2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-17 16:50:01 +08:00
|
|
|
module Reports::Docx::DrawMyModule
|
2021-05-21 22:35:23 +08:00
|
|
|
def draw_my_module(subject)
|
2019-07-01 16:14:16 +08:00
|
|
|
color = @color
|
|
|
|
link_style = @link_style
|
|
|
|
scinote_url = @scinote_url
|
2021-05-21 22:35:23 +08:00
|
|
|
my_module = subject.my_module
|
2022-10-13 19:55:36 +08:00
|
|
|
tags = my_module.tags.order(:id)
|
2021-10-01 20:18:40 +08:00
|
|
|
return unless can_read_my_module?(@user, my_module)
|
2019-07-01 16:14:16 +08:00
|
|
|
|
2022-07-13 18:52:56 +08:00
|
|
|
@docx.h3 do
|
|
|
|
link my_module.name,
|
|
|
|
scinote_url + Rails.application.routes.url_helpers.protocols_my_module_path(my_module),
|
|
|
|
link_style
|
|
|
|
end
|
|
|
|
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p do
|
2022-11-29 15:38:08 +08:00
|
|
|
text I18n.t('projects.reports.elements.module.user_time', code: my_module.code,
|
2019-07-01 16:14:16 +08:00
|
|
|
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
|
|
|
end
|
2020-07-23 20:24:30 +08:00
|
|
|
|
2022-07-20 16:12:38 +08:00
|
|
|
if my_module.started_on.present?
|
|
|
|
@docx.p do
|
2020-07-23 20:24:30 +08:00
|
|
|
text I18n.t('projects.reports.elements.module.started_on',
|
|
|
|
started_on: I18n.l(my_module.started_on, format: :full))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-07-20 16:12:38 +08:00
|
|
|
if my_module.due_date.present?
|
|
|
|
@docx.p do
|
2020-07-23 20:24:30 +08:00
|
|
|
text I18n.t('projects.reports.elements.module.due_date',
|
|
|
|
due_date: I18n.l(my_module.due_date, format: :full))
|
|
|
|
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
|
|
|
|
|
2022-10-13 19:55:36 +08:00
|
|
|
if tags.present?
|
2022-07-20 16:12:38 +08:00
|
|
|
@docx.p do
|
|
|
|
text I18n.t('projects.reports.elements.module.tags_header')
|
2022-10-13 19:55:36 +08:00
|
|
|
tags.each do |tag|
|
2019-07-12 19:48:14 +08:00
|
|
|
text ' '
|
|
|
|
text "[#{tag.name}]", color: tag.color.delete('#')
|
|
|
|
end
|
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-14 22:09:49 +08:00
|
|
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: scinote_url,
|
|
|
|
link_style: link_style }).html_to_word_converter(html)
|
2020-07-23 20:24:30 +08:00
|
|
|
end
|
|
|
|
|
2022-08-09 19:50:00 +08:00
|
|
|
draw_my_module_protocol(my_module)
|
2021-05-21 22:35:23 +08:00
|
|
|
|
|
|
|
filter_steps_for_report(my_module.protocol.steps, @settings).order(:position).each do |step|
|
|
|
|
draw_step(step)
|
|
|
|
end
|
|
|
|
|
2023-08-18 17:35:24 +08:00
|
|
|
@docx.h4 I18n.t('Results') if my_module.results.any? && (%w(file_results table_results text_results).any? { |k| @settings.dig('task', k) })
|
2021-05-21 22:35:23 +08:00
|
|
|
order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result|
|
|
|
|
if result.is_asset && @settings.dig('task', 'file_results')
|
2023-02-01 19:01:18 +08:00
|
|
|
draw_result_asset(result, @settings)
|
2021-05-21 22:35:23 +08:00
|
|
|
elsif result.is_table && @settings.dig('task', 'table_results')
|
|
|
|
draw_result_table(result)
|
|
|
|
elsif result.is_text && @settings.dig('task', 'text_results')
|
|
|
|
draw_result_text(result)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p
|
2021-05-27 22:31:41 +08:00
|
|
|
subject.children.active.each do |child|
|
2021-05-21 22:35:23 +08:00
|
|
|
public_send("draw_#{child.type_of}", child)
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
2021-05-21 22:35:23 +08:00
|
|
|
|
|
|
|
draw_my_module_activity(my_module) if @settings.dig('task', 'activities')
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
end
|