From 2486bd0077da264366d60c19dd0df29a8a26ff8b Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Thu, 5 Sep 2019 14:03:08 +0200 Subject: [PATCH 1/3] SCI3818-unshared-inventory-screen --- app/assets/stylesheets/repositories.scss | 4 ++++ app/controllers/my_modules_controller.rb | 6 ++++++ app/views/my_modules/_repositories_dropdown.html.erb | 8 +++++--- config/locales/en.yml | 5 ++++- config/routes.rb | 3 +++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/repositories.scss b/app/assets/stylesheets/repositories.scss index b64087679..bc74166c3 100644 --- a/app/assets/stylesheets/repositories.scss +++ b/app/assets/stylesheets/repositories.scss @@ -25,6 +25,10 @@ .fas-custom{ float: right; } + + a.muted { + opacity: 0.7 + } } .repository-share-status { diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 20dd28547..97e97ca4f 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -623,6 +623,12 @@ class MyModulesController < ApplicationController end end + def unshared_inventory + render_403 unless Repository.used_on_task_but_unshared(@my_module, current_team).pluck(:id).include?(params[:inventory_id].to_i) + @inventory = Repository.find(params[:inventory_id]) + @inventory_admin = @inventory.created_by + end + private def task_completion_activity diff --git a/app/views/my_modules/_repositories_dropdown.html.erb b/app/views/my_modules/_repositories_dropdown.html.erb index 2af29c4d8..33d255972 100644 --- a/app/views/my_modules/_repositories_dropdown.html.erb +++ b/app/views/my_modules/_repositories_dropdown.html.erb @@ -22,13 +22,15 @@ <% Repository.used_on_task_but_unshared(@my_module, current_team).each do |repository| %>
  • - + title="<%= repository.name %>" + href="<%= unshared_inventory_my_module_url(inventory_id: repository.id)%>"> + <% if enable_counters %> <% cache [repository, @my_module] do %> <%= truncate(repository.name) %> - <%= "(#{@my_module.repository_rows_count(repository)})" %> + <%= "(#{@my_module.repository_rows_count()})" %> <% end %> <% else %> <%= truncate(repository.name) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 2ae8107c9..91dfedd33 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -757,6 +757,9 @@ en: task_and_downstream: 'Task & Downstream' unassign_title: "Unassign %{repository_name} items from task %{my_module_name}" unassign_message: "Do you want to unassign %{size} items only from this task, or unassign them from this task & downstream tasks in the workflow as well?" + unshared_inventory: + title: The inventory %{inventory_name} is no longer shared with your team. + body: This inventory has been ushared with your team by the inventory’s owner (%{team_name} team). To view the item/s that are assigned to your task/s contact the %{team_name} team administrator (%{admin_name}, %{admin_email}). experiments: new: create: 'New Experiment' @@ -1032,7 +1035,7 @@ en: can_edit: "Can Edit" all_teams: "All teams (current & new)" all_teams_tooltip: "This will disable individual team settings" - success_message: “Selected sharing options for the Inventory %{inventory_name} have been saved.” + success_message: “Selected sharing options for the Inventory %{inventory_name} have been saved.” table: id: 'ID' assigned: "Assigned" diff --git a/config/routes.rb b/config/routes.rb index 1afc8c5b1..054c683b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -405,6 +405,9 @@ Rails.application.routes.draw do post 'unassign_repository_records/:repository_id', to: 'my_modules#unassign_repository_records', as: :unassign_repository_records + get 'unshared_inventory/:inventory_id', + to: "my_modules#unshared_inventory", + as: :unshared_inventory get 'archive' # Archive view for single module get 'complete_my_module' post 'toggle_task_state' From 7fc5035d2ddfcacb81f6b109b115957f4f482029 Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Fri, 6 Sep 2019 13:47:06 +0200 Subject: [PATCH 2/3] PR fixes, codestyle fixes --- app/assets/stylesheets/repositories.scss | 2 +- app/controllers/my_modules_controller.rb | 10 +++++++--- app/views/my_modules/_repositories_dropdown.html.erb | 2 +- config/routes.rb | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/repositories.scss b/app/assets/stylesheets/repositories.scss index bc74166c3..9028b65cd 100644 --- a/app/assets/stylesheets/repositories.scss +++ b/app/assets/stylesheets/repositories.scss @@ -27,7 +27,7 @@ } a.muted { - opacity: 0.7 + opacity: .7; } } diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 97e97ca4f..3c62557df 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -16,7 +16,7 @@ class MyModulesController < ApplicationController assign_repository_records unassign_repository_records unassign_repository_records_modal assign_repository_records_modal - repositories_dropdown update_description update_protocol_description) + repositories_dropdown update_description update_protocol_description unshared_inventory) before_action :load_vars_nested, only: %i(new create) before_action :load_repository, only: %i(assign_repository_records unassign_repository_records @@ -24,7 +24,7 @@ class MyModulesController < ApplicationController assign_repository_records_modal repository_index) before_action :load_projects_tree, only: %i(protocols results activities - samples repository archive) + samples repository archive unshared_inventory) before_action :check_manage_permissions_archive, only: %i(update destroy) before_action :check_manage_permissions, only: %i(description due_date update_description update_protocol_description) @@ -624,7 +624,11 @@ class MyModulesController < ApplicationController end def unshared_inventory - render_403 unless Repository.used_on_task_but_unshared(@my_module, current_team).pluck(:id).include?(params[:inventory_id].to_i) + #binding.pry + render_403 unless Repository.used_on_task_but_unshared(@my_module, current_team) + .where(id: params[:inventory_id]) + .any? + @inventory = Repository.find(params[:inventory_id]) @inventory_admin = @inventory.created_by end diff --git a/app/views/my_modules/_repositories_dropdown.html.erb b/app/views/my_modules/_repositories_dropdown.html.erb index 33d255972..530cc814e 100644 --- a/app/views/my_modules/_repositories_dropdown.html.erb +++ b/app/views/my_modules/_repositories_dropdown.html.erb @@ -25,7 +25,7 @@ + href="<%= unshared_inventory_my_module_path(inventory_id: repository.id)%>"> <% if enable_counters %> <% cache [repository, @my_module] do %> diff --git a/config/routes.rb b/config/routes.rb index 054c683b0..ffb1d9bd5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -403,11 +403,11 @@ Rails.application.routes.draw do to: 'my_modules#unassign_repository_records_modal', as: :unassign_repository_records_modal post 'unassign_repository_records/:repository_id', - to: 'my_modules#unassign_repository_records', - as: :unassign_repository_records + to: 'my_modules#unassign_repository_records', + as: :unassign_repository_records get 'unshared_inventory/:inventory_id', - to: "my_modules#unshared_inventory", - as: :unshared_inventory + to: "my_modules#unshared_inventory", + as: :unshared_inventory get 'archive' # Archive view for single module get 'complete_my_module' post 'toggle_task_state' From d522b3807a6c37d196b7c966d2d2caf5d15a5131 Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Fri, 6 Sep 2019 14:59:30 +0200 Subject: [PATCH 3/3] codestyle improvements --- app/controllers/my_modules_controller.rb | 7 +------ config/routes.rb | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 3c62557df..f19a9d739 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -624,12 +624,7 @@ class MyModulesController < ApplicationController end def unshared_inventory - #binding.pry - render_403 unless Repository.used_on_task_but_unshared(@my_module, current_team) - .where(id: params[:inventory_id]) - .any? - - @inventory = Repository.find(params[:inventory_id]) + @inventory = Repository.used_on_task_but_unshared(@my_module, current_team).find(params[:inventory_id]) @inventory_admin = @inventory.created_by end diff --git a/config/routes.rb b/config/routes.rb index ffb1d9bd5..54c1af14e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -406,7 +406,7 @@ Rails.application.routes.draw do to: 'my_modules#unassign_repository_records', as: :unassign_repository_records get 'unshared_inventory/:inventory_id', - to: "my_modules#unshared_inventory", + to: 'my_modules#unshared_inventory', as: :unshared_inventory get 'archive' # Archive view for single module get 'complete_my_module'