From d16930e987e8110fcee766ba9bb7a64d463f6247 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Wed, 20 May 2020 17:23:48 +0200 Subject: [PATCH] Add private tasks to assigned task list --- .../shared/my_modules_list_partial.scss | 7 +++++++ app/controllers/repository_rows_controller.rb | 13 ++++++++----- .../_repository_row_info_modal.html.erb | 15 +++++++++------ .../shared/_my_modules_list_partial.html.erb | 13 +++++++------ config/locales/en.yml | 3 +++ 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/app/assets/stylesheets/shared/my_modules_list_partial.scss b/app/assets/stylesheets/shared/my_modules_list_partial.scss index e42834c12..dcef1bf8b 100644 --- a/app/assets/stylesheets/shared/my_modules_list_partial.scss +++ b/app/assets/stylesheets/shared/my_modules_list_partial.scss @@ -57,6 +57,13 @@ } } + .private-tasks-counter { + @include font-button; + border-top: $border-tertiary; + color: $color-silver-chalice; + padding-top: .5em; + } + .archived { @include font-small; background: $brand-warning; diff --git a/app/controllers/repository_rows_controller.rb b/app/controllers/repository_rows_controller.rb index dce0099d5..9bb325016 100644 --- a/app/controllers/repository_rows_controller.rb +++ b/app/controllers/repository_rows_controller.rb @@ -49,8 +49,9 @@ class RepositoryRowsController < ApplicationController end def show - @assigned_modules = MyModuleRepositoryRow.eager_load(my_module: [{ experiment: :project }]) - .where(repository_row: @repository_row) + @assigned_modules = @repository_row.my_modules.joins(experiment: :project) + @viewable_modules = @assigned_modules.viewable_by_user(current_user, current_user.teams) + @private_modules = @assigned_modules - @viewable_modules respond_to do |format| format.json do @@ -152,11 +153,13 @@ class RepositoryRowsController < ApplicationController end def assigned_task_list - my_modules = @repository_row.my_modules.joins(experiment: :project) - .search_by_name(current_user, current_team, params[:query]) + assigned_modules = @repository_row.my_modules.joins(experiment: :project) + private_modules = assigned_modules - assigned_modules.viewable_by_user(current_user, current_user.teams) + viewable_modules = assigned_modules.search_by_name(current_user, current_user.teams, params[:query]) render json: { html: render_to_string(partial: 'shared/my_modules_list_partial.html.erb', locals: { - my_modules: my_modules + my_modules: viewable_modules, + private_modules: private_modules }) } end diff --git a/app/views/repositories/_repository_row_info_modal.html.erb b/app/views/repositories/_repository_row_info_modal.html.erb index 618da9ec5..ce9ed0173 100644 --- a/app/views/repositories/_repository_row_info_modal.html.erb +++ b/app/views/repositories/_repository_row_info_modal.html.erb @@ -40,36 +40,38 @@

<% if @repository_row.repository.is_a?(Repository) %> - <% if @assigned_modules.size > 0 %> + <% if @assigned_modules.size.positive? %>
<%= t('repository_row.modal_info.title', nr: @assigned_modules.size) %> + <%= t('repository_row.modal_info.private_tasks', nr: @private_modules.size) if @private_modules.size.positive? %>
+ <% if @viewable_modules.size.positive? %>
- <% @assigned_modules.each_with_index do |element, i| %> + <% @viewable_modules.each do |my_module| %>
+ <% end %> <% else %> <%= t('repository_row.modal_info.no_tasks') %> <% end %> diff --git a/app/views/shared/_my_modules_list_partial.html.erb b/app/views/shared/_my_modules_list_partial.html.erb index d35776e66..52e31209a 100644 --- a/app/views/shared/_my_modules_list_partial.html.erb +++ b/app/views/shared/_my_modules_list_partial.html.erb @@ -19,14 +19,15 @@ <% if task.archived %> <%= t('general.archived') %> <% end %> - <% if can_read_experiment?(current_user, task.experiment) %> - <%= link_to(task.name, protocols_my_module_path(task.id), {class: "task-link", title: task.name, target: "_blank"}) %> - <% else %> - <%= task.name %> - <% end %> + <%= link_to(task.name, protocols_my_module_path(task.id), {class: "task-link", title: task.name, target: "_blank"}) %> <% end %> - <% end %> + <% end %> + <% if defined?(private_modules) && private_modules.size.positive? %> +
+ <%= t('my_modules.modules_list_partial.private_tasks_html', nr: private_modules.size ) %> +
+ <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 1060507d2..01d6531c4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -831,6 +831,8 @@ en: message: Do you want to assign %{size} items only to this task, or assign them to this task & downstream tasks in the workflow as well? task: 'Assign to task' task_and_downstream: 'Assign to task & downstream' + modules_list_partial: + private_tasks_html: 'Assigned to %{nr} private task(s)' unshared_inventory: title_html: The inventory %{inventory_name} is no longer shared with your team. body_html: This inventory has been ushared with your team by the inventory’s owner. To view the item/s that are assigned to your task/s contact the %{team_name} team administrator %{admin_name} (%{admin_email}). @@ -1320,6 +1322,7 @@ en: added_by: "Added by" custom_field: "%{cf}: " title: "This item is assigned to %{nr} tasks." + private_tasks: "%{nr} task(s) are private and will not be displayed." no_tasks: "This item in not assigned to any task." samples: columns: "Columns"