mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-11 06:16:32 +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',
|
text I18n.t('projects.reports.elements.experiment.user_time',
|
||||||
timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
|
timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
|
||||||
text ' | '
|
text ' | '
|
||||||
link 'SciNote Link',
|
link I18n.t('projects.reports.elements.all.scinote_link'),
|
||||||
scinote_url + Rails.application.routes.url_helpers.canvas_experiment_path(experiment),
|
scinote_url + Rails.application.routes.url_helpers.canvas_experiment_path(experiment),
|
||||||
link_style
|
link_style
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ module DrawMyModule
|
||||||
color: color[:gray]
|
color: color[:gray]
|
||||||
end
|
end
|
||||||
text ' | '
|
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),
|
scinote_url + Rails.application.routes.url_helpers.protocols_my_module_path(my_module),
|
||||||
link_style
|
link_style
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ module DrawMyModuleActivity
|
||||||
|
|
||||||
return false unless activities.any?
|
return false unless activities.any?
|
||||||
|
|
||||||
|
color = @color
|
||||||
@docx.p
|
@docx.p
|
||||||
@docx.p I18n.t('projects.reports.elements.module_activity.name', my_module: my_module.name), bold: true
|
@docx.p I18n.t('projects.reports.elements.module_activity.name', my_module: my_module.name), bold: true
|
||||||
activities.each do |activity|
|
activities.each do |activity|
|
||||||
|
@ -18,7 +19,7 @@ module DrawMyModuleActivity
|
||||||
else
|
else
|
||||||
sanitize_input(generate_activity_content(activity, true))
|
sanitize_input(generate_activity_content(activity, true))
|
||||||
end
|
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)
|
html_to_word_converter(activity_text)
|
||||||
@docx.p
|
@docx.p
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,7 +46,7 @@ module DrawMyModuleRepository
|
||||||
@docx.p I18n.t('projects.reports.elements.module_repository.name',
|
@docx.p I18n.t('projects.reports.elements.module_repository.name',
|
||||||
repository: repository.name,
|
repository: repository.name,
|
||||||
my_module: my_module.name), bold: true
|
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
|
||||||
@docx.p
|
@docx.p
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,13 +8,14 @@ module DrawResultAsset
|
||||||
asset = result.asset
|
asset = result.asset
|
||||||
is_image = result.asset.is_image?
|
is_image = result.asset.is_image?
|
||||||
timestamp = asset.created_at
|
timestamp = asset.created_at
|
||||||
|
color = @color
|
||||||
@docx.p
|
@docx.p
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text result.name
|
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.file_name', file: asset.file_file_name)
|
||||||
text ' ' + I18n.t('projects.reports.elements.result_asset.user_time',
|
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
|
end
|
||||||
|
|
||||||
asset_image_preparing(asset) if is_image
|
asset_image_preparing(asset) if is_image
|
||||||
|
|
|
@ -7,17 +7,18 @@ module DrawResultTable
|
||||||
|
|
||||||
table = result.table
|
table = result.table
|
||||||
timestamp = table.created_at
|
timestamp = table.created_at
|
||||||
|
color = @color
|
||||||
@docx.p
|
@docx.p
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text result.name
|
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 ' '
|
||||||
text I18n.t 'projects.reports.elements.result_table.table_name', name: table.name
|
text I18n.t 'projects.reports.elements.result_table.table_name', name: table.name
|
||||||
text ' '
|
text ' '
|
||||||
text I18n.t('projects.reports.elements.result_text.user_time',
|
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
|
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|
|
subject['children'].each do |child|
|
||||||
public_send("draw_#{child['type_of']}", child)
|
public_send("draw_#{child['type_of']}", child)
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,14 @@ module DrawResultText
|
||||||
|
|
||||||
result_text = result.result_text
|
result_text = result.result_text
|
||||||
timestamp = result.created_at
|
timestamp = result.created_at
|
||||||
|
color = @color
|
||||||
@docx.p
|
@docx.p
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text result.name
|
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 ' '
|
||||||
text I18n.t('projects.reports.elements.result_table.user_time',
|
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
|
end
|
||||||
html = custom_auto_link(result_text.text, team: @report_team)
|
html = custom_auto_link(result_text.text, team: @report_team)
|
||||||
html_to_word_converter(html)
|
html_to_word_converter(html)
|
||||||
|
|
|
@ -7,12 +7,13 @@ module DrawStepAsset
|
||||||
|
|
||||||
is_image = asset.is_image?
|
is_image = asset.is_image?
|
||||||
timestamp = asset.created_at
|
timestamp = asset.created_at
|
||||||
|
color = @color
|
||||||
@docx.p
|
@docx.p
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text I18n.t 'projects.reports.elements.step_asset.file_name', file: asset.file_file_name
|
text I18n.t 'projects.reports.elements.step_asset.file_name', file: asset.file_file_name
|
||||||
text ' '
|
text ' '
|
||||||
text I18n.t('projects.reports.elements.step_asset.user_time',
|
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
|
end
|
||||||
|
|
||||||
asset_image_preparing(asset) if is_image
|
asset_image_preparing(asset) if is_image
|
||||||
|
|
|
@ -7,6 +7,7 @@ module DrawStepChecklist
|
||||||
|
|
||||||
items = checklist.checklist_items
|
items = checklist.checklist_items
|
||||||
timestamp = checklist.created_at
|
timestamp = checklist.created_at
|
||||||
|
color = @color
|
||||||
@docx.p
|
@docx.p
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text SmartAnnotations::TagToText.new(
|
text SmartAnnotations::TagToText.new(
|
||||||
|
@ -16,7 +17,7 @@ module DrawStepChecklist
|
||||||
).text
|
).text
|
||||||
text ' '
|
text ' '
|
||||||
text I18n.t('projects.reports.elements.step_checklist.user_time',
|
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
|
end
|
||||||
@docx.ul do
|
@docx.ul do
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
|
|
|
@ -5,14 +5,15 @@ module DrawStepTable
|
||||||
table = Table.find_by_id(subject['id']['table_id'])
|
table = Table.find_by_id(subject['id']['table_id'])
|
||||||
return unless table
|
return unless table
|
||||||
|
|
||||||
|
color = @color
|
||||||
timestamp = table.created_at
|
timestamp = table.created_at
|
||||||
@docx.p
|
@docx.p
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text I18n.t 'projects.reports.elements.step_table.table_name', name: table.name
|
text I18n.t 'projects.reports.elements.step_table.table_name', name: table.name
|
||||||
text ' '
|
text ' '
|
||||||
text I18n.t('projects.reports.elements.step_table.user_time',
|
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
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -111,6 +111,11 @@ class Constants
|
||||||
REPORT_DOCX_MARGIN_BOTTOM = 720
|
REPORT_DOCX_MARGIN_BOTTOM = 720
|
||||||
REPORT_DOCX_MARGIN_LEFT = 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
|
# Styling
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
|
@ -469,6 +469,7 @@ en:
|
||||||
move_up: "Move report element up"
|
move_up: "Move report element up"
|
||||||
move_down: "Move report element down"
|
move_down: "Move report element down"
|
||||||
remove: "Remove report element from the report"
|
remove: "Remove report element from the report"
|
||||||
|
scinote_link: "SciNote link"
|
||||||
new_element:
|
new_element:
|
||||||
title: "Add new report element/s here"
|
title: "Add new report element/s here"
|
||||||
project_header:
|
project_header:
|
||||||
|
|
Loading…
Add table
Reference in a new issue