mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
Merge pull request #3398 from artoscinote/ma_SCI_5828
Expose experiment IDs in interface and reports [SCI-5828]
This commit is contained in:
commit
723b594632
13 changed files with 121 additions and 24 deletions
|
@ -47,11 +47,14 @@
|
|||
|
||||
.cards-wrapper {
|
||||
--card-min-width: 350px;
|
||||
--list-columns-number: 7;
|
||||
--list-columns-number: 8;
|
||||
|
||||
.card {
|
||||
grid-row: span 6;
|
||||
grid-row: span 7;
|
||||
|
||||
.experiment-code-cell {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&.experiment-card {
|
||||
border-radius: 4px;
|
||||
|
@ -174,7 +177,7 @@
|
|||
|
||||
&.list {
|
||||
grid-auto-rows: 1px 5em;
|
||||
grid-template-columns: max-content repeat(calc(var(--list-columns-number) - 2), minmax(100px, auto)) max-content;
|
||||
grid-template-columns: max-content minmax(100px, auto) minmax(80px, max-content) repeat(calc(var(--list-columns-number) - 4), minmax(100px, auto)) max-content;
|
||||
grid-template-rows: 3em;
|
||||
|
||||
.card {
|
||||
|
@ -230,20 +233,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
.start-date-cell {
|
||||
.experiment-code-cell {
|
||||
display: block;
|
||||
grid-column: 3;
|
||||
}
|
||||
|
||||
.modified-date-cell {
|
||||
.start-date-cell {
|
||||
grid-column: 4;
|
||||
}
|
||||
|
||||
.completed-task-cell {
|
||||
.modified-date-cell {
|
||||
grid-column: 5;
|
||||
}
|
||||
|
||||
.description-cell {
|
||||
.completed-task-cell {
|
||||
grid-column: 6;
|
||||
}
|
||||
|
||||
.description-cell {
|
||||
grid-column: 7;
|
||||
position: relative;
|
||||
|
||||
.description-text {
|
||||
|
@ -262,7 +270,7 @@
|
|||
}
|
||||
|
||||
.actions-cell {
|
||||
grid-column: 7;
|
||||
grid-column: 8;
|
||||
padding-top: 3px;
|
||||
position: initial;
|
||||
}
|
||||
|
|
|
@ -40,17 +40,30 @@
|
|||
}
|
||||
|
||||
.dropdown-menu {
|
||||
.form-dropdown-break hr {
|
||||
margin-bottom: 8px;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.form-dropdown-item {
|
||||
padding: 0 !important;
|
||||
|
||||
button {
|
||||
button,
|
||||
.form-dropdown-item-info {
|
||||
border-radius: 0;
|
||||
color: $color-black !important;
|
||||
padding-left: .9em;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
button {
|
||||
color: $color-black !important;
|
||||
}
|
||||
|
||||
.form-dropdown-item-info {
|
||||
color: $color-silver-chalice !important;
|
||||
}
|
||||
|
||||
.project-archive-restore-form {
|
||||
.button-to {
|
||||
&:hover {
|
||||
|
|
|
@ -43,6 +43,8 @@ module SearchableModel
|
|||
(attrs.map.with_index do |a, i|
|
||||
if %w(repository_rows.id repository_number_values.data).include?(a)
|
||||
"((#{a})::text) #{like} :t#{i} OR "
|
||||
elsif a == Experiment::EXPERIMENT_CODE_SQL
|
||||
"#{Experiment::EXPERIMENT_CODE_SQL} #{like} :t#{i} OR "
|
||||
else
|
||||
col = options[:at_search].to_s == 'true' ? "lower(#{a})": a
|
||||
"(trim_html_tags(#{col})) #{like} :t#{i} OR "
|
||||
|
@ -67,6 +69,8 @@ module SearchableModel
|
|||
(attrs.map.with_index do |a, i|
|
||||
if %w(repository_rows.id repository_number_values.data).include?(a)
|
||||
"((#{a})::text) #{like} ANY (array[:t#{i}]) OR "
|
||||
elsif a == Experiment::EXPERIMENT_CODE_SQL
|
||||
"#{Experiment::EXPERIMENT_CODE_SQL} #{like} ANY (array[:t#{i}]) OR "
|
||||
else
|
||||
"(trim_html_tags(#{a})) #{like} ANY (array[:t#{i}]) OR "
|
||||
end
|
||||
|
@ -86,6 +90,8 @@ module SearchableModel
|
|||
(attrs.map.with_index do |a, i|
|
||||
if %w(repository_rows.id repository_number_values.data).include?(a)
|
||||
"((#{a})::text) #{like} :t#{i} OR "
|
||||
elsif a == Experiment::EXPERIMENT_CODE_SQL
|
||||
"#{Experiment::EXPERIMENT_CODE_SQL} #{like} :t#{i} OR "
|
||||
else
|
||||
"(trim_html_tags(#{a})) #{like} :t#{i} OR "
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ class Experiment < ApplicationRecord
|
|||
include SearchableModel
|
||||
include SearchableByNameModel
|
||||
|
||||
EXPERIMENT_CODE_SQL = "('EX' || id)".freeze
|
||||
|
||||
before_save -> { report_elements.destroy_all }, if: -> { !new_record? && project_id_changed? }
|
||||
|
||||
belongs_to :project, inverse_of: :experiments, touch: true
|
||||
|
@ -70,19 +72,25 @@ class Experiment < ApplicationRecord
|
|||
new_query =
|
||||
Experiment
|
||||
.where('experiments.project_id IN (?)', projects_ids)
|
||||
.where_attributes_like([:name, :description], query, options)
|
||||
.where_attributes_like(
|
||||
[:name, :description, EXPERIMENT_CODE_SQL], query, options
|
||||
)
|
||||
return include_archived ? new_query : new_query.active
|
||||
elsif include_archived
|
||||
new_query =
|
||||
Experiment
|
||||
.where(project: project_ids)
|
||||
.where_attributes_like([:name, :description], query, options)
|
||||
.where_attributes_like(
|
||||
[:name, :description, EXPERIMENT_CODE_SQL], query, options
|
||||
)
|
||||
else
|
||||
new_query =
|
||||
Experiment
|
||||
.active
|
||||
.where(project: project_ids)
|
||||
.where_attributes_like([:name, :description], query, options)
|
||||
.where_attributes_like(
|
||||
[:name, :description, EXPERIMENT_CODE_SQL], query, options
|
||||
)
|
||||
end
|
||||
|
||||
# Show all results if needed
|
||||
|
@ -99,6 +107,10 @@ class Experiment < ApplicationRecord
|
|||
where(project: Project.viewable_by_user(user, teams))
|
||||
end
|
||||
|
||||
def code
|
||||
"EX#{id}"
|
||||
end
|
||||
|
||||
def archived_branch?
|
||||
archived? || project.archived?
|
||||
end
|
||||
|
|
|
@ -49,7 +49,10 @@ class ExperimentsOverviewService
|
|||
records = records.archived if @view_mode == 'archived' && @project.active?
|
||||
records = records.active if @view_mode == 'active'
|
||||
if @params[:search].present?
|
||||
records = records.where_attributes_like(%w(experiments.name experiments.description), @params[:search])
|
||||
records = records.where_attributes_like(
|
||||
['experiments.name', 'experiments.description', "('EX' || experiments.id)"],
|
||||
@params[:search]
|
||||
)
|
||||
end
|
||||
if @params[:created_on_from].present?
|
||||
records = records.where('experiments.created_at > ?', @params[:created_on_from])
|
||||
|
|
|
@ -11,7 +11,7 @@ module Reports::Docx::DrawExperiment
|
|||
@docx.h2 experiment.name, size: Constants::REPORT_DOCX_EXPERIMENT_TITLE_SIZE
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.elements.experiment.user_time',
|
||||
timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
|
||||
code: experiment.code, timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
|
||||
if experiment.archived?
|
||||
text ' | '
|
||||
text I18n.t('search.index.archived'), color: color[:gray]
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="table-header-cell"><%= t('experiments.card.name') %></div>
|
||||
<div class="table-header-cell"><%= t('experiments.id') %></div>
|
||||
<div class="table-header-cell"><%= t('experiments.card.start_date') %></div>
|
||||
<div class="table-header-cell"><%= t('experiments.card.modified_date') %></div>
|
||||
<div class="table-header-cell" data-view-mode="archived"><%= t('experiments.card.archived_date') %></div>
|
||||
|
|
|
@ -63,6 +63,14 @@
|
|||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="form-dropdown-break">
|
||||
<hr>
|
||||
</li>
|
||||
<li class="form-dropdown-item">
|
||||
<div class="form-dropdown-item-info">
|
||||
<span><%= "#{t('experiments.experiment_id')}: #{experiment.code}" %></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -25,11 +25,14 @@
|
|||
<%= link_to experiment.name, canvas_experiment_path(experiment), title: experiment.name, class: 'name-link' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="actions actions-cell table-cell">
|
||||
<% if can_manage_experiments?(experiment.project) %>
|
||||
<%= render partial: 'projects/show/experiment_actions_dropdown.html.erb', locals: { experiment: experiment } %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="experiment-code-cell table-cell">
|
||||
<span><%= experiment.code %></span>
|
||||
</div>
|
||||
<div class="actions actions-cell table-cell">
|
||||
<% if can_manage_experiments?(experiment.project) %>
|
||||
<%= render partial: 'projects/show/experiment_actions_dropdown.html.erb', locals: { experiment: experiment } %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="dates-and-img-container">
|
||||
<div class="dates-container">
|
||||
<div class="data-row start-date-cell table-cell">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="report-element-header">
|
||||
<div class="row">
|
||||
<div class="pull-left user-time">
|
||||
<%= t('projects.reports.elements.experiment.user_time', timestamp: l(timestamp, format: :full)) %>
|
||||
<%= t('projects.reports.elements.experiment.user_time', code: experiment.code, timestamp: l(timestamp, format: :full)) %>
|
||||
<b><%= link_to t('projects.reports.elements.all.scinote_link'),canvas_experiment_url(experiment), target: :_blank %></b>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -677,7 +677,7 @@ en:
|
|||
protocol:
|
||||
user_time: "Protocol created on %{timestamp}."
|
||||
experiment:
|
||||
user_time: "Experiment created on %{timestamp}."
|
||||
user_time: "Experiment %{code} created on %{timestamp}."
|
||||
no_description: "No description"
|
||||
no_tags: "No tags"
|
||||
module_activity:
|
||||
|
@ -1001,6 +1001,8 @@ en:
|
|||
body_html: This inventory has been unshared with your team by the inventory’s owner. To view the item/s that are assigned to your task/s contact the <b>%{team_name}</b> team administrator <b>%{admin_name}</b> (<b>%{admin_email}</b>).
|
||||
open_mobile_app: "Open mobile app"
|
||||
experiments:
|
||||
id: "ID"
|
||||
experiment_id: "Experiment ID"
|
||||
header:
|
||||
cards: "Cards"
|
||||
table: "Table"
|
||||
|
|
26
db/migrate/20210622101238_fix_experiment_indices.rb
Normal file
26
db/migrate/20210622101238_fix_experiment_indices.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path('app/helpers/database_helper')
|
||||
|
||||
class FixExperimentIndices < ActiveRecord::Migration[6.1]
|
||||
include DatabaseHelper
|
||||
|
||||
def up
|
||||
remove_index :experiments, name: 'index_experiments_on_name', column: 'name'
|
||||
|
||||
add_gin_index_without_tags(:experiments, :name)
|
||||
add_gin_index_without_tags(:experiments, :description)
|
||||
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"CREATE INDEX index_experiments_on_experiment_code ON experiments using gin (('EX'::text || id) gin_trgm_ops);"
|
||||
)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :experiments, name: 'index_experiments_on_experiment_code'
|
||||
remove_index :experiments, name: 'index_experiments_on_description'
|
||||
remove_index :experiments, name: 'index_experiments_on_name'
|
||||
|
||||
add_index :experiments, :name
|
||||
end
|
||||
end
|
|
@ -4349,6 +4349,20 @@ CREATE INDEX index_experiments_on_archived_by_id ON public.experiments USING btr
|
|||
CREATE INDEX index_experiments_on_created_by_id ON public.experiments USING btree (created_by_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_experiments_on_description; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_experiments_on_description ON public.experiments USING gin (public.trim_html_tags(description) public.gin_trgm_ops);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_experiments_on_experiment_code; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_experiments_on_experiment_code ON public.experiments USING gin ((('EX'::text || id)) public.gin_trgm_ops);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_experiments_on_last_modified_by_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -4360,7 +4374,7 @@ CREATE INDEX index_experiments_on_last_modified_by_id ON public.experiments USIN
|
|||
-- Name: index_experiments_on_name; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_experiments_on_name ON public.experiments USING btree (name);
|
||||
CREATE INDEX index_experiments_on_name ON public.experiments USING gin (public.trim_html_tags((name)::text) public.gin_trgm_ops);
|
||||
|
||||
|
||||
--
|
||||
|
@ -7235,6 +7249,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20210325152257'),
|
||||
('20210407143303'),
|
||||
('20210410100006'),
|
||||
('20210506125657');
|
||||
('20210506125657'),
|
||||
('20210622101238');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue