diff --git a/app/services/reports/docx/draw_experiment.rb b/app/services/reports/docx/draw_experiment.rb index a0bafeabc..a78156036 100644 --- a/app/services/reports/docx/draw_experiment.rb +++ b/app/services/reports/docx/draw_experiment.rb @@ -13,7 +13,7 @@ module DrawExperiment text I18n.t('projects.reports.elements.experiment.user_time', timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray] text ' | ' - link 'SciNote Link', + link I18n.t('projects.reports.elements.all.scinote_link'), scinote_url + Rails.application.routes.url_helpers.canvas_experiment_path(experiment), link_style end diff --git a/app/services/reports/docx/draw_my_module.rb b/app/services/reports/docx/draw_my_module.rb index 56bda4886..d8a5e8061 100644 --- a/app/services/reports/docx/draw_my_module.rb +++ b/app/services/reports/docx/draw_my_module.rb @@ -24,7 +24,7 @@ module DrawMyModule color: color[:gray] end text ' | ' - link 'SciNote Link', + 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 diff --git a/app/services/reports/docx/draw_my_module_activity.rb b/app/services/reports/docx/draw_my_module_activity.rb index 30e015d1d..c9d0f60a3 100644 --- a/app/services/reports/docx/draw_my_module_activity.rb +++ b/app/services/reports/docx/draw_my_module_activity.rb @@ -9,6 +9,7 @@ module DrawMyModuleActivity return false unless activities.any? + color = @color @docx.p @docx.p I18n.t('projects.reports.elements.module_activity.name', my_module: my_module.name), bold: true activities.each do |activity| @@ -18,7 +19,7 @@ module DrawMyModuleActivity else sanitize_input(generate_activity_content(activity, true)) end - @docx.p I18n.l(activity_ts, format: :full), color: 'a0a0a0' + @docx.p I18n.l(activity_ts, format: :full), color: color[:gray] html_to_word_converter(activity_text) @docx.p end diff --git a/app/services/reports/docx/draw_my_module_repository.rb b/app/services/reports/docx/draw_my_module_repository.rb index a3a90e49d..fc941fe75 100644 --- a/app/services/reports/docx/draw_my_module_repository.rb +++ b/app/services/reports/docx/draw_my_module_repository.rb @@ -46,7 +46,7 @@ module DrawMyModuleRepository @docx.p I18n.t('projects.reports.elements.module_repository.name', repository: repository.name, my_module: my_module.name), bold: true - @docx.table table, border_size: 4 + @docx.table table, border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE @docx.p @docx.p end diff --git a/app/services/reports/docx/draw_result_asset.rb b/app/services/reports/docx/draw_result_asset.rb index 8c52fdaea..9150ebb09 100644 --- a/app/services/reports/docx/draw_result_asset.rb +++ b/app/services/reports/docx/draw_result_asset.rb @@ -8,13 +8,14 @@ module DrawResultAsset asset = result.asset is_image = result.asset.is_image? timestamp = asset.created_at + color = @color @docx.p @docx.p do text result.name - text ' ' + I18n.t('search.index.archived'), color: 'a0a0a0' if result.archived? + text ' ' + I18n.t('search.index.archived'), color: color[:gray] if result.archived? text ' ' + I18n.t('projects.reports.elements.result_asset.file_name', file: asset.file_file_name) text ' ' + I18n.t('projects.reports.elements.result_asset.user_time', - user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: 'a0a0a0' + user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray] end asset_image_preparing(asset) if is_image diff --git a/app/services/reports/docx/draw_result_table.rb b/app/services/reports/docx/draw_result_table.rb index 7aae83fed..f0984251d 100644 --- a/app/services/reports/docx/draw_result_table.rb +++ b/app/services/reports/docx/draw_result_table.rb @@ -7,17 +7,18 @@ module DrawResultTable table = result.table timestamp = table.created_at + color = @color @docx.p @docx.p do text result.name - text ' ' + I18n.t('search.index.archived'), color: 'a0a0a0' if result.archived? + text ' ' + I18n.t('search.index.archived'), color: color[:gray] if result.archived? text ' ' text I18n.t 'projects.reports.elements.result_table.table_name', name: table.name text ' ' text I18n.t('projects.reports.elements.result_text.user_time', - timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: 'a0a0a0' + 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: 4 + @docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE subject['children'].each do |child| public_send("draw_#{child['type_of']}", child) end diff --git a/app/services/reports/docx/draw_result_text.rb b/app/services/reports/docx/draw_result_text.rb index 87b090fe0..114f2fde5 100644 --- a/app/services/reports/docx/draw_result_text.rb +++ b/app/services/reports/docx/draw_result_text.rb @@ -7,13 +7,14 @@ module DrawResultText result_text = result.result_text timestamp = result.created_at + color = @color @docx.p @docx.p do text result.name - text ' ' + I18n.t('search.index.archived'), color: 'a0a0a0' if result.archived? + text ' ' + I18n.t('search.index.archived'), color: color[:gray] if result.archived? text ' ' text I18n.t('projects.reports.elements.result_table.user_time', - timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: 'a0a0a0' + timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray] end html = custom_auto_link(result_text.text, team: @report_team) html_to_word_converter(html) diff --git a/app/services/reports/docx/draw_step_asset.rb b/app/services/reports/docx/draw_step_asset.rb index 57a10b65e..d1471ba3a 100644 --- a/app/services/reports/docx/draw_step_asset.rb +++ b/app/services/reports/docx/draw_step_asset.rb @@ -7,12 +7,13 @@ module DrawStepAsset is_image = asset.is_image? timestamp = asset.created_at + color = @color @docx.p @docx.p do text I18n.t 'projects.reports.elements.step_asset.file_name', file: asset.file_file_name text ' ' text I18n.t('projects.reports.elements.step_asset.user_time', - timestamp: I18n.l(timestamp, format: :full)), color: 'a0a0a0' + timestamp: I18n.l(timestamp, format: :full)), color: color[:gray] end asset_image_preparing(asset) if is_image diff --git a/app/services/reports/docx/draw_step_checklist.rb b/app/services/reports/docx/draw_step_checklist.rb index 8956cf97f..cd728965b 100644 --- a/app/services/reports/docx/draw_step_checklist.rb +++ b/app/services/reports/docx/draw_step_checklist.rb @@ -7,6 +7,7 @@ module DrawStepChecklist items = checklist.checklist_items timestamp = checklist.created_at + color = @color @docx.p @docx.p do text SmartAnnotations::TagToText.new( @@ -16,7 +17,7 @@ module DrawStepChecklist ).text text ' ' text I18n.t('projects.reports.elements.step_checklist.user_time', - timestamp: I18n.l(timestamp, format: :full)), color: 'a0a0a0' + timestamp: I18n.l(timestamp, format: :full)), color: color[:gray] end @docx.ul do items.each do |item| diff --git a/app/services/reports/docx/draw_step_table.rb b/app/services/reports/docx/draw_step_table.rb index f46a69527..d84a80257 100644 --- a/app/services/reports/docx/draw_step_table.rb +++ b/app/services/reports/docx/draw_step_table.rb @@ -5,14 +5,15 @@ module DrawStepTable table = Table.find_by_id(subject['id']['table_id']) return unless table + color = @color timestamp = table.created_at @docx.p @docx.p do text I18n.t 'projects.reports.elements.step_table.table_name', name: table.name text ' ' text I18n.t('projects.reports.elements.step_table.user_time', - timestamp: I18n.l(timestamp, format: :full)), color: 'a0a0a0' + timestamp: I18n.l(timestamp, format: :full)), color: color[:gray] end - @docx.table JSON.parse(table.contents_utf_8)['data'], border_size: 4 + @docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE end end diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb index 67f6045f1..eedd6abd0 100644 --- a/config/initializers/constants.rb +++ b/config/initializers/constants.rb @@ -111,6 +111,11 @@ class Constants REPORT_DOCX_MARGIN_BOTTOM = 720 REPORT_DOCX_MARGIN_LEFT = 720 + # Word borders in eighth point units. + # A eighth point is 1/8 of a point. A border size of 4 is equivalent to 0.5pt. + + REPORT_DOCX_TABLE_BORDER_SIZE = 4 + #============================================================================= # Styling #============================================================================= diff --git a/config/locales/en.yml b/config/locales/en.yml index b463bf614..78bebc844 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -469,6 +469,7 @@ en: move_up: "Move report element up" move_down: "Move report element down" remove: "Remove report element from the report" + scinote_link: "SciNote link" new_element: title: "Add new report element/s here" project_header: