diff --git a/app/assets/javascripts/protocols/index.js b/app/assets/javascripts/protocols/index.js index eed54dc7c..c892e59f0 100644 --- a/app/assets/javascripts/protocols/index.js +++ b/app/assets/javascripts/protocols/index.js @@ -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"), diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index ee40a4c92..1f3d46130 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -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 diff --git a/app/views/protocols/index/_protocol_preview_modal_footer.html.erb b/app/views/protocols/index/_protocol_preview_modal_footer.html.erb index 430b7e028..6b60460a4 100644 --- a/app/views/protocols/index/_protocol_preview_modal_footer.html.erb +++ b/app/views/protocols/index/_protocol_preview_modal_footer.html.erb @@ -1,4 +1,6 @@ <% 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 %> diff --git a/app/views/search/results/_protocols.html.erb b/app/views/search/results/_protocols.html.erb index 2a9de39b0..e3aea0810 100644 --- a/app/views/search/results/_protocols.html.erb +++ b/app/views/search/results/_protocols.html.erb @@ -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 @@
<% end %> + +<%= stylesheet_link_tag 'datatables' %> +<%= javascript_include_tag "protocols/index" %> +<%= javascript_include_tag "protocols/steps" %> + + +<%= 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" %> diff --git a/app/views/search/results/partials/_protocol_text.html.erb b/app/views/search/results/partials/_protocol_text.html.erb index 137f7a62d..cfb09b68d 100644 --- a/app/views/search/results/partials/_protocol_text.html.erb +++ b/app/views/search/results/partials/_protocol_text.html.erb @@ -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? %> +<% if protocol.in_repository_public? %> - + <%=t "search.index.public" %> + +   +<% elsif protocol.in_repository_private? %> + + <%=t "search.index.private" %> + +   +<% elsif protocol.in_repository_archived? %> + + <%=t "search.index.archived" %>   - <% 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? %> - - <%=t "search.index.public" %> - -   - <% elsif protocol.in_repository_private? %> - - <%=t "search.index.private" %> - -   - <% elsif protocol.in_repository_archived? %> - - <%=t "search.index.archived" %> - -   - <% 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 %>