2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-17 16:50:01 +08:00
|
|
|
module Reports::Docx::DrawExperiment
|
2019-07-01 16:14:16 +08:00
|
|
|
def draw_experiment(subject)
|
|
|
|
color = @color
|
|
|
|
link_style = @link_style
|
|
|
|
scinote_url = @scinote_url
|
2021-05-21 22:35:23 +08:00
|
|
|
experiment = subject.experiment
|
|
|
|
return unless can_read_experiment?(@user, experiment)
|
2019-07-01 16:14:16 +08:00
|
|
|
|
2022-07-13 18:52:56 +08:00
|
|
|
@docx.h2 do
|
|
|
|
link experiment.name,
|
|
|
|
scinote_url + Rails.application.routes.url_helpers.canvas_experiment_path(experiment),
|
|
|
|
link_style
|
|
|
|
end
|
|
|
|
|
2019-07-01 16:14:16 +08:00
|
|
|
@docx.p do
|
|
|
|
text I18n.t('projects.reports.elements.experiment.user_time',
|
2021-06-18 20:11:54 +08:00
|
|
|
code: experiment.code, timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
|
2019-07-12 17:38:48 +08:00
|
|
|
if experiment.archived?
|
|
|
|
text ' | '
|
|
|
|
text I18n.t('search.index.archived'), color: color[:gray]
|
|
|
|
end
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
html = custom_auto_link(experiment.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
|
|
|
@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
|
|
|
|
end
|
|
|
|
end
|