2019-07-01 16:14:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-17 16:50:01 +08:00
|
|
|
module Reports::Docx::PrivateMethods
|
2020-10-09 14:22:38 +08:00
|
|
|
private
|
2019-07-01 16:14:16 +08:00
|
|
|
|
|
|
|
def initial_document_load
|
|
|
|
@docx.page_size do
|
|
|
|
width Constants::REPORT_DOCX_WIDTH
|
|
|
|
height Constants::REPORT_DOCX_HEIGHT
|
|
|
|
end
|
|
|
|
|
|
|
|
@docx.page_margins do
|
|
|
|
left Constants::REPORT_DOCX_MARGIN_LEFT
|
|
|
|
right Constants::REPORT_DOCX_MARGIN_RIGHT
|
|
|
|
top Constants::REPORT_DOCX_MARGIN_TOP
|
|
|
|
bottom Constants::REPORT_DOCX_MARGIN_BOTTOM
|
|
|
|
end
|
|
|
|
|
|
|
|
@docx.page_numbers true, align: :right
|
|
|
|
|
2023-08-24 22:27:33 +08:00
|
|
|
insert_logo
|
2020-07-08 16:48:29 +08:00
|
|
|
|
|
|
|
@docx.p do
|
|
|
|
text I18n.t('projects.reports.new.generate_PDF.generated_on', timestamp: I18n.l(Time.zone.now, format: :full))
|
|
|
|
end
|
|
|
|
|
2022-07-13 18:52:56 +08:00
|
|
|
@docx.hr
|
|
|
|
|
2019-07-01 16:14:16 +08:00
|
|
|
generate_html_styles
|
|
|
|
end
|
|
|
|
|
2023-08-24 22:27:33 +08:00
|
|
|
def insert_logo
|
|
|
|
logo_data = File.read(Rails.root.join('app/assets/images/scinote_logo.svg'))
|
|
|
|
|
|
|
|
@docx.img 'logo.svg' do
|
|
|
|
data logo_data
|
|
|
|
height 20
|
|
|
|
width 100
|
|
|
|
align :left
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-01 16:14:16 +08:00
|
|
|
def generate_html_styles
|
|
|
|
@docx.style do
|
2020-07-08 17:35:25 +08:00
|
|
|
id 'Heading1'
|
|
|
|
name 'heading 1'
|
|
|
|
font 'Arial'
|
2022-07-13 18:52:56 +08:00
|
|
|
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
|
2019-07-01 16:14:16 +08:00
|
|
|
bold true
|
2022-07-13 18:52:56 +08:00
|
|
|
italic false
|
2019-07-01 16:14:16 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
@link_style = {
|
2022-07-13 18:52:56 +08:00
|
|
|
color: '2a61bb',
|
|
|
|
bold: false
|
2019-07-01 16:14:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@color = {
|
2019-07-12 19:48:14 +08:00
|
|
|
gray: 'a0a0a0',
|
2023-05-10 22:15:14 +08:00
|
|
|
green: '2dbe61',
|
|
|
|
concrete: 'f0f0f6'
|
2019-07-01 16:14:16 +08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|