mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-05 22:44:22 +08:00
Merge pull request #387 from mlorb/ml_sci_732
Add protocol preview to search results [SCI-732]
This commit is contained in:
commit
f14ad0f762
5 changed files with 58 additions and 35 deletions
|
@ -191,7 +191,13 @@ function initKeywordFiltering() {
|
|||
function initProtocolPreviewModal() {
|
||||
// Only do this if the repository is public/private
|
||||
if (repositoryType !== "archive") {
|
||||
protocolsTableEl.on("click", "a[data-action='protocol-preview']", function(e) {
|
||||
// If you are in protocol repository
|
||||
var protocolsEl = protocolsTableEl;
|
||||
// If you are in search results
|
||||
if (document.getElementById("search-content")) {
|
||||
protocolsEl = $("#search-content");
|
||||
}
|
||||
protocolsEl.on("click", "a[data-action='protocol-preview']", function(e) {
|
||||
var link = $(this);
|
||||
$.ajax({
|
||||
url: link.attr("data-url"),
|
||||
|
|
|
@ -17,4 +17,16 @@ module SearchHelper
|
|||
link_to text, path
|
||||
end
|
||||
end
|
||||
|
||||
def route_to_other_org_btn(path, search_org, text)
|
||||
if search_org != current_organization
|
||||
link_to text,
|
||||
path,
|
||||
class: 'btn btn-primary',
|
||||
data: { confirm: t('users.settings.changed_org_in_search',
|
||||
team: search_org.name) }
|
||||
else
|
||||
link_to text, path, class: 'btn btn-primary'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.close" %></button>
|
||||
<% if can_edit_protocol(@protocol) %>
|
||||
<%= link_to t("general.edit"), edit_protocol_path(@protocol), :class => "btn btn-primary" %>
|
||||
<%= route_to_other_org_btn edit_protocol_path(protocol),
|
||||
protocol.organization,
|
||||
t("general.edit") %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<%= render partial: "protocols/index/protocol_preview_modal.html.erb" %>
|
||||
|
||||
<% results.each do |protocol| %>
|
||||
<% has_description = protocol.description.present? && !protocol.description.empty? %>
|
||||
<% has_authors = protocol.authors.present? && !protocol.authors.empty? %>
|
||||
|
@ -119,3 +121,20 @@
|
|||
<hr>
|
||||
|
||||
<% end %>
|
||||
|
||||
<%= stylesheet_link_tag 'datatables' %>
|
||||
<%= javascript_include_tag "protocols/index" %>
|
||||
<%= javascript_include_tag "protocols/steps" %>
|
||||
|
||||
<!-- Libraries for formulas -->
|
||||
<%= javascript_include_tag "lodash" %>
|
||||
<%= javascript_include_tag "numeral" %>
|
||||
<%= javascript_include_tag "numeric" %>
|
||||
<%= javascript_include_tag "md5" %>
|
||||
<%= javascript_include_tag "jstat" %>
|
||||
<%= javascript_include_tag "formula" %>
|
||||
<%= javascript_include_tag "parser" %>
|
||||
<%= javascript_include_tag "ruleJS" %>
|
||||
<%= javascript_include_tag "handsontable.formula" %>
|
||||
<%= javascript_include_tag "big.min" %>
|
||||
<%= stylesheet_link_tag "handsontable.formula" %>
|
||||
|
|
|
@ -1,40 +1,24 @@
|
|||
<% query ||= nil %>
|
||||
<% text = query.present? ? highlight(protocol.name, query.strip.split(/\s+/)) : (protocol.name.empty? ? t("search.index.no_name") : protocol.name) %>
|
||||
|
||||
<% if protocol.in_module? %>
|
||||
<span class="label label-info">
|
||||
<span class="glyphicon glyphicon-credit-card"></span>
|
||||
</span>
|
||||
|
||||
<% if can_view_steps_in_protocol(protocol) %>
|
||||
<%= route_to_other_org protocols_my_module_path(protocol.my_module),
|
||||
protocol.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if protocol.in_repository_public? %>
|
||||
<% if protocol.in_repository_public? %>
|
||||
<span class="label label-info">
|
||||
<%=t "search.index.public" %>
|
||||
</span>
|
||||
|
||||
<% elsif protocol.in_repository_private? %>
|
||||
<% elsif protocol.in_repository_private? %>
|
||||
<span class="label label-info">
|
||||
<%=t "search.index.private" %>
|
||||
</span>
|
||||
|
||||
<% elsif protocol.in_repository_archived? %>
|
||||
<% elsif protocol.in_repository_archived? %>
|
||||
<span class="label label-warning">
|
||||
<%=t "search.index.archived" %>
|
||||
</span>
|
||||
|
||||
<% end %>
|
||||
<% if can_edit_protocol(protocol) %>
|
||||
<%= route_to_other_org edit_protocol_path(protocol),
|
||||
protocol.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if can_view_protocol(protocol) %>
|
||||
<%= link_to text, '#', 'data-action': 'protocol-preview', 'data-url': preview_protocol_path(protocol) %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue