From 80621c9b6bd1cabb24fcc6d5a6983ac7b3dd9167 Mon Sep 17 00:00:00 2001
From: Jure Grabnar
Date: Tue, 26 Jul 2016 12:12:43 +0200
Subject: [PATCH] Add experiment text to all searches related to experiment
---
app/views/search/results/_assets.html.erb | 7 ++++++-
app/views/search/results/_checklists.html.erb | 5 +++++
.../search/results/_experiments.html.erb | 3 ++-
app/views/search/results/_modules.html.erb | 9 ++++++--
app/views/search/results/_protocols.html.erb | 5 +++++
app/views/search/results/_results.html.erb | 7 ++++++-
app/views/search/results/_steps.html.erb | 5 +++++
app/views/search/results/_tables.html.erb | 7 ++++++-
app/views/search/results/_workflows.html.erb | 7 ++++++-
.../partials/_experiment_text.html.erb | 21 +++++++++++++++++++
config/locales/en.yml | 1 +
config/routes.rb | 2 ++
12 files changed, 72 insertions(+), 7 deletions(-)
create mode 100644 app/views/search/results/partials/_experiment_text.html.erb
diff --git a/app/views/search/results/_assets.html.erb b/app/views/search/results/_assets.html.erb
index 68623490c..204781079 100644
--- a/app/views/search/results/_assets.html.erb
+++ b/app/views/search/results/_assets.html.erb
@@ -59,9 +59,14 @@
<%= render partial: "search/results/partials/my_module_text.html.erb", locals: { my_module: asset.result.my_module } %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: asset.result.my_module.experiment } %>
+
+
<%=t "search.index.project" %>
- <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: asset.result.my_module.project } %>
+ <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: asset.result.my_module.experiment.project } %>
diff --git a/app/views/search/results/_checklists.html.erb b/app/views/search/results/_checklists.html.erb
index d2392c9e6..c1aff6dd2 100644
--- a/app/views/search/results/_checklists.html.erb
+++ b/app/views/search/results/_checklists.html.erb
@@ -34,6 +34,11 @@
<%= render partial: "search/results/partials/my_module_text.html.erb", locals: { my_module: checklist.step.protocol.my_module } %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: checklist.step.protocol.my_modul.experiment } %>
+
+
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb", locals: { project: checklist.step.protocol.my_module.project } %>
diff --git a/app/views/search/results/_experiments.html.erb b/app/views/search/results/_experiments.html.erb
index 6990072f7..2567a84f1 100644
--- a/app/views/search/results/_experiments.html.erb
+++ b/app/views/search/results/_experiments.html.erb
@@ -1,7 +1,8 @@
<% results.each do |experiment| %>
- <%= highlight experiment.name, search_query.strip.split(/\s+/) %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb",
+ locals: { experiment: experiment, query: search_query } %>
diff --git a/app/views/search/results/_modules.html.erb b/app/views/search/results/_modules.html.erb
index bcd7b885e..355b2f08d 100644
--- a/app/views/search/results/_modules.html.erb
+++ b/app/views/search/results/_modules.html.erb
@@ -19,14 +19,19 @@
<%=l mod.created_at, format: :full %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: mod.experiment } %>
+
+
<%=t "search.index.project" %>
- <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: mod.project } %>
+ <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: mod.experiment.project } %>
<%=t "search.index.organization" %>
- <%= render partial: "search/results/partials/organization_text.html.erb", locals: { organization: mod.project.organization } %>
+ <%= render partial: "search/results/partials/organization_text.html.erb", locals: { organization: mod.experiment.project.organization } %>
diff --git a/app/views/search/results/_protocols.html.erb b/app/views/search/results/_protocols.html.erb
index 1597cdde8..cf01e270e 100644
--- a/app/views/search/results/_protocols.html.erb
+++ b/app/views/search/results/_protocols.html.erb
@@ -54,6 +54,11 @@
<%= render partial: "search/results/partials/my_module_text.html.erb", locals: { my_module: protocol.my_module } %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: protocol.my_module.experiment } %>
+
+
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb", locals: { project: protocol.my_module.project } %>
diff --git a/app/views/search/results/_results.html.erb b/app/views/search/results/_results.html.erb
index b8842a743..78cde2957 100644
--- a/app/views/search/results/_results.html.erb
+++ b/app/views/search/results/_results.html.erb
@@ -34,9 +34,14 @@
<%= render partial: "search/results/partials/my_module_text.html.erb", locals: { my_module: result.my_module } %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: result.my_module.experiment } %>
+
+
<%=t "search.index.project" %>
- <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: result.my_module.project } %>
+ <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: result.my_module.experiment.project } %>
diff --git a/app/views/search/results/_steps.html.erb b/app/views/search/results/_steps.html.erb
index 19e6c7363..972a33d72 100644
--- a/app/views/search/results/_steps.html.erb
+++ b/app/views/search/results/_steps.html.erb
@@ -26,6 +26,11 @@
locals: { my_module: step.protocol.my_module, link_to_page: :protocols } %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: step.protocol.my_module.experiment } %>
+
+
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb", locals: { project: step.protocol.my_module.project } %>
diff --git a/app/views/search/results/_tables.html.erb b/app/views/search/results/_tables.html.erb
index 372914aba..3b827f01b 100644
--- a/app/views/search/results/_tables.html.erb
+++ b/app/views/search/results/_tables.html.erb
@@ -23,9 +23,14 @@
locals: { my_module: table.step.protocol.my_module, link_to_page: :results } %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: table.step.protocol.my_module.experiment } %>
+
+
<%=t "search.index.project" %>
- <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: table.step.protocol.my_module.project } %>
+ <%= render partial: "search/results/partials/project_text.html.erb", locals: { project: table.step.protocol.my_module.experiment.project } %>
<% else %>
diff --git a/app/views/search/results/_workflows.html.erb b/app/views/search/results/_workflows.html.erb
index e5c3164ac..e84d0ced2 100644
--- a/app/views/search/results/_workflows.html.erb
+++ b/app/views/search/results/_workflows.html.erb
@@ -10,10 +10,15 @@
<%=l workflow.created_at, format: :full %>
+
+ <%=t "search.index.experiment" %>
+ <%= render partial: "search/results/partials/experiment_text.html.erb", locals: { experiment: workflow.protocol.my_module.experiment } %>
+
+
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
- locals: { project: workflow.project, link_to_page: :canvas } %>
+ locals: { project: workflow.experiment.project, link_to_page: :canvas } %>
diff --git a/app/views/search/results/partials/_experiment_text.html.erb b/app/views/search/results/partials/_experiment_text.html.erb
new file mode 100644
index 000000000..0a05d56f5
--- /dev/null
+++ b/app/views/search/results/partials/_experiment_text.html.erb
@@ -0,0 +1,21 @@
+<% query ||= nil %>
+<% text = query.present? ? highlight(experiment.name, query.strip.split(/\s+/)) : experiment.name %>
+
+<% if experiment.archived? %>
+ <%=t "search.index.archived" %>
+ <% if can_view_experiment(experiment) and can_restore_experiment(experiment.project) %>
+
+ <%= text %>
+
+ <% else %>
+ <%= text %>
+ <% end %>
+<% else %>
+ <% if can_view_experiment(experiment) %>
+
+ <%= text %>
+
+ <% else %>
+ <%= text %>
+ <% end %>
+<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 6688c9cba..1744db178 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -109,6 +109,7 @@ en:
no_description: "No description"
organization: "Team: "
project: "Project: "
+ experiment: "Experiment: "
protocol: "Protocol: "
modules: "Tasks: "
tag_no_modules: "not added to any tasks"
diff --git a/config/routes.rb b/config/routes.rb
index b500075df..11b5c2db5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -106,6 +106,8 @@ Rails.application.routes.draw do
get 'users/edit', to: 'user_projects#index_edit'
end
+ resources :experiments, only: [:show]
+
# Show action is a popup (JSON) for individual module in full-zoom canvas,
# as well as "module info" page for single module (HTML)
resources :my_modules, path: "/modules", only: [:show, :edit, :update, :destroy] do