diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index f2ec2940a..d7c868df3 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -8,7 +8,6 @@ module ReportsHelper def render_report_element(element, provided_locals = nil) # Determine partial - file_name = element.type_of if element.type_of.in? ReportExtends::MY_MODULE_CHILDREN_ELEMENTS file_name = "my_module_#{element.type_of.singularize}" @@ -83,6 +82,8 @@ module ReportsHelper end end + locals[:protocol] = element.parent.my_module.protocol if element.type_of == 'my_module_protocol' + # ReportExtends is located in config/initializers/extends/report_extends.rb ReportElement.type_ofs.keys.each do |type| next unless element.public_send("#{type}?") diff --git a/app/models/concerns/tiny_mce_images.rb b/app/models/concerns/tiny_mce_images.rb index 88de79dea..d320547c7 100644 --- a/app/models/concerns/tiny_mce_images.rb +++ b/app/models/concerns/tiny_mce_images.rb @@ -27,6 +27,8 @@ module TinyMceImages tm_asset_to_update = html_description.css( "img[data-mce-token=\"#{Base62.encode(tm_asset.id)}\"]" )[0] + next unless tm_asset_to_update + tm_asset_to_update.attributes['src'].value = new_tm_asset_src description = html_description.css('body').inner_html.to_s ensure diff --git a/app/models/report.rb b/app/models/report.rb index 5d23083b1..02b02e3dc 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -100,6 +100,7 @@ class Report < ApplicationRecord exp.my_modules.each do |my_module| module_children = [] + module_children += gen_element_content(my_module.protocol, nil, 'my_module_protocol') my_module.protocol.steps.each do |step| step_children = gen_element_content(step, step.assets, 'step_asset') diff --git a/app/models/report_element.rb b/app/models/report_element.rb index 8ae6e2fe4..377771270 100644 --- a/app/models/report_element.rb +++ b/app/models/report_element.rb @@ -84,7 +84,7 @@ class ReportElement < ApplicationRecord if parent_model == 'experiment' destroy unless send(parent_model).project == report.project - else + elsif parent_model != '' destroy unless (send(parent_model).active? rescue send(parent_model)) end end diff --git a/app/views/reports/elements/_my_module_protocol_element.html.erb b/app/views/reports/elements/_my_module_protocol_element.html.erb index dc1bf8e7d..e8ebb1035 100644 --- a/app/views/reports/elements/_my_module_protocol_element.html.erb +++ b/app/views/reports/elements/_my_module_protocol_element.html.erb @@ -1,5 +1,5 @@ -