From 7c99eaed8f7f8de043c9c9d89b9c43c15bc538a5 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Fri, 5 Feb 2021 12:39:26 +0100 Subject: [PATCH] Add folder links to global search [SCI-5407] --- app/controllers/search_controller.rb | 1 + app/views/search/results/_experiments.html.erb | 8 ++++++++ app/views/search/results/_modules.html.erb | 8 ++++++++ app/views/search/results/_project_folders.html.erb | 8 ++++++++ app/views/search/results/_projects.html.erb | 8 ++++++++ .../search/results/partials/_project_folder_text.html.erb | 6 +----- .../results/partials/_project_folders_text.html.erb | 4 ++++ config/locales/en.yml | 1 + 8 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 app/views/search/results/partials/_project_folders_text.html.erb diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 257172f2c..2d945d30a 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,5 +1,6 @@ class SearchController < ApplicationController include IconsHelper + include ProjectFoldersHelper before_action :load_vars, only: :index def index diff --git a/app/views/search/results/_experiments.html.erb b/app/views/search/results/_experiments.html.erb index 7c15b627d..2c46e2267 100644 --- a/app/views/search/results/_experiments.html.erb +++ b/app/views/search/results/_experiments.html.erb @@ -17,6 +17,14 @@ locals: { project: experiment.project, link_to_page: :show } %>
+ <% if experiment.project.project_folder %> + + <%=t "search.index.folder" %> + <%= render partial: "search/results/partials/project_folders_text.html.erb", + locals: { folder: experiment.project.project_folder } %> + +
+ <% end %> <%=t "search.index.team" %> <%= render partial: "search/results/partials/team_text.html.erb", diff --git a/app/views/search/results/_modules.html.erb b/app/views/search/results/_modules.html.erb index 3f1ca4bea..7b3f32318 100644 --- a/app/views/search/results/_modules.html.erb +++ b/app/views/search/results/_modules.html.erb @@ -34,6 +34,14 @@ locals: { project: mod.experiment.project, link_to_page: :show } %>
+ <% if mod.experiment.project.project_folder %> + + <%=t "search.index.folder" %> + <%= render partial: "search/results/partials/project_folders_text.html.erb", + locals: { folder: mod.experiment.project.project_folder } %> + +
+ <% end %> <%=t "search.index.team" %> <%= render partial: "search/results/partials/team_text.html.erb", diff --git a/app/views/search/results/_project_folders.html.erb b/app/views/search/results/_project_folders.html.erb index c6f8fa6b5..fff7b5ee8 100644 --- a/app/views/search/results/_project_folders.html.erb +++ b/app/views/search/results/_project_folders.html.erb @@ -11,6 +11,14 @@ <%= l(project_folder.created_at, format: :full) %>
+ <% if project_folder.parent_folder %> + + <%=t "search.index.folder" %> + <%= render partial: "search/results/partials/project_folders_text.html.erb", + locals: { folder: project_folder.parent_folder } %> + +
+ <% end %> <%= t('search.index.team') %> <%= render partial: 'search/results/partials/team_text.html.erb', locals: { team: project_folder.team } %> diff --git a/app/views/search/results/_projects.html.erb b/app/views/search/results/_projects.html.erb index 869659151..5f13af619 100644 --- a/app/views/search/results/_projects.html.erb +++ b/app/views/search/results/_projects.html.erb @@ -11,6 +11,14 @@ <%=l project.created_at, format: :full %>
+ <% if project.project_folder %> + + <%=t "search.index.folder" %> + <%= render partial: "search/results/partials/project_folders_text.html.erb", + locals: { folder: project.project_folder } %> + +
+ <% end %> <%=t 'search.index.team' %> <%= render partial: 'search/results/partials/team_text.html.erb', diff --git a/app/views/search/results/partials/_project_folder_text.html.erb b/app/views/search/results/partials/_project_folder_text.html.erb index 3e367ee01..745e01eff 100644 --- a/app/views/search/results/partials/_project_folder_text.html.erb +++ b/app/views/search/results/partials/_project_folder_text.html.erb @@ -2,11 +2,7 @@ <% text = query.present? ? highlight(project_folder.name, query.strip.split(/\s+/)) : project_folder.name %> <% if can_read_team?(project_folder.team) %> - <% if link_to_page == :show %> - <%= route_to_other_team(projects_path, project_folder.team, text) %> - <% else %> - <%= route_to_other_team(projects_path, project_folder.team, text) %> - <% end %> + <%= route_to_other_team(project_folder_path(project_folder), project_folder.team, text) %> <% else %> <%= text %> <% end %> diff --git a/app/views/search/results/partials/_project_folders_text.html.erb b/app/views/search/results/partials/_project_folders_text.html.erb new file mode 100644 index 000000000..e477fe12f --- /dev/null +++ b/app/views/search/results/partials/_project_folders_text.html.erb @@ -0,0 +1,4 @@ +<% tree_ordered_parent_folders(folder)&.each do |project_folder| %> + <%= route_to_other_team(project_folder_path(project_folder), project_folder.team, project_folder.name) %> + / +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index a41543113..78285222a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -273,6 +273,7 @@ en: description: "Description: " no_description: "No description" team: "Team: " + folder: "Folders: " repository: "Inventory: " repository_row: "Inventory item: " project: "Project: "