mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-07 13:44:23 +08:00
fixes bug with step comments
This commit is contained in:
parent
3057965940
commit
1d42d46c02
5 changed files with 28 additions and 26 deletions
|
@ -84,8 +84,9 @@ module ReportActions
|
|||
)
|
||||
if contents.element == :step
|
||||
el[:children] = generate_step_contents_json(report_el)
|
||||
elsif contents.element == :result
|
||||
el[:children] = generate_result_contents_json(report_el)
|
||||
end
|
||||
el[:children] = generate_result_contents_json(report_el)
|
||||
res << el
|
||||
end
|
||||
else
|
||||
|
@ -103,7 +104,7 @@ module ReportActions
|
|||
|
||||
def generate_step_contents_json(step)
|
||||
res = []
|
||||
if in_params? :step_checklists then
|
||||
if in_params? :step_checklists
|
||||
step.checklists.each do |checklist|
|
||||
res << generate_new_el(false)
|
||||
res << generate_el(
|
||||
|
@ -112,7 +113,7 @@ module ReportActions
|
|||
)
|
||||
end
|
||||
end
|
||||
if in_params? :step_assets then
|
||||
if in_params? :step_assets
|
||||
step.assets.each do |asset|
|
||||
res << generate_new_el(false)
|
||||
res << generate_el(
|
||||
|
@ -121,7 +122,7 @@ module ReportActions
|
|||
)
|
||||
end
|
||||
end
|
||||
if in_params? :step_tables then
|
||||
if in_params? :step_tables
|
||||
step.tables.each do |table|
|
||||
res << generate_new_el(false)
|
||||
res << generate_el(
|
||||
|
@ -130,7 +131,7 @@ module ReportActions
|
|||
)
|
||||
end
|
||||
end
|
||||
if in_params? :step_comments then
|
||||
if in_params? :step_comments
|
||||
res << generate_new_el(false)
|
||||
res << generate_el(
|
||||
'reports/elements/step_comments_element.html.erb',
|
||||
|
|
|
@ -49,7 +49,7 @@ module ReportsHelper
|
|||
local_sym = type
|
||||
.split('_')
|
||||
.first
|
||||
.to_sym if type.in? ReportExtends::RESULT_ELEMENTS
|
||||
.to_sym if type.in? ReportExtends::FIRST_PART_ELEMENTS
|
||||
local_sym = :my_module if type.in? ReportExtends::MY_MODULE_ELEMENTS
|
||||
locals[local_sym] = element.element_reference
|
||||
locals[:order] = element
|
||||
|
|
|
@ -105,12 +105,13 @@ class Report < ActiveRecord::Base
|
|||
el.position = index
|
||||
el.report = self
|
||||
el.parent = parent
|
||||
el.type_of = json_element["type_of"]
|
||||
el.sort_order = json_element["sort_order"]
|
||||
el.set_element_reference(json_element["id"])
|
||||
el.type_of = json_element['type_of']
|
||||
el.sort_order = json_element['sort_order']
|
||||
el.set_element_reference(json_element['id'])
|
||||
el.save!
|
||||
if json_element["children"].present?
|
||||
json_element["children"].each_with_index do |child, i|
|
||||
|
||||
if json_element['children'].present?
|
||||
json_element['children'].each_with_index do |child, i|
|
||||
save_json_element(child, i, el)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,6 +57,7 @@ class ReportElement < ActiveRecord::Base
|
|||
check = el_ref.check(self)
|
||||
next unless check
|
||||
self.send("#{el_ref.element}=", ref_id)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -80,16 +81,14 @@ class ReportElement < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def has_one_of_referenced_elements
|
||||
num_of_refs = [
|
||||
project,
|
||||
experiment,
|
||||
my_module,
|
||||
step,
|
||||
result,
|
||||
checklist,
|
||||
asset,
|
||||
table
|
||||
].count { |r| r.present? }
|
||||
num_of_refs = [project,
|
||||
experiment,
|
||||
my_module,
|
||||
step,
|
||||
result,
|
||||
checklist,
|
||||
asset,
|
||||
table].count { |r| r.present? }
|
||||
if num_of_refs != 1
|
||||
errors.add(:base,
|
||||
'Report element must have exactly one element reference.')
|
||||
|
|
|
@ -93,11 +93,12 @@ module ReportExtends
|
|||
MY_MODULE_ELEMENTS = %w(my_module my_module_activity my_module_samples)
|
||||
|
||||
# sets local name to first element of the listed elements
|
||||
RESULT_ELEMENTS = %w(result_comments
|
||||
result_text
|
||||
result_asset
|
||||
result_table
|
||||
project_header)
|
||||
FIRST_PART_ELEMENTS = %w(result_comments
|
||||
result_text
|
||||
result_asset
|
||||
result_table
|
||||
project_header
|
||||
step_comments)
|
||||
|
||||
# path: app/models/report_element.rb
|
||||
# method: set_element_reference
|
||||
|
|
Loading…
Add table
Reference in a new issue