mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-03 18:35:36 +08:00
Fix I18n and constants in DOCX report (#1901)
This commit is contained in:
parent
ab9b7a7429
commit
0d1ec0d4ed
12 changed files with 28 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
#=============================================================================
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue