2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-17 16:50:01 +08:00
|
|
|
module Reports::Docx::DrawMyModule
|
2020-07-21 20:11:42 +08:00
|
|
|
def draw_my_module(subject, experiment)
|
2019-07-01 16:14:16 +08:00
|
|
|
color = @color
|
|
|
|
link_style = @link_style
|
|
|
|
scinote_url = @scinote_url
|
2020-07-21 20:11:42 +08:00
|
|
|
my_module = experiment.my_modules.find_by(id: subject['id']['my_module_id'])
|
2019-07-12 19:48:14 +08:00
|
|
|
tags = my_module.tags
|
2019-07-01 16:14:16 +08:00
|
|
|
return unless my_module
|
|
|
|
|
2019-07-12 19:48:14 +08:00
|
|
|
@docx.h3 my_module.name, italic: false, size: Constants::REPORT_DOCX_MY_MODULE_TITLE_SIZE
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p do
|
|
|
|
text I18n.t('projects.reports.elements.module.user_time',
|
|
|
|
timestamp: I18n.l(my_module.created_at, format: :full)), color: color[:gray]
|
2019-07-12 17:38:48 +08:00
|
|
|
if my_module.archived?
|
|
|
|
text ' | '
|
|
|
|
text I18n.t('search.index.archived'), color: color[:gray]
|
|
|
|
end
|
2019-07-01 16:14:16 +08:00
|
|
|
text ' | '
|
2019-07-08 18:51:26 +08:00
|
|
|
link I18n.t('projects.reports.elements.all.scinote_link'),
|
2019-07-01 16:14:16 +08:00
|
|
|
scinote_url + Rails.application.routes.url_helpers.protocols_my_module_path(my_module),
|
|
|
|
link_style
|
|
|
|
end
|
2020-07-23 20:24:30 +08:00
|
|
|
|
|
|
|
@docx.p do
|
|
|
|
if my_module.started_on.present?
|
|
|
|
text I18n.t('projects.reports.elements.module.started_on',
|
|
|
|
started_on: I18n.l(my_module.started_on, format: :full))
|
|
|
|
else
|
|
|
|
text I18n.t('projects.reports.elements.module.no_due_date')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@docx.p do
|
|
|
|
if my_module.due_date.present?
|
|
|
|
text I18n.t('projects.reports.elements.module.due_date',
|
|
|
|
due_date: I18n.l(my_module.due_date, format: :full))
|
|
|
|
else
|
|
|
|
text I18n.t('projects.reports.elements.module.no_due_date')
|
|
|
|
end
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
|
2020-07-23 20:24:30 +08:00
|
|
|
status = my_module.my_module_status
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p do
|
2020-07-23 20:24:30 +08:00
|
|
|
text I18n.t('projects.reports.elements.module.status')
|
|
|
|
text ' '
|
|
|
|
text "[#{status.name}]", color: status.color.delete('#')
|
2020-09-09 16:46:21 +08:00
|
|
|
if my_module.completed?
|
|
|
|
text " #{I18n.t('my_modules.states.completed')} #{I18n.l(my_module.completed_on, format: :full)}"
|
|
|
|
end
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
@docx.p do
|
2020-07-28 15:53:35 +08:00
|
|
|
text I18n.t('projects.reports.elements.module.tags_header')
|
2019-07-12 19:48:14 +08:00
|
|
|
if tags.any?
|
|
|
|
my_module.tags.each do |tag|
|
|
|
|
text ' '
|
|
|
|
text "[#{tag.name}]", color: tag.color.delete('#')
|
|
|
|
end
|
|
|
|
else
|
2019-07-01 16:14:16 +08:00
|
|
|
text ' '
|
2020-07-28 15:53:35 +08:00
|
|
|
text I18n.t('projects.reports.elements.module.no_tags')
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-23 20:24:30 +08:00
|
|
|
if my_module.description.present?
|
|
|
|
html = custom_auto_link(my_module.description, team: @report_team)
|
2020-10-13 19:54:16 +08:00
|
|
|
Reports::HtmlToWordConverter.new(@docx).html_to_word_converter(html)
|
2020-07-23 20:24:30 +08:00
|
|
|
else
|
2020-07-28 15:53:35 +08:00
|
|
|
@docx.p I18n.t('projects.reports.elements.module.no_description')
|
2020-07-23 20:24:30 +08:00
|
|
|
end
|
|
|
|
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p
|
|
|
|
subject['children'].each do |child|
|
2020-07-21 20:11:42 +08:00
|
|
|
public_send("draw_#{child['type_of']}", child, my_module)
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|