2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-17 16:50:01 +08:00
|
|
|
module Reports::Docx::DrawStep
|
2021-05-21 22:35:23 +08:00
|
|
|
def draw_step(step)
|
2019-07-12 19:48:14 +08:00
|
|
|
color = @color
|
2019-07-01 16:14:16 +08:00
|
|
|
step_type_str = step.completed ? 'completed' : 'uncompleted'
|
2021-06-29 19:46:45 +08:00
|
|
|
user = step.completed? && step.last_modified_by || step.user
|
2021-02-25 20:24:09 +08:00
|
|
|
timestamp = step.completed ? step.completed_on : step.created_at
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p
|
2019-07-12 19:48:14 +08:00
|
|
|
@docx.h5 (I18n.t('projects.reports.elements.step.step_pos', pos: step.position_plus_one) +
|
|
|
|
' ' + step.name), size: Constants::REPORT_DOCX_STEP_TITLE_SIZE
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p do
|
|
|
|
if step.completed
|
2019-07-12 19:48:14 +08:00
|
|
|
text I18n.t('protocols.steps.completed'), color: color[:green], bold: true
|
2019-07-01 16:14:16 +08:00
|
|
|
else
|
2019-07-12 19:48:14 +08:00
|
|
|
text I18n.t('protocols.steps.uncompleted'), color: color[:gray], bold: true
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
text ' | '
|
|
|
|
text I18n.t(
|
|
|
|
"projects.reports.elements.step.#{step_type_str}.user_time",
|
|
|
|
user: user.full_name,
|
|
|
|
timestamp: I18n.l(timestamp, format: :full)
|
2019-07-12 19:48:14 +08:00
|
|
|
), color: color[:gray]
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
if step.description.present?
|
|
|
|
html = custom_auto_link(step.description, team: @report_team)
|
2020-10-14 22:09:49 +08:00
|
|
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
|
|
|
|
link_style: @link_style }).html_to_word_converter(html)
|
2019-07-01 16:14:16 +08:00
|
|
|
else
|
|
|
|
@docx.p I18n.t 'projects.reports.elements.step.no_description'
|
|
|
|
end
|
|
|
|
|
2022-05-30 17:33:56 +08:00
|
|
|
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)
|
2021-05-21 22:35:23 +08:00
|
|
|
end
|
2022-05-30 17:33:56 +08:00
|
|
|
if e.orderable_type == 'Checklist' && @settings.dig('task', 'protocol', 'step_checklists')
|
|
|
|
draw_step_checklist(e.orderable)
|
|
|
|
end
|
2022-06-01 21:53:40 +08:00
|
|
|
draw_step_text(e.orderable) if e.orderable_type == 'StepText' && @settings.dig('task', 'protocol', 'step_texts')
|
2021-05-21 22:35:23 +08:00
|
|
|
end
|
|
|
|
if @settings.dig('task', 'protocol', 'step_files')
|
|
|
|
step.assets.each do |asset|
|
|
|
|
draw_step_asset(asset)
|
|
|
|
end
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
2022-05-30 17:33:56 +08:00
|
|
|
|
2021-05-21 22:35:23 +08:00
|
|
|
draw_step_comments(step) if @settings.dig('task', 'protocol', 'step_comments')
|
|
|
|
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p
|
|
|
|
@docx.p
|
|
|
|
end
|
|
|
|
end
|