mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-09 14:46:47 +08:00
Added possibility to add uncompleted steps to report. [closes SCI-414]
This commit is contained in:
parent
2c6f888cbc
commit
f78c80b148
5 changed files with 58 additions and 32 deletions
|
@ -70,17 +70,20 @@ module ReportActions
|
||||||
def generate_module_contents_json(my_module)
|
def generate_module_contents_json(my_module)
|
||||||
res = []
|
res = []
|
||||||
ReportExtends::MODULE_CONTENTS.each do |contents|
|
ReportExtends::MODULE_CONTENTS.each do |contents|
|
||||||
protocol = contents.element == :steps ? my_module.protocol.present? : true
|
present = false
|
||||||
next unless (in_params?("module_#{contents.element}".to_sym) ||
|
contents.values.each do |element|
|
||||||
in_params?('#{contents.element}'.to_sym)) && protocol
|
present = in_params?("module_#{element}".to_sym) ||
|
||||||
|
in_params?(element.to_sym)
|
||||||
|
break if present
|
||||||
|
end
|
||||||
|
next unless present
|
||||||
|
|
||||||
if contents.children
|
if contents.children
|
||||||
contents.collection(my_module).each do |report_el|
|
contents.collection(my_module, params).each do |report_el|
|
||||||
res << generate_new_el(false)
|
res << generate_new_el(false)
|
||||||
el = generate_el(
|
el = generate_el(
|
||||||
"reports/elements/my_module_#{contents
|
"reports/elements/my_module_#{contents.element.to_s.singularize}"\
|
||||||
.element
|
"_element.html.erb",
|
||||||
.to_s
|
|
||||||
.singularize}_element.html.erb",
|
|
||||||
contents.parse_locals([report_el])
|
contents.parse_locals([report_el])
|
||||||
)
|
)
|
||||||
if :step.in? contents.locals
|
if :step.in? contents.locals
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<% if step.blank? and @step.present? then step = @step end %>
|
<% if step.blank? and @step.present? then step = @step end %>
|
||||||
<% timestamp = step.completed_on %>
|
<% step_type_str = step.completed ? 'completed' : 'uncompleted' %>
|
||||||
|
<% user = step.completed || !step.changed? ? step.user : step.last_modified_by %>
|
||||||
|
<% timestamp = step.completed ? step.completed_on : step.updated_at %>
|
||||||
<% tables = step.tables %>
|
<% tables = step.tables %>
|
||||||
<% assets = step.assets %>
|
<% assets = step.assets %>
|
||||||
<% checklists = step.checklists %>
|
<% checklists = step.checklists %>
|
||||||
|
@ -8,7 +10,7 @@
|
||||||
<div class="report-element-header">
|
<div class="report-element-header">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="pull-left user-time">
|
<div class="pull-left user-time">
|
||||||
<%=t "projects.reports.elements.step.user_time", user: step.user.full_name , timestamp: l(timestamp, format: :full) %>
|
<%=t "projects.reports.elements.step.#{step_type_str}.user_time", user: user.full_name , timestamp: l(timestamp, format: :full) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-right controls">
|
<div class="pull-right controls">
|
||||||
<%= render partial: "reports/elements/element_controls.html.erb", locals: { show_sort: true } %>
|
<%= render partial: "reports/elements/element_controls.html.erb", locals: { show_sort: true } %>
|
||||||
|
|
|
@ -15,6 +15,14 @@
|
||||||
<% if my_module_undefined or my_module.protocol.steps.exists? %>
|
<% if my_module_undefined or my_module.protocol.steps.exists? %>
|
||||||
<li>
|
<li>
|
||||||
<%= form.check_box :module_steps, label: t("projects.reports.elements.modals.module_contents_inner.steps") %>
|
<%= form.check_box :module_steps, label: t("projects.reports.elements.modals.module_contents_inner.steps") %>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<%= form.check_box :module_completed_steps, label: t("projects.reports.elements.modals.module_contents_inner.completed_steps") %>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<%= form.check_box :module_uncompleted_steps, label: t("projects.reports.elements.modals.module_contents_inner.uncompleted_steps") %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div>
|
<div>
|
||||||
|
@ -34,13 +42,11 @@
|
||||||
<%= form.check_box :module_result_assets, label: t("projects.reports.elements.modals.module_contents_inner.result_assets") %>
|
<%= form.check_box :module_result_assets, label: t("projects.reports.elements.modals.module_contents_inner.result_assets") %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_table && r.active? }).exists? %>
|
<% if my_module_undefined or (my_module.results.select { |r| r.is_table && r.active? }).exists? %>
|
||||||
<li>
|
<li>
|
||||||
<%= form.check_box :module_result_tables, label: t("projects.reports.elements.modals.module_contents_inner.result_tables") %>
|
<%= form.check_box :module_result_tables, label: t("projects.reports.elements.modals.module_contents_inner.result_tables") %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if my_module_undefined or (my_module.results.select { |r| r.is_text && r.active? }).exists? %>
|
<% if my_module_undefined or (my_module.results.select { |r| r.is_text && r.active? }).exists? %>
|
||||||
<li>
|
<li>
|
||||||
<%= form.check_box :module_result_texts, label: t("projects.reports.elements.modals.module_contents_inner.result_texts") %>
|
<%= form.check_box :module_result_texts, label: t("projects.reports.elements.modals.module_contents_inner.result_texts") %>
|
||||||
|
@ -60,7 +66,6 @@
|
||||||
<li>
|
<li>
|
||||||
<%= form.check_box :module_activity, label: t("projects.reports.elements.modals.module_contents_inner.activity") %>
|
<%= form.check_box :module_activity, label: t("projects.reports.elements.modals.module_contents_inner.activity") %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<%= form.check_box :module_samples, label: t("projects.reports.elements.modals.module_contents_inner.samples") %>
|
<%= form.check_box :module_samples, label: t("projects.reports.elements.modals.module_contents_inner.samples") %>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -11,25 +11,27 @@ module ReportExtends
|
||||||
# ModuleElement struct creates an argument objects which is needed in
|
# ModuleElement struct creates an argument objects which is needed in
|
||||||
# generate_module_contents_json method. It takes 3 parameters a Proc and
|
# generate_module_contents_json method. It takes 3 parameters a Proc and
|
||||||
# additional options wich can be extended.
|
# additional options wich can be extended.
|
||||||
|
# :values => name of the hook/identifier for specific module element state
|
||||||
# :element => name of module element in plural
|
# :element => name of module element in plural
|
||||||
# :children => bolean if element has children elements in report
|
# :children => bolean if element has children elements in report
|
||||||
# :locals => an array of names of local variables which are passed in the view
|
# :locals => an array of names of local variables which are passed in the view
|
||||||
# :coll => a prock which the my_module is passed and have to return a
|
# :coll => a procedure which the my_module is passed and have to return a
|
||||||
# collection of element
|
# collection of elements
|
||||||
# :singular => true by defaut change the enum type to singular
|
# :singular => true by defaut; change the enum type to singular - needed when
|
||||||
# needed when querying partials by name
|
# querying partials by name
|
||||||
|
|
||||||
ModuleElement = Struct.new(:element,
|
ModuleElement = Struct.new(:values,
|
||||||
|
:element,
|
||||||
:children,
|
:children,
|
||||||
:locals,
|
:locals,
|
||||||
:coll,
|
:coll,
|
||||||
:singular) do
|
:singular) do
|
||||||
def initialize(element, children, locals, coll = nil, singular = true)
|
def initialize(values, element, children, locals, coll = nil, singular = true)
|
||||||
super(element, children, locals, coll, singular)
|
super(values, element, children, locals, coll, singular)
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection(my_module)
|
def collection(my_module, params2)
|
||||||
coll.call(my_module) if coll
|
coll.call(my_module, params2) if coll
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_locals(values)
|
def parse_locals(values)
|
||||||
|
@ -48,34 +50,43 @@ module ReportExtends
|
||||||
|
|
||||||
# Module contents element
|
# Module contents element
|
||||||
MODULE_CONTENTS = [
|
MODULE_CONTENTS = [
|
||||||
ModuleElement.new(:steps,
|
ModuleElement.new(%i(completed_steps uncompleted_steps),
|
||||||
|
:steps,
|
||||||
true,
|
true,
|
||||||
[:step],
|
[:step],
|
||||||
proc do |my_module|
|
proc do |my_module, params2|
|
||||||
my_module.protocol.completed_steps.order(:position)
|
steps = []
|
||||||
|
steps << true if params2["module_completed_steps"] == '1'
|
||||||
|
steps << false if params2["module_uncompleted_steps"] == '1'
|
||||||
|
my_module.protocol.steps.where(completed: steps).order(:position)
|
||||||
end),
|
end),
|
||||||
ModuleElement.new(:result_assets,
|
ModuleElement.new([:result_assets],
|
||||||
|
:result_assets,
|
||||||
true,
|
true,
|
||||||
[:result],
|
[:result],
|
||||||
proc do |my_module|
|
proc do |my_module|
|
||||||
my_module.results.select { |r| r.is_asset && r.active? }
|
my_module.results.select { |r| r.is_asset && r.active? }
|
||||||
end),
|
end),
|
||||||
ModuleElement.new(:result_tables,
|
ModuleElement.new([:result_tables],
|
||||||
|
:result_tables,
|
||||||
true,
|
true,
|
||||||
[:result],
|
[:result],
|
||||||
proc do |my_module|
|
proc do |my_module|
|
||||||
my_module.results.select { |r| r.is_table && r.active? }
|
my_module.results.select { |r| r.is_table && r.active? }
|
||||||
end),
|
end),
|
||||||
ModuleElement.new(:result_texts,
|
ModuleElement.new([:result_texts],
|
||||||
|
:result_texts,
|
||||||
true,
|
true,
|
||||||
[:result],
|
[:result],
|
||||||
proc do |my_module|
|
proc do |my_module|
|
||||||
my_module.results.select { |r| r.is_text && r.active? }
|
my_module.results.select { |r| r.is_text && r.active? }
|
||||||
end),
|
end),
|
||||||
ModuleElement.new(:activity,
|
ModuleElement.new([:activity],
|
||||||
|
:activity,
|
||||||
false,
|
false,
|
||||||
[:my_module, :order]),
|
[:my_module, :order]),
|
||||||
ModuleElement.new(:samples,
|
ModuleElement.new([:samples],
|
||||||
|
:samples,
|
||||||
false,
|
false,
|
||||||
[:my_module, :order])
|
[:my_module, :order])
|
||||||
]
|
]
|
||||||
|
|
|
@ -291,7 +291,9 @@ en:
|
||||||
module_contents_inner:
|
module_contents_inner:
|
||||||
instructions: "Choose what information from task/s to include in the report"
|
instructions: "Choose what information from task/s to include in the report"
|
||||||
check_all: "All tasks content"
|
check_all: "All tasks content"
|
||||||
steps: "Completed protocol steps"
|
steps: "Steps"
|
||||||
|
completed_steps: "Completed"
|
||||||
|
uncompleted_steps: "Uncompleted"
|
||||||
no_steps: "Task has no steps"
|
no_steps: "Task has no steps"
|
||||||
results: "Results"
|
results: "Results"
|
||||||
result_assets: "Files"
|
result_assets: "Files"
|
||||||
|
@ -376,9 +378,12 @@ en:
|
||||||
user_time: "Created by %{user} on %{timestamp}."
|
user_time: "Created by %{user} on %{timestamp}."
|
||||||
step:
|
step:
|
||||||
sidebar_name: "Step %{pos}: %{name}"
|
sidebar_name: "Step %{pos}: %{name}"
|
||||||
user_time: "Completed by %{user} on %{timestamp}."
|
|
||||||
step_pos: "Step %{pos}:"
|
step_pos: "Step %{pos}:"
|
||||||
no_description: "No description"
|
no_description: "No description"
|
||||||
|
completed:
|
||||||
|
user_time: "Completed by %{user} on %{timestamp}."
|
||||||
|
uncompleted:
|
||||||
|
user_time: "Created by %{user} on %{timestamp}."
|
||||||
step_table:
|
step_table:
|
||||||
table_name: "[ %{name} ]"
|
table_name: "[ %{name} ]"
|
||||||
user_time: "Table created on %{timestamp}."
|
user_time: "Table created on %{timestamp}."
|
||||||
|
|
Loading…
Add table
Reference in a new issue