mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Fix report saving (#1748)
This commit is contained in:
parent
634b58bd6a
commit
3db6129808
6 changed files with 10 additions and 4 deletions
|
@ -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}?")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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">
|
||||
|
@ -18,4 +18,5 @@
|
|||
<em><%= t('my_modules.protocols.protocol_status_bar.no_description') %></em>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue