Merge pull request #129 from mlorb/ml_sci_310

adds tasks, experiment and project category in protocol search results [SCI-310]
This commit is contained in:
mlorb 2016-09-05 15:31:35 +02:00 committed by GitHub
commit aea288371f
10 changed files with 61 additions and 9 deletions

View file

@ -146,6 +146,18 @@ class Protocol < ActiveRecord::Base
end
end
def linked_modules
MyModule.joins(:protocols).where('protocols.parent_id = ?', id)
end
def linked_experiments(linked_mod)
Experiment.where('id IN (?)', linked_mod.pluck(:experiment_id).uniq)
end
def linked_projects(linked_exp)
Project.where('id IN (?)', linked_exp.pluck(:project_id).uniq)
end
def self.new_blank_for_module(my_module)
Protocol.new(
organization: my_module.experiment.project.organization,

View file

@ -38,7 +38,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: asset.step.protocol.my_module.experiment.project } %>
locals: { project: asset.step.protocol.my_module.experiment.project, link_to_page: :show } %>
</span>
<% else %>
<span>

View file

@ -45,7 +45,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: checklist.step.protocol.my_module.experiment.project } %>
locals: { project: checklist.step.protocol.my_module.experiment.project, link_to_page: :show } %>
</span>
<% else %>
<span>

View file

@ -28,7 +28,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: mod.experiment.project } %>
locals: { project: mod.experiment.project, link_to_page: :show } %>
</span>
<br>
<span>

View file

@ -48,6 +48,47 @@
<%=l protocol.created_at, format: :full %>
</span>
<br>
<% if protocol.nr_of_linked_children > 0 %>
<span>
<% if protocol_linked_modules = protocol.linked_modules %>
<%=t "search.index.modules" %>
<% protocol_linked_modules.each_with_index do |mod, i| %>
<%= render partial: "search/results/partials/my_module_text.html.erb",
locals: { my_module: mod } %>
<% if i != (protocol_linked_modules.count - 1) %>
,&nbsp;
<% end %>
<% end %>
<% end %>
</span>
<br>
<span>
<% if protocol_linked_experiments = protocol.linked_experiments(protocol_linked_modules) %>
<%=t "search.index.experiment" %>
<% protocol_linked_experiments.each_with_index do |exp, i| %>
<%= render partial: "search/results/partials/experiment_text.html.erb",
locals: { experiment: exp } %>
<% if i != (protocol_linked_experiments.count - 1) %>
,&nbsp;
<% end %>
<% end %>
<% end %>
</span>
<br>
<span>
<% if protocol_linked_projects = protocol.linked_projects(protocol_linked_experiments) %>
<%=t "search.index.project" %>
<% protocol_linked_projects.each_with_index do |pro, i| %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: pro, link_to_page: :show } %>
<% if i != (protocol_linked_projects.count - 1) %>
,&nbsp;
<% end %>
<% end %>
<% end %>
</span>
<% end %>
<br>
<% if protocol.in_module? %>
<span>
<%=t "search.index.module" %>

View file

@ -39,7 +39,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: report.project } %>
locals: { project: report.project, link_to_page: :show } %>
</span>
<br>
<span>

View file

@ -44,7 +44,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: result.my_module.experiment.project } %>
locals: { project: result.my_module.experiment.project, link_to_page: :show } %>
</span>
<br>
<span>

View file

@ -35,7 +35,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: step.protocol.my_module.experiment.project } %>
locals: { project: step.protocol.my_module.experiment.project, link_to_page: :show } %>
</span>
<% else %>
<span>

View file

@ -35,7 +35,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: table.step.protocol.my_module.experiment.project } %>
locals: { project: table.step.protocol.my_module.experiment.project, link_to_page: :show } %>
</span>
<% else %>
<span>

View file

@ -31,7 +31,6 @@
<% experiments_results(tag).each_with_index do |exp, i| %>
<%= render partial: 'search/results/partials/experiment_text.html.erb',
locals: { experiment: exp } %>
<% #byebug %>
<% if i != (experiments_results(tag).count - 1) %>
,&nbsp;
<% end %>
@ -42,7 +41,7 @@
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: tag.project } %>
locals: { project: tag.project, link_to_page: :show } %>
</span>
<br>
<span>