2016-02-12 23:52:43 +08:00
|
|
|
<% provide(:head_title, t("search.index.head_title")) %>
|
2019-07-02 17:21:00 +08:00
|
|
|
<%= render partial: "protocols/index/protocol_preview_modal.html.erb" %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<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"
|
|
|
|
type="text"
|
|
|
|
name="q"
|
|
|
|
placeholder="<%= t('nav.search') %>"
|
|
|
|
value="<%= @display_query %>">
|
|
|
|
<span class="input-group-btn">
|
|
|
|
<button class="btn btn-default" type="submit">
|
2018-07-09 19:13:44 +08:00
|
|
|
<span class="fas fa-search"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
</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>
|
2017-05-05 22:41:23 +08:00
|
|
|
</div>
|
2018-05-08 22:33:42 +08:00
|
|
|
<% end %>
|
|
|
|
</div>
|
2017-05-05 22:41:23 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= form_tag search_path, method: :get do %>
|
|
|
|
<%= hidden_field_tag :q, @search_query %>
|
|
|
|
<%= hidden_field_tag :category, @search_category %>
|
2017-06-23 22:06:11 +08:00
|
|
|
|
2018-05-08 22:33:42 +08:00
|
|
|
<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>
|
2018-05-22 22:55:58 +08:00
|
|
|
<span class="fas fa-folder"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= t'Projects' %>
|
|
|
|
</a>
|
|
|
|
</li>
|
2020-11-10 22:04:35 +08:00
|
|
|
<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="fas fa-folder"></span>
|
|
|
|
<%= t('ProjectFolders') %>
|
|
|
|
</a>
|
|
|
|
</li>
|
2018-05-08 22:33:42 +08:00
|
|
|
<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="fas fa-flask"></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>
|
2018-07-09 19:13:44 +08:00
|
|
|
<span class="fas fa-credit-card"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= 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>
|
2018-07-09 19:13:44 +08:00
|
|
|
<span class="fas fa-columns"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= 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>
|
2018-05-22 22:55:58 +08:00
|
|
|
<span class="fas fa-tags"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= 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>
|
2018-05-22 22:55:58 +08:00
|
|
|
<span class="fas fa-clipboard-check"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= 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>
|
2018-05-22 22:55:58 +08:00
|
|
|
<span class="fas fa-edit"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= 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>
|
2018-07-09 19:13:44 +08:00
|
|
|
<span class="fas fa-arrow-circle-right"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= 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>
|
2018-05-22 22:55:58 +08:00
|
|
|
<span class="fas fa-tasks"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= t'Checklists' %>
|
|
|
|
</a>
|
|
|
|
</li>
|
2017-06-27 19:23:51 +08:00
|
|
|
|
2018-05-08 22:33:42 +08:00
|
|
|
<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>
|
2018-08-14 19:26:48 +08:00
|
|
|
<span class="fas fa-paperclip"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= t'Assets' %>
|
|
|
|
</a>
|
2017-06-27 19:23:51 +08:00
|
|
|
</li>
|
2018-05-08 22:33:42 +08:00
|
|
|
<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>
|
2018-05-22 22:55:58 +08:00
|
|
|
<span class="fas fa-table"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= 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>
|
2018-05-22 22:55:58 +08:00
|
|
|
<span class="fas fa-comment"></span>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= t'Comments' %>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<% @repository_search_count.each do |team, results| %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<li class="repositories-team <%= 'active' if results[:count].positive? %>">
|
2018-05-22 22:55:58 +08:00
|
|
|
<i class="fas fa-list-alt"></i>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= t('Repositories_team', team: team) %>
|
2017-06-27 19:23:51 +08:00
|
|
|
</li>
|
2018-05-08 22:33:42 +08:00
|
|
|
<% 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 %>
|
2019-09-10 17:20:18 +08:00
|
|
|
<%= inventory_shared_status_icon(values[:repository], results[:team]) %>
|
2018-05-08 22:33:42 +08:00
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<% end %>
|
2017-06-27 19:23:51 +08:00
|
|
|
<% end %>
|
2018-05-08 22:33:42 +08:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
2021-07-23 17:56:28 +08:00
|
|
|
<% if not @search_category.blank? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<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>
|
2017-06-27 19:23:51 +08:00
|
|
|
<% end %>
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2018-05-08 22:33:42 +08:00
|
|
|
<hr class="visible-xs">
|
2016-07-21 19:11:15 +08:00
|
|
|
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :projects and @project_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/projects', search_query: @search_query, results: @project_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% 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? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/experiments', search_query: @search_query, results: @experiment_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :modules and @module_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/modules', search_query: @search_query, results: @module_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :results and @result_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/results', search_query: @search_query, results: @result_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :tags and @tag_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/tags', search_query: @search_query, results: @tag_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :reports and @report_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/reports', search_query: @search_query, results: @report_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :protocols and @protocol_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/protocols', search_query: @search_query, results: @protocol_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :steps and @step_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/steps', search_query: @search_query, results: @step_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :checklists and @checklist_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/checklists', search_query: @search_query, results: @checklist_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :repositories and @repository_search_count_total.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/repositories', search_query: @search_query, results: @repository_results, repository: @repository %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :assets and @asset_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/assets', search_query: @search_query, results: @asset_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :tables and @table_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/tables', search_query: @search_query, results: @table_results %>
|
|
|
|
<% end %>
|
2020-11-10 22:04:35 +08:00
|
|
|
<% if @search_category == :comments and @comment_search_count.positive? %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<%= render 'search/results/comments', search_query: @search_query, results: @comment_results %>
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-02-12 23:52:43 +08:00
|
|
|
<% end %>
|
2018-05-08 22:33:42 +08:00
|
|
|
</div>
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2018-05-08 22:33:42 +08:00
|
|
|
<% end %>
|
2016-02-12 23:52:43 +08:00
|
|
|
|
2018-05-08 22:33:42 +08:00
|
|
|
<% if @search_pages > 1 %>
|
2018-05-15 23:48:48 +08:00
|
|
|
<% params = { q: @search_query,
|
|
|
|
category: @search_category,
|
|
|
|
utf8: '✓',
|
|
|
|
search_id: @search_id } %>
|
|
|
|
<% if @search_category == :repositories %>
|
|
|
|
<% params[:repository] = @repository.id %>
|
|
|
|
<% end %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<nav class="text-center">
|
|
|
|
<ul class="pagination">
|
|
|
|
<% if @search_page > 1 %>
|
2018-05-15 23:48:48 +08:00
|
|
|
<% params[:page] = @search_page - 1 %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<li>
|
2018-05-15 23:48:48 +08:00
|
|
|
<a href="?<%= params.to_query %>" aria-label="Previous">
|
2018-05-08 22:33:42 +08:00
|
|
|
<span aria-hidden="true">«</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
2016-07-21 19:11:15 +08:00
|
|
|
<% end %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<% (@start_page..@end_page).each do |page_i| %>
|
2018-05-15 23:48:48 +08:00
|
|
|
<% params[:page] = page_i %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<li <% if @search_page == page_i %>class="active"<% end %>>
|
2018-05-15 23:48:48 +08:00
|
|
|
<a href="?<%= params.to_query %>"><%= page_i %></a>
|
2018-05-08 22:33:42 +08:00
|
|
|
</li>
|
2016-02-12 23:52:43 +08:00
|
|
|
<% end %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<% if @search_page < @search_pages %>
|
2018-05-15 23:48:48 +08:00
|
|
|
<% params[:page] = @search_page + 1 %>
|
2018-05-08 22:33:42 +08:00
|
|
|
<li>
|
2018-05-15 23:48:48 +08:00
|
|
|
<a href="?<%= params.to_query %>" aria-label="Next">
|
2018-05-08 22:33:42 +08:00
|
|
|
<span aria-hidden="true">»</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
2016-02-12 23:52:43 +08:00
|
|
|
<% end %>
|
2018-05-08 22:33:42 +08:00
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2017-05-05 22:41:23 +08:00
|
|
|
|
|
|
|
<%= javascript_include_tag('search') %>
|