mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
355 lines
17 KiB
Text
355 lines
17 KiB
Text
<% provide(:head_title, t("search.index.head_title")) %>
|
|
<%= render partial: "protocols/index/protocol_preview_modal" %>
|
|
<div class="content-pane">
|
|
<div class="page-header">
|
|
<h1><%= t('search.index.results_title_html', query: @display_query) %></h1>
|
|
<br>
|
|
<!-- search form -->
|
|
<div class="row">
|
|
<div class="col-xs-12 col-sm-8 col-md-6">
|
|
<%= form_tag search_path,
|
|
method: :get,
|
|
role: 'search' do %>
|
|
<div class="form-group">
|
|
<div class="input-group">
|
|
<input class="form-control min-h-[2.5rem]"
|
|
type="text"
|
|
name="q"
|
|
placeholder="<%= t('nav.search') %>"
|
|
value="<%= @display_query %>">
|
|
<span class="input-group-btn">
|
|
<button class="btn btn-secondary" type="submit">
|
|
<span class="sn-icon sn-icon-search"></span>
|
|
</button>
|
|
</span>
|
|
</div>
|
|
<label class="checkbox-inline">
|
|
<input id="search_whole_word" type="checkbox" name="whole_word" value="true" <%= 'checked' if @search_whole_word %>><%= I18n.t('search.whole_word') %>
|
|
</label>
|
|
<label class="checkbox-inline">
|
|
<input id="search_whole_phrase" type="checkbox" name="whole_phrase" value="true" <%= 'checked' if @search_whole_phrase %>><%= I18n.t('search.whole_phrase') %>
|
|
</label>
|
|
<label class="checkbox-inline">
|
|
<input id="search_match_case" type="checkbox" name="match_case" value="true" <%= 'checked' if @search_case %>><%= I18n.t('search.match_case') %>
|
|
</label>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<%= form_tag search_path, method: :get do %>
|
|
<%= hidden_field_tag :q, @search_query %>
|
|
<%= hidden_field_tag :category, @search_category %>
|
|
|
|
<div class="row">
|
|
<div class="col-xs-12 col-sm-3 col-md-3" id="search-menu">
|
|
<ul class="nav nav-pills nav-stacked nav-stacked-arrow nav-search">
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :projects %>
|
|
<%= "disabled" if @project_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'projects', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @project_search_count %></span>
|
|
<span class="sn-icon sn-icon-projects"></span>
|
|
<%= t'Projects' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :project_folders %>
|
|
<%= "disabled" if @project_folder_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= { category: 'project_folders', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id }.to_query %>">
|
|
<span class="badge pull-right"><%= @project_folder_search_count %></span>
|
|
<span class="sn-icon sn-icon-folder"></span>
|
|
<%= t('ProjectFolders') %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :experiments %>
|
|
<%= "disabled" if @experiment_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'experiments', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @experiment_search_count %></span>
|
|
<i class="sn-icon sn-icon-experiment"></i>
|
|
<%= t'Experiments' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :modules %>
|
|
<%= "disabled" if @module_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'modules', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @module_search_count %></span>
|
|
<span class="sn-icon sn-icon-task"></span>
|
|
<%= t'Modules' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :results %>
|
|
<%= "disabled" if @result_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'results', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @result_search_count %></span>
|
|
<span class="sn-icon sn-icon sn-icon-reports"></span>
|
|
<%= t'Results' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :tags %>
|
|
<%= "disabled" if @tag_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'tags', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @tag_search_count %></span>
|
|
<span class="sn-icon sn-icon-tag"></span>
|
|
<%= t'Tags' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :reports %>
|
|
<%= "disabled" if @report_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'reports', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @report_search_count %></span>
|
|
<span class="sn-icon sn-icon-reports"></span>
|
|
<%= t'Reports' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :protocols %>
|
|
<%= "disabled" if @protocol_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'protocols', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @protocol_search_count %></span>
|
|
<span class="sn-icon sn-icon-protocols-templates"></span>
|
|
<%= t'Protocols' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :steps %>
|
|
<%= "disabled" if @step_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'steps', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @step_search_count %></span>
|
|
<span class="sn-icon sn-icon-steps"></span>
|
|
<%= t'Steps' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :checklists %>
|
|
<%= "disabled" if @checklist_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'checklists', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @checklist_search_count %></span>
|
|
<span class="sn-icon sn-icon-checkllist"></span>
|
|
<%= t'Checklists' %>
|
|
</a>
|
|
</li>
|
|
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :assets %>
|
|
<%= "disabled" if @asset_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'assets', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @asset_search_count %></span>
|
|
<span class="sn-icon sn-icon-files"></span>
|
|
<%= t'Assets' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :tables %>
|
|
<%= "disabled" if @table_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'tables', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @table_search_count %></span>
|
|
<span class="sn-icon sn-icon-tables"></span>
|
|
<%= t'Tables' %>
|
|
</a>
|
|
</li>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category.present? and @search_category == :comments %>
|
|
<%= "disabled" if @comment_search_count == 0 %>"
|
|
>
|
|
<a href="?<%= {category: 'comments', q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= @comment_search_count %></span>
|
|
<span class="sn-icon sn-icon-comments"></span>
|
|
<%= t'Comments' %>
|
|
</a>
|
|
</li>
|
|
|
|
<% @repository_search_count.each do |team, results| %>
|
|
<li class="repositories-team <%= 'active' if results[:count].positive? %>">
|
|
<i class="sn-icon sn-icon-inventory"></i>
|
|
<%= t('Repositories_team', team: team) %>
|
|
</li>
|
|
<% results[:repositories].each do |repository, values| %>
|
|
<li role="presentation"
|
|
class="
|
|
<%= "active" if @search_category == :repositories && @repository.id == values[:id] %>
|
|
<%= "disabled" if values[:count] == 0 %> repository-search"
|
|
>
|
|
<a href="?<%= {category: 'repositories',
|
|
repository: values[:id], q: @search_query,
|
|
whole_word: @search_whole_word, whole_phrase: @search_whole_phrase,
|
|
match_case: @search_case, utf8: '✓',
|
|
search_id: @search_id}.to_query %>">
|
|
<span class="badge pull-right"><%= values[:count] %></span>
|
|
<%= repository %>
|
|
<%= inventory_shared_status_icon(values[:repository], results[:team]) %>
|
|
</a>
|
|
</li>
|
|
<% end %>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
|
|
<% if not @search_category.blank? %>
|
|
<div class="col-xs-12 col-sm-9" id="search-content">
|
|
|
|
<div class="container-fluid" id="search-container">
|
|
<% if @search_results_count == 0 %>
|
|
<p><%= t'search.index.error.no_results', q: @search_query %></p>
|
|
<% end %>
|
|
|
|
<hr class="visible-xs">
|
|
|
|
<% if @search_category == :projects and @project_search_count.positive? %>
|
|
<%= render 'search/results/projects', search_query: @search_query, results: @project_results %>
|
|
<% end %>
|
|
<% if @search_category == :project_folders and @project_folder_search_count.positive? %>
|
|
<%= render 'search/results/project_folders', search_query: @search_query, results: @project_folder_results %>
|
|
<% end %>
|
|
<% if @search_category == :experiments and @experiment_search_count.positive? %>
|
|
<%= render 'search/results/experiments', search_query: @search_query, results: @experiment_results %>
|
|
<% end %>
|
|
<% if @search_category == :modules and @module_search_count.positive? %>
|
|
<%= render 'search/results/modules', search_query: @search_query, results: @module_results %>
|
|
<% end %>
|
|
<% if @search_category == :results and @result_search_count.positive? %>
|
|
<%= render 'search/results/results', search_query: @search_query, results: @result_results %>
|
|
<% end %>
|
|
<% if @search_category == :tags and @tag_search_count.positive? %>
|
|
<%= render 'search/results/tags', search_query: @search_query, results: @tag_results %>
|
|
<% end %>
|
|
<% if @search_category == :reports and @report_search_count.positive? %>
|
|
<%= render 'search/results/reports', search_query: @search_query, results: @report_results %>
|
|
<% end %>
|
|
<% if @search_category == :protocols and @protocol_search_count.positive? %>
|
|
<%= render 'search/results/protocols', search_query: @search_query, results: @protocol_results %>
|
|
<% end %>
|
|
<% if @search_category == :steps and @step_search_count.positive? %>
|
|
<%= render 'search/results/steps', search_query: @search_query, results: @step_results %>
|
|
<% end %>
|
|
<% if @search_category == :checklists and @checklist_search_count.positive? %>
|
|
<%= render 'search/results/checklists', search_query: @search_query, results: @checklist_results %>
|
|
<% end %>
|
|
<% if @search_category == :repositories and @repository_search_count_total.positive? %>
|
|
<%= render 'search/results/repositories', search_query: @search_query, results: @repository_results, repository: @repository %>
|
|
<% end %>
|
|
<% if @search_category == :assets and @asset_search_count.positive? %>
|
|
<%= render 'search/results/assets', search_query: @search_query, results: @asset_results %>
|
|
<% end %>
|
|
<% if @search_category == :tables and @table_search_count.positive? %>
|
|
<%= render 'search/results/tables', search_query: @search_query, results: @table_results %>
|
|
<% end %>
|
|
<% if @search_category == :comments and @comment_search_count.positive? %>
|
|
<%= render 'search/results/comments', search_query: @search_query, results: @comment_results %>
|
|
<% end %>
|
|
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<% if @search_pages > 1 %>
|
|
<% params = { q: @search_query,
|
|
category: @search_category,
|
|
utf8: '✓',
|
|
search_id: @search_id } %>
|
|
<% if @search_category == :repositories %>
|
|
<% params[:repository] = @repository.id %>
|
|
<% end %>
|
|
<nav class="text-center">
|
|
<ul class="pagination">
|
|
<% if @search_page > 1 %>
|
|
<% params[:page] = @search_page - 1 %>
|
|
<li>
|
|
<a href="?<%= params.to_query %>" aria-label="Previous">
|
|
<span aria-hidden="true">«</span>
|
|
</a>
|
|
</li>
|
|
<% end %>
|
|
<% (@start_page..@end_page).each do |page_i| %>
|
|
<% params[:page] = page_i %>
|
|
<li <% if @search_page == page_i %>class="active"<% end %>>
|
|
<a href="?<%= params.to_query %>"><%= page_i %></a>
|
|
</li>
|
|
<% end %>
|
|
<% if @search_page < @search_pages %>
|
|
<% params[:page] = @search_page + 1 %>
|
|
<li>
|
|
<a href="?<%= params.to_query %>" aria-label="Next">
|
|
<span aria-hidden="true">»</span>
|
|
</a>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
</nav>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= javascript_include_tag('search') %>
|