diff --git a/app/services/reports/docx/draw_my_module.rb b/app/services/reports/docx/draw_my_module.rb index c944362b4..b2fd99e0a 100644 --- a/app/services/reports/docx/draw_my_module.rb +++ b/app/services/reports/docx/draw_my_module.rb @@ -24,21 +24,17 @@ module Reports::Docx::DrawMyModule end end - @docx.p do - if my_module.started_on.present? + if my_module.started_on.present? + @docx.p do 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? + if my_module.due_date.present? + @docx.p do 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 end @@ -52,16 +48,13 @@ module Reports::Docx::DrawMyModule end end - @docx.p do - text I18n.t('projects.reports.elements.module.tags_header') - if tags.any? + if tags.any? + @docx.p do + text I18n.t('projects.reports.elements.module.tags_header') my_module.tags.each do |tag| text ' ' text "[#{tag.name}]", color: tag.color.delete('#') end - else - text ' ' - text I18n.t('projects.reports.elements.module.no_tags') end end @@ -69,8 +62,6 @@ module Reports::Docx::DrawMyModule html = custom_auto_link(my_module.description, team: @report_team) Reports::HtmlToWordConverter.new(@docx, { scinote_url: scinote_url, link_style: link_style }).html_to_word_converter(html) - else - @docx.p I18n.t('projects.reports.elements.module.no_description') end draw_my_module_protocol(my_module) if @settings.dig('task', 'protocol', 'description') diff --git a/app/services/reports/docx/draw_my_module_protocol.rb b/app/services/reports/docx/draw_my_module_protocol.rb index 5a5c0bdbc..e47ded272 100644 --- a/app/services/reports/docx/draw_my_module_protocol.rb +++ b/app/services/reports/docx/draw_my_module_protocol.rb @@ -8,9 +8,8 @@ module Reports::Docx::DrawMyModuleProtocol 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 + @docx.p I18n.t('projects.reports.elements.module.protocol.user_time', + timestamp: I18n.l(protocol.created_at, format: :full)), color: @color[:gray] html = custom_auto_link(protocol.description, team: @report_team) Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url, link_style: @link_style }).html_to_word_converter(html) diff --git a/app/services/reports/docx/draw_project_header.rb b/app/services/reports/docx/draw_project_header.rb index 508a86000..e311e1848 100644 --- a/app/services/reports/docx/draw_project_header.rb +++ b/app/services/reports/docx/draw_project_header.rb @@ -5,6 +5,7 @@ module Reports::Docx::DrawProjectHeader project = subject.project link_style = @link_style scinote_url = @scinote_url + color = @color return unless project && can_read_project?(@user, project) @@ -16,7 +17,7 @@ module Reports::Docx::DrawProjectHeader @docx.p do text I18n.t('projects.reports.elements.project_header.user_time', - timestamp: I18n.l(project.created_at, format: :full)) + timestamp: I18n.l(project.created_at, format: :full)), color: color[:gray] br br br diff --git a/app/services/reports/docx/draw_result_asset.rb b/app/services/reports/docx/draw_result_asset.rb index 29d896049..b6c613a3d 100644 --- a/app/services/reports/docx/draw_result_asset.rb +++ b/app/services/reports/docx/draw_result_asset.rb @@ -7,6 +7,16 @@ module Reports::Docx::DrawResultAsset asset_url = Rails.application.routes.url_helpers.asset_download_url(asset) color = @color @docx.p + + begin + Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list? + rescue StandardError => e + Rails.logger.error e.message + @docx.p do + text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true + end + end + @docx.p do text result.name, italic: true text ' ' @@ -19,15 +29,6 @@ module Reports::Docx::DrawResultAsset user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray] end - begin - Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list? - rescue StandardError => e - Rails.logger.error e.message - @docx.p do - text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true - end - end - draw_result_comments(result) if @settings.dig('task', 'result_comments') end end diff --git a/app/services/reports/docx/draw_result_table.rb b/app/services/reports/docx/draw_result_table.rb index b7b90fd50..6ad3fa6bf 100644 --- a/app/services/reports/docx/draw_result_table.rb +++ b/app/services/reports/docx/draw_result_table.rb @@ -6,6 +6,7 @@ module Reports::Docx::DrawResultTable timestamp = table.created_at color = @color @docx.p + @docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE @docx.p do text result.name, italic: true text ' ' + I18n.t('search.index.archived'), color: color[:gray] if result.archived? @@ -15,7 +16,6 @@ module Reports::Docx::DrawResultTable text I18n.t('projects.reports.elements.result_text.user_time', timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray] end - @docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE draw_result_comments(result) if @settings.dig('task', 'result_comments') end diff --git a/app/services/reports/docx/draw_step.rb b/app/services/reports/docx/draw_step.rb index ae738e724..4bb406b73 100644 --- a/app/services/reports/docx/draw_step.rb +++ b/app/services/reports/docx/draw_step.rb @@ -23,13 +23,6 @@ module Reports::Docx::DrawStep timestamp: I18n.l(timestamp, format: :full) ), color: color[:gray] end - if step.description.present? - html = custom_auto_link(step.description, team: @report_team) - Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url, - link_style: @link_style }).html_to_word_converter(html) - else - @docx.p I18n.t 'projects.reports.elements.step.no_description' - end step.step_orderable_elements.order(:position).each do |e| if e.orderable_type == 'StepTable' && @settings.dig('task', 'protocol', 'step_tables') diff --git a/app/services/reports/docx/draw_step_asset.rb b/app/services/reports/docx/draw_step_asset.rb index 5ecf71e49..8d83ca221 100644 --- a/app/services/reports/docx/draw_step_asset.rb +++ b/app/services/reports/docx/draw_step_asset.rb @@ -6,6 +6,16 @@ module Reports::Docx::DrawStepAsset asset_url = Rails.application.routes.url_helpers.asset_download_url(asset) color = @color @docx.p + + begin + Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list? + rescue StandardError => e + Rails.logger.error e.message + @docx.p do + text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true + end + end + @docx.p do text (I18n.t 'projects.reports.elements.step_asset.file_name', file: asset.file_name), italic: true text ' ' @@ -16,14 +26,5 @@ module Reports::Docx::DrawStepAsset text I18n.t('projects.reports.elements.step_asset.user_time', timestamp: I18n.l(timestamp, format: :full)), color: color[:gray] end - - begin - Reports::DocxRenderer.render_asset_image(@docx, asset) if asset.previewable? && !asset.list? - rescue StandardError => e - Rails.logger.error e.message - @docx.p do - text I18n.t('projects.reports.index.generation.file_preview_generation_error'), italic: true - end - end end end diff --git a/app/services/reports/docx/draw_step_table.rb b/app/services/reports/docx/draw_step_table.rb index a91114b5d..66dd59775 100644 --- a/app/services/reports/docx/draw_step_table.rb +++ b/app/services/reports/docx/draw_step_table.rb @@ -5,12 +5,12 @@ module Reports::Docx::DrawStepTable color = @color timestamp = table.created_at @docx.p + @docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE @docx.p do text I18n.t('projects.reports.elements.step_table.table_name', name: table.name), italic: true text ' ' text I18n.t('projects.reports.elements.step_table.user_time', timestamp: I18n.l(timestamp, format: :full)), color: color[:gray] end - @docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 8dd1f51ea..b3c764891 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -735,11 +735,15 @@ en: sidebar_name: "Activity" no_activity: "No activities" module_repository: + name: "%{repository} of task %{my_module}" + table_name: "%{name}" no_items: "No items" result_asset: + file_name: "%{file}" user_time: "Uploaded by %{user} on %{timestamp}." full_preview_attached: "[full document attached to report]" result_table: + table_name: "%{name}" user_time: "Created by %{user} on %{timestamp}." result_text: user_time: "Created by %{user} on %{timestamp}." @@ -752,11 +756,14 @@ en: uncompleted: user_time: "Created by %{user} on %{timestamp}." step_table: + table_name: "%{name}" user_time: "Table created on %{timestamp}." step_asset: + file_name: "%{file}" sidebar_name: "File %{file}" user_time: "File uploaded on %{timestamp}." step_checklist: + checklist_name: "%{name}" user_time: "Checklist created on %{timestamp}." checked: "checked" result_comments: