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