Fix report saving (#1748)

This commit is contained in:
aignatov-bio 2019-05-13 08:58:47 +02:00 committed by GitHub
parent 634b58bd6a
commit 3db6129808
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 4 deletions

View file

@ -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}?")

View file

@ -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

View file

@ -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')

View file

@ -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

View file

@ -1,5 +1,5 @@
<div class="report-element report-module-protocol-element" data-ts="<%= protocol.created_at %>" data-type="protocol" data-id='{ "protocol_id": <%= protocol.id %> }' data-scroll-id="<%= protocol.id %>">
<div class="report-element report-module-protocol-element" data-ts="<%= protocol.created_at %>" data-type="my_module_protocol" data-id='{ "protocol_id": <%= protocol.id %> }' data-scroll-id="<%= protocol.id %>">
<div class="report-element-header">
<div class="row">
<div class="pull-left user-time">
@ -19,3 +19,4 @@
<% end %>
</div>
</div>
</div>

View file

@ -38,7 +38,8 @@ class Extends
project_samples: 14, # TODO
experiment: 15,
# Higher number because of addons
my_module_repository: 17 }
my_module_repository: 17,
my_module_protocol: 18 }
# Data type name should match corresponding model's name
REPOSITORY_DATA_TYPES = { RepositoryTextValue: 0,