scinote-web/app/views/search/results/_protocols.html.erb

81 lines
2.5 KiB
Plaintext
Raw Normal View History

2016-07-21 19:11:15 +08:00
<% results.each do |protocol| %>
<% has_description = protocol.description.present? && !protocol.description.empty? %>
<% has_authors = protocol.authors.present? && !protocol.authors.empty? %>
<% has_keywords = protocol.in_repository? && protocol.protocol_keywords.count > 0 %>
<h5>
<span class="glyphicon glyphicon-list-alt"></span>
<%= render partial: "search/results/partials/protocol_text.html.erb", locals: { protocol: protocol, query: search_query } %>
</h5>
<% if has_description || has_authors || has_keywords %>
<p>
<% if has_description %>
<span>
<%=t "search.index.description" %>
<%= highlight protocol.description, search_query.strip.split(/\s+/) %>
</span>
<% if has_authors || has_keywords %>
<br>
<% end %>
<% end %>
<% if has_authors %>
<span>
<%=t "search.index.authors" %>
<%= highlight protocol.authors, search_query.strip.split(/\s+/) %>
</span>
<% if has_keywords %>
<br>
<% end %>
<% end %>
<% if has_keywords %>
<span>
<%=t "search.index.keywords" %>
<% protocol.protocol_keywords.each_with_index do |kw, i| %>
<%= highlight kw.name, search_query.strip.split(/\s+/) %>
<% if i < protocol.protocol_keywords.count - 1 %>
,&nbsp;
<% end %>
<% end %>
</span>
<% end %>
</p>
<% end %>
<p>
<span>
<%=t "search.index.created_at" %>
<%=l protocol.created_at, format: :full %>
</span>
<br>
<% if protocol.in_module? %>
<span>
<%=t "search.index.module" %>
<%= render partial: "search/results/partials/my_module_text.html.erb",
locals: { my_module: protocol.my_module } %>
2016-07-21 19:11:15 +08:00
</span>
<br>
<span>
<%=t "search.index.experiment" %>
<%= render partial: "search/results/partials/experiment_text.html.erb",
locals: { experiment: protocol.my_module.experiment } %>
</span>
<br>
2016-07-21 19:11:15 +08:00
<span>
<%=t "search.index.project" %>
<%= render partial: "search/results/partials/project_text.html.erb",
locals: { project: protocol.my_module.experiment.project } %>
2016-07-21 19:11:15 +08:00
</span>
<br>
<% end %>
<span>
<%=t "search.index.organization" %>
<%= render partial: "search/results/partials/organization_text.html.erb",
locals: { organization: protocol.organization } %>
2016-07-21 19:11:15 +08:00
</span>
</p>
<hr>
<% end %>