diff --git a/app/controllers/concerns/report_actions.rb b/app/controllers/concerns/report_actions.rb index 3c27ae302..6ba54c76d 100644 --- a/app/controllers/concerns/report_actions.rb +++ b/app/controllers/concerns/report_actions.rb @@ -1,7 +1,6 @@ module ReportActions extend ActiveSupport::Concern - def in_params?(val) params.include? val and params[val] == '1' end @@ -83,7 +82,9 @@ module ReportActions .singularize}_element.html.erb", contents.parse_locals([report_el]) ) - el[:children] = generate_step_contents_json(report_el) if contents.element == :step + if contents.element == :step + el[:children] = generate_step_contents_json(report_el) + end el[:children] = generate_result_contents_json(report_el) res << el end diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 31834567c..9ae544c05 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -33,13 +33,16 @@ module ReportsHelper end file_name = element.type_of - file_name = "my_module_#{element.type_of}" if element.type_of.in? %w(step result_asset result_table result_text) + if element.type_of.in? %w(step result_asset result_table result_text) + file_name = "my_module_#{element.type_of.singularize}" + end view = "reports/elements/#{file_name}_element.html.erb" locals = provided_locals.nil? ? {} : provided_locals.clone locals[:children] = children_html # ReportExtends is located in config/initializers/extends/report_extends.rb + ReportElement.type_ofs.keys.each do |type| next unless element.send("#{type}?") local_sym = type.split('_').last.to_sym diff --git a/app/models/report_element.rb b/app/models/report_element.rb index 424070b06..cf75037cf 100644 --- a/app/models/report_element.rb +++ b/app/models/report_element.rb @@ -15,8 +15,12 @@ class ReportElement < ActiveRecord::Base belongs_to :report, inverse_of: :report_elements # Hierarchical structure representation - has_many :children, -> { order(:position) }, class_name: "ReportElement", foreign_key: "parent_id", dependent: :destroy - belongs_to :parent, class_name: "ReportElement" + has_many :children, + -> { order(:position) }, + class_name: 'ReportElement', + foreign_key: 'parent_id', + dependent: :destroy + belongs_to :parent, class_name: 'ReportElement' # References to various report entities belongs_to :project, inverse_of: :report_elements @@ -49,16 +53,6 @@ class ReportElement < ActiveRecord::Base # Set the element reference (previously, element's type_of must be set) def set_element_reference(ref_id) - # check = true - # ReportExtends::REFERENCE_ELEMENTS_IDS.each do |element| - # next unless check - # ReportExtends::SET_ELEMENT_REFERENCES_LIST.each do |el_ref| - # check = el_ref.check(self) - # next unless check - # check = false - # self.send("#{element}=", ref_id) - # end - # end ReportExtends::SET_ELEMENT_REFERENCES_LIST.each do |el_ref| check = el_ref.check(self) next unless check @@ -97,7 +91,8 @@ class ReportElement < ActiveRecord::Base table ].count { |r| r.present? } if num_of_refs != 1 - errors.add(:base, "Report element must have exactly one element reference.") + errors.add(:base, + 'Report element must have exactly one element reference.') end end end diff --git a/config/initializers/extends/report_extends.rb b/config/initializers/extends/report_extends.rb index 94e25523e..2194f4c3c 100644 --- a/config/initializers/extends/report_extends.rb +++ b/config/initializers/extends/report_extends.rb @@ -78,6 +78,7 @@ module ReportExtends # method: render_report_element # adds :order local to listed elements views + # ADD REPORT ELEMENT TYPE WHICH YOU WANT TO PASS 'ORDER' LOCAL IN THE PARTIAL SORTED_ELEMENTS = %w(my_module_activity my_module_samples step_comments