mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2026-01-07 00:36:08 +08:00
Add experiment to search results
This commit is contained in:
parent
6d26203796
commit
3be562bdf6
4 changed files with 54 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ class SearchController < ApplicationController
|
|||
count_search_results
|
||||
|
||||
search_projects if @search_category == :projects
|
||||
search_experiments if @search_category == :experiments
|
||||
search_workflows if @search_category == :workflows
|
||||
search_modules if @search_category == :modules
|
||||
search_results if @search_category == :results
|
||||
|
|
@ -63,7 +64,8 @@ class SearchController < ApplicationController
|
|||
@search_page = 1
|
||||
end
|
||||
end
|
||||
# Initialize markdown parser
|
||||
|
||||
# Initialize markdown parser
|
||||
def load_markdown
|
||||
if @search_category == :results
|
||||
@markdown = Redcarpet::Markdown.new(
|
||||
|
|
@ -87,6 +89,7 @@ class SearchController < ApplicationController
|
|||
|
||||
def count_search_results
|
||||
@project_search_count = count_by_name Project
|
||||
@experiment_search_count = count_by_name Experiment
|
||||
@workflow_search_count = count_by_name MyModuleGroup
|
||||
@module_search_count = count_by_name MyModule
|
||||
@result_search_count = count_by_name Result
|
||||
|
|
@ -101,6 +104,7 @@ class SearchController < ApplicationController
|
|||
@comment_search_count = count_by_name Comment
|
||||
|
||||
@search_results_count = @project_search_count
|
||||
@search_results_count += @experiment_search_count
|
||||
@search_results_count += @workflow_search_count
|
||||
@search_results_count += @module_search_count
|
||||
@search_results_count += @result_search_count
|
||||
|
|
@ -123,6 +127,14 @@ class SearchController < ApplicationController
|
|||
@search_count = @project_search_count
|
||||
end
|
||||
|
||||
def search_experiments
|
||||
@experiment_results = []
|
||||
if @experiment_search_count > 0 then
|
||||
@experiment_results = search_by_name Experiment
|
||||
end
|
||||
@search_count = @experiment_search_count
|
||||
end
|
||||
|
||||
def search_workflows
|
||||
@workflow_results = []
|
||||
if @workflow_search_count > 0 then
|
||||
|
|
|
|||
|
|
@ -20,6 +20,17 @@
|
|||
<%= t'Projects' %>
|
||||
</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, utf8: '✓'}.to_query %>">
|
||||
<span class="badge pull-right"><%= @experiment_search_count %></span>
|
||||
<span class="glyphicon glyphicon-filter"></span>
|
||||
<%= t'Experiments' %>
|
||||
</a>
|
||||
</li>
|
||||
<li role="presentation"
|
||||
class="
|
||||
<%= "active" if @search_category.present? and @search_category == :workflows %>
|
||||
|
|
@ -168,6 +179,9 @@
|
|||
<% if @search_category == :projects and @project_search_count > 0 %>
|
||||
<%= render 'search/results/projects', search_query: @search_query, results: @project_results %>
|
||||
<% end %>
|
||||
<% if @search_category == :experiments and @experiment_search_count > 0 %>
|
||||
<%= render 'search/results/experiments', search_query: @search_query, results: @experiment_results %>
|
||||
<% end %>
|
||||
<% if @search_category == :workflows and @workflow_search_count > 0 %>
|
||||
<%= render 'search/results/workflows', search_query: @search_query, results: @workflow_results %>
|
||||
<% end %>
|
||||
|
|
|
|||
26
app/views/search/results/_experiments.html.erb
Normal file
26
app/views/search/results/_experiments.html.erb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<% results.each do |experiment| %>
|
||||
<h5>
|
||||
<span class="glyphicon glyphicon-filter"></span>
|
||||
<%= highlight experiment.name, search_query.strip.split(/\s+/) %>
|
||||
</h5>
|
||||
|
||||
<p>
|
||||
<span>
|
||||
<%=t "search.index.created_at" %>
|
||||
<%=l experiment.created_at, format: :full %>
|
||||
</span>
|
||||
<br>
|
||||
<span>
|
||||
<%=t "search.index.project" %>
|
||||
<%= render partial: "search/results/partials/project_text.html.erb",
|
||||
locals: { project: experiment.project, link_to_page: :canvas } %>
|
||||
</span>
|
||||
<br>
|
||||
<span>
|
||||
<%=t "search.index.organization" %>
|
||||
<%= render partial: "search/results/partials/organization_text.html.erb", locals: { organization: experiment.project.organization } %>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
<% end %>
|
||||
|
|
@ -1410,6 +1410,7 @@ en:
|
|||
Modules: "Tasks"
|
||||
Project: "Project"
|
||||
Projects: "Projects"
|
||||
Experiments: "Experiments"
|
||||
Result: "Result"
|
||||
Results: "Results"
|
||||
Protocol: "Protocol"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue