Update step structure in report [SCI-6855]

This commit is contained in:
Anton 2022-05-30 11:33:56 +02:00
parent b7e78f567c
commit a2f7f38e31
3 changed files with 35 additions and 17 deletions

View file

@ -3,15 +3,19 @@
module Reports::Docx::DrawMyModuleProtocol
def draw_my_module_protocol(my_module)
protocol = my_module.protocol
return false if protocol.description.blank?
@docx.p I18n.t 'projects.reports.elements.module.protocol.user_time',
timestamp: I18n.l(protocol.created_at, format: :full)
@docx.hr
html = custom_auto_link(protocol.description, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)
@docx.p
@docx.p
@docx.h4 protocol.name, italic: false
if protocol.description.present?
@docx.p I18n.t 'projects.reports.elements.module.protocol.user_time',
timestamp: I18n.l(protocol.created_at, format: :full)
@docx.hr
html = custom_auto_link(protocol.description, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)
@docx.p
@docx.p
end
end
end

View file

@ -30,21 +30,22 @@ module Reports::Docx::DrawStep
@docx.p I18n.t 'projects.reports.elements.step.no_description'
end
if @settings.dig('task', 'protocol', 'step_tables')
step.tables.each do |table|
draw_step_table(table)
step.step_orderable_elements.order(:position).each do |e|
if e.orderable_type == 'StepTable' && @settings.dig('task', 'protocol', 'step_tables')
draw_step_table(e.orderable.table)
end
if e.orderable_type == 'Checklist' && @settings.dig('task', 'protocol', 'step_checklists')
draw_step_checklist(e.orderable)
end
draw_step_text(e.orderable) if e.orderable_type == 'StepText'
end
if @settings.dig('task', 'protocol', 'step_files')
step.assets.each do |asset|
draw_step_asset(asset)
end
end
if @settings.dig('task', 'protocol', 'step_checklists')
step.checklists.each do |checklist|
draw_step_checklist(checklist)
end
end
draw_step_comments(step) if @settings.dig('task', 'protocol', 'step_comments')
@docx.p

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
module Reports::Docx::DrawStepText
def draw_step_text(step_text)
if step_text.text.present?
html = custom_auto_link(step_text.text, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)
else
@docx.p I18n.t 'projects.reports.elements.step.no_description'
end
end
end