Fix I18n and constants in DOCX report (#1901)

This commit is contained in:
aignatov-bio 2019-07-08 12:51:26 +02:00 committed by GitHub
parent ab9b7a7429
commit 0d1ec0d4ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 28 additions and 15 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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|

View file

@ -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

View file

@ -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
#=============================================================================

View file

@ -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: