mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 20:23:16 +08:00
DOCX layout improvements [SCI-6857] (#4160)
This commit is contained in:
parent
b84e77210f
commit
3d2e835268
8 changed files with 83 additions and 29 deletions
|
@ -8,7 +8,12 @@ module Reports::Docx::DrawExperiment
|
|||
experiment = subject.experiment
|
||||
return unless can_read_experiment?(@user, experiment)
|
||||
|
||||
@docx.h2 experiment.name, size: Constants::REPORT_DOCX_EXPERIMENT_TITLE_SIZE
|
||||
@docx.h2 do
|
||||
link experiment.name,
|
||||
scinote_url + Rails.application.routes.url_helpers.canvas_experiment_path(experiment),
|
||||
link_style
|
||||
end
|
||||
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.elements.experiment.user_time',
|
||||
code: experiment.code, timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
|
||||
|
@ -16,10 +21,6 @@ module Reports::Docx::DrawExperiment
|
|||
text ' | '
|
||||
text I18n.t('search.index.archived'), color: color[:gray]
|
||||
end
|
||||
text ' | '
|
||||
link I18n.t('projects.reports.elements.all.scinote_link'),
|
||||
scinote_url + Rails.application.routes.url_helpers.canvas_experiment_path(experiment),
|
||||
link_style
|
||||
end
|
||||
html = custom_auto_link(experiment.description, team: @report_team)
|
||||
Reports::HtmlToWordConverter.new(@docx, { scinote_url: scinote_url,
|
||||
|
|
|
@ -9,7 +9,12 @@ module Reports::Docx::DrawMyModule
|
|||
tags = my_module.tags
|
||||
return unless can_read_my_module?(@user, my_module)
|
||||
|
||||
@docx.h3 my_module.name, italic: false, size: Constants::REPORT_DOCX_MY_MODULE_TITLE_SIZE
|
||||
@docx.h3 do
|
||||
link my_module.name,
|
||||
scinote_url + Rails.application.routes.url_helpers.protocols_my_module_path(my_module),
|
||||
link_style
|
||||
end
|
||||
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.elements.module.user_time',
|
||||
timestamp: I18n.l(my_module.created_at, format: :full)), color: color[:gray]
|
||||
|
@ -17,10 +22,6 @@ module Reports::Docx::DrawMyModule
|
|||
text ' | '
|
||||
text I18n.t('search.index.archived'), color: color[:gray]
|
||||
end
|
||||
text ' | '
|
||||
link I18n.t('projects.reports.elements.all.scinote_link'),
|
||||
scinote_url + Rails.application.routes.url_helpers.protocols_my_module_path(my_module),
|
||||
link_style
|
||||
end
|
||||
|
||||
@docx.p do
|
||||
|
@ -78,6 +79,7 @@ module Reports::Docx::DrawMyModule
|
|||
draw_step(step)
|
||||
end
|
||||
|
||||
@docx.h4 I18n.t('Results') if my_module.results.any?
|
||||
order_results_for_report(my_module.results, @settings.dig('task', 'result_order')).each do |result|
|
||||
if result.is_asset && @settings.dig('task', 'file_results')
|
||||
draw_result_asset(result)
|
||||
|
|
|
@ -7,8 +7,7 @@ module Reports::Docx::DrawMyModuleActivity
|
|||
|
||||
color = @color
|
||||
@docx.p
|
||||
@docx.p I18n.t('projects.reports.elements.module_activity.name', my_module: my_module.name),
|
||||
bold: true, size: Constants::REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE
|
||||
@docx.h4 I18n.t('projects.reports.elements.module_activity.name', my_module: my_module.name)
|
||||
activities.each do |activity|
|
||||
activity_ts = activity.created_at
|
||||
activity_text = if activity.old_activity?
|
||||
|
|
|
@ -7,7 +7,7 @@ module Reports::Docx::DrawMyModuleProtocol
|
|||
@docx.h4 protocol.name, italic: false
|
||||
|
||||
if protocol.description.present?
|
||||
|
||||
@docx.h4 protocol.name if my_module.results.any?
|
||||
@docx.p I18n.t 'projects.reports.elements.module.protocol.user_time',
|
||||
timestamp: I18n.l(protocol.created_at, format: :full)
|
||||
@docx.hr
|
||||
|
|
|
@ -3,14 +3,23 @@
|
|||
module Reports::Docx::DrawProjectHeader
|
||||
def draw_project_header(subject)
|
||||
project = subject.project
|
||||
link_style = @link_style
|
||||
scinote_url = @scinote_url
|
||||
|
||||
return unless project && can_read_project?(@user, project)
|
||||
|
||||
@docx.p I18n.t('projects.reports.elements.project_header.user_time',
|
||||
timestamp: I18n.l(project.created_at, format: :full))
|
||||
@docx.h1 I18n.t('projects.reports.elements.project_header.title', project: project.name)
|
||||
@docx.hr do
|
||||
size 18
|
||||
spacing 24
|
||||
@docx.h1 do
|
||||
link I18n.t('projects.reports.elements.project_header.title', project: project.name),
|
||||
scinote_url + Rails.application.routes.url_helpers.project_path(project),
|
||||
link_style
|
||||
end
|
||||
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.elements.project_header.user_time',
|
||||
timestamp: I18n.l(project.created_at, format: :full))
|
||||
br
|
||||
br
|
||||
br
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,11 +4,12 @@ module Reports::Docx::DrawStep
|
|||
def draw_step(step)
|
||||
color = @color
|
||||
step_type_str = step.completed ? 'completed' : 'uncompleted'
|
||||
user = step.completed? && step.last_modified_by || step.user
|
||||
user = (step.completed? && step.last_modified_by) || step.user
|
||||
timestamp = step.completed ? step.completed_on : step.created_at
|
||||
@docx.p
|
||||
@docx.h5 (I18n.t('projects.reports.elements.step.step_pos', pos: step.position_plus_one) +
|
||||
' ' + step.name), size: Constants::REPORT_DOCX_STEP_TITLE_SIZE
|
||||
@docx.h5(
|
||||
"#{I18n.t('projects.reports.elements.step.step_pos', pos: step.position_plus_one)} #{step.name}"
|
||||
)
|
||||
@docx.p do
|
||||
if step.completed
|
||||
text I18n.t('protocols.steps.completed'), color: color[:green], bold: true
|
||||
|
|
|
@ -27,9 +27,10 @@ module Reports::Docx::PrivateMethods
|
|||
end
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.new.generate_PDF.generated_on', timestamp: I18n.l(Time.zone.now, format: :full))
|
||||
br
|
||||
end
|
||||
|
||||
@docx.hr
|
||||
|
||||
generate_html_styles
|
||||
end
|
||||
|
||||
|
@ -38,14 +39,54 @@ module Reports::Docx::PrivateMethods
|
|||
id 'Heading1'
|
||||
name 'heading 1'
|
||||
font 'Arial'
|
||||
size 36
|
||||
bottom 120
|
||||
size Constants::REPORT_DOCX_REPORT_TITLE_SIZE
|
||||
bottom 240
|
||||
bold true
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'Heading2'
|
||||
name 'heading 2'
|
||||
font 'Arial'
|
||||
size Constants::REPORT_DOCX_EXPERIMENT_TITLE_SIZE
|
||||
bottom Constants::REPORT_DOCX_EXPERIMENT_TITLE_SIZE * 10
|
||||
bold true
|
||||
italic false
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'Heading3'
|
||||
name 'heading 3'
|
||||
font 'Arial'
|
||||
size Constants::REPORT_DOCX_MY_MODULE_TITLE_SIZE
|
||||
bottom Constants::REPORT_DOCX_EXPERIMENT_TITLE_SIZE * 10
|
||||
bold true
|
||||
italic false
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'Heading4'
|
||||
name 'heading 4'
|
||||
font 'Arial'
|
||||
size Constants::REPORT_DOCX_STEP_TITLE_SIZE
|
||||
bottom Constants::REPORT_DOCX_EXPERIMENT_TITLE_SIZE * 10
|
||||
bold true
|
||||
italic false
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'Heading5'
|
||||
name 'heading 5'
|
||||
font 'Arial'
|
||||
size Constants::REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE
|
||||
bottom Constants::REPORT_DOCX_EXPERIMENT_TITLE_SIZE * 10
|
||||
bold true
|
||||
italic false
|
||||
end
|
||||
|
||||
@link_style = {
|
||||
color: '37a0d9',
|
||||
bold: true
|
||||
color: '2a61bb',
|
||||
bold: false
|
||||
}
|
||||
|
||||
@color = {
|
||||
|
|
|
@ -126,8 +126,9 @@ class Constants
|
|||
REPORT_DOCX_TABLE_BORDER_SIZE = 4
|
||||
|
||||
# All font size in half points
|
||||
REPORT_DOCX_EXPERIMENT_TITLE_SIZE = 28
|
||||
REPORT_DOCX_MY_MODULE_TITLE_SIZE = 24
|
||||
REPORT_DOCX_REPORT_TITLE_SIZE = 36
|
||||
REPORT_DOCX_EXPERIMENT_TITLE_SIZE = 32
|
||||
REPORT_DOCX_MY_MODULE_TITLE_SIZE = 28
|
||||
REPORT_DOCX_STEP_TITLE_SIZE = 22
|
||||
REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE = 20
|
||||
|
||||
|
|
Loading…
Reference in a new issue