2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-17 16:50:01 +08:00
|
|
|
module Reports::Docx::DrawStep
|
2020-07-21 20:11:42 +08:00
|
|
|
def draw_step(subject, my_module)
|
2019-07-12 19:48:14 +08:00
|
|
|
color = @color
|
2020-07-21 20:11:42 +08:00
|
|
|
step = my_module.protocols.first.steps.find_by(id: subject['id']['step_id'])
|
2019-07-01 16:14:16 +08:00
|
|
|
return unless step
|
|
|
|
|
|
|
|
step_type_str = step.completed ? 'completed' : 'uncompleted'
|
|
|
|
user = step.completed || !step.changed? ? step.user : step.last_modified_by
|
|
|
|
timestamp = step.completed ? step.completed_on : step.updated_at
|
|
|
|
@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
|
|
|
|
|
|
|
|
subject['children'].each do |child|
|
2020-07-21 20:11:42 +08:00
|
|
|
public_send("draw_#{child['type_of']}", child, step)
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
@docx.p
|
|
|
|
@docx.p
|
|
|
|
end
|
|
|
|
end
|