mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-05 11:24:42 +08:00
Docx report fixes [SCI-6979] (#4265)
* Fixes for docx [SCI-6979] * Remove step description from DOCX [SCI-6979]
This commit is contained in:
parent
49dfa2c2aa
commit
1732c8897a
9 changed files with 40 additions and 47 deletions
|
@ -24,21 +24,17 @@ module Reports::Docx::DrawMyModule
|
||||||
end
|
end
|
||||||
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',
|
text I18n.t('projects.reports.elements.module.started_on',
|
||||||
started_on: I18n.l(my_module.started_on, format: :full))
|
started_on: I18n.l(my_module.started_on, format: :full))
|
||||||
else
|
|
||||||
text I18n.t('projects.reports.elements.module.no_due_date')
|
|
||||||
end
|
end
|
||||||
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',
|
text I18n.t('projects.reports.elements.module.due_date',
|
||||||
due_date: I18n.l(my_module.due_date, format: :full))
|
due_date: I18n.l(my_module.due_date, format: :full))
|
||||||
else
|
|
||||||
text I18n.t('projects.reports.elements.module.no_due_date')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,16 +48,13 @@ module Reports::Docx::DrawMyModule
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@docx.p do
|
if tags.any?
|
||||||
text I18n.t('projects.reports.elements.module.tags_header')
|
@docx.p do
|
||||||
if tags.any?
|
text I18n.t('projects.reports.elements.module.tags_header')
|
||||||
my_module.tags.each do |tag|
|
my_module.tags.each do |tag|
|
||||||
text ' '
|
text ' '
|
||||||
text "[#{tag.name}]", color: tag.color.delete('#')
|
text "[#{tag.name}]", color: tag.color.delete('#')
|
||||||
end
|
end
|
||||||
else
|
|
||||||
text ' '
|
|
||||||
text I18n.t('projects.reports.elements.module.no_tags')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,8 +62,6 @@ module Reports::Docx::DrawMyModule
|
||||||
html = custom_auto_link(my_module.description, team: @report_team)
|
html = custom_auto_link(my_module.description, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx, { scinote_url: scinote_url,
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: scinote_url,
|
||||||
link_style: link_style }).html_to_word_converter(html)
|
link_style: link_style }).html_to_word_converter(html)
|
||||||
else
|
|
||||||
@docx.p I18n.t('projects.reports.elements.module.no_description')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
draw_my_module_protocol(my_module) if @settings.dig('task', 'protocol', 'description')
|
draw_my_module_protocol(my_module) if @settings.dig('task', 'protocol', 'description')
|
||||||
|
|
|
@ -8,9 +8,8 @@ module Reports::Docx::DrawMyModuleProtocol
|
||||||
|
|
||||||
if protocol.description.present?
|
if protocol.description.present?
|
||||||
@docx.h4 protocol.name if my_module.results.any?
|
@docx.h4 protocol.name if my_module.results.any?
|
||||||
@docx.p I18n.t 'projects.reports.elements.module.protocol.user_time',
|
@docx.p I18n.t('projects.reports.elements.module.protocol.user_time',
|
||||||
timestamp: I18n.l(protocol.created_at, format: :full)
|
timestamp: I18n.l(protocol.created_at, format: :full)), color: @color[:gray]
|
||||||
@docx.hr
|
|
||||||
html = custom_auto_link(protocol.description, team: @report_team)
|
html = custom_auto_link(protocol.description, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
|
||||||
link_style: @link_style }).html_to_word_converter(html)
|
link_style: @link_style }).html_to_word_converter(html)
|
||||||
|
|
|
@ -5,6 +5,7 @@ module Reports::Docx::DrawProjectHeader
|
||||||
project = subject.project
|
project = subject.project
|
||||||
link_style = @link_style
|
link_style = @link_style
|
||||||
scinote_url = @scinote_url
|
scinote_url = @scinote_url
|
||||||
|
color = @color
|
||||||
|
|
||||||
return unless project && can_read_project?(@user, project)
|
return unless project && can_read_project?(@user, project)
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ module Reports::Docx::DrawProjectHeader
|
||||||
|
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text I18n.t('projects.reports.elements.project_header.user_time',
|
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
|
br
|
||||||
br
|
br
|
||||||
|
|
|
@ -7,6 +7,16 @@ module Reports::Docx::DrawResultAsset
|
||||||
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
|
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
|
||||||
color = @color
|
color = @color
|
||||||
@docx.p
|
@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
|
@docx.p do
|
||||||
text result.name, italic: true
|
text result.name, italic: true
|
||||||
text ' '
|
text ' '
|
||||||
|
@ -19,15 +29,6 @@ module Reports::Docx::DrawResultAsset
|
||||||
user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
|
user: result.user.full_name, timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
|
||||||
end
|
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')
|
draw_result_comments(result) if @settings.dig('task', 'result_comments')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,7 @@ module Reports::Docx::DrawResultTable
|
||||||
timestamp = table.created_at
|
timestamp = table.created_at
|
||||||
color = @color
|
color = @color
|
||||||
@docx.p
|
@docx.p
|
||||||
|
@docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text result.name, italic: true
|
text result.name, italic: true
|
||||||
text ' ' + I18n.t('search.index.archived'), color: color[:gray] if result.archived?
|
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',
|
text I18n.t('projects.reports.elements.result_text.user_time',
|
||||||
timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray]
|
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: Constants::REPORT_DOCX_TABLE_BORDER_SIZE
|
|
||||||
|
|
||||||
draw_result_comments(result) if @settings.dig('task', 'result_comments')
|
draw_result_comments(result) if @settings.dig('task', 'result_comments')
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,13 +23,6 @@ module Reports::Docx::DrawStep
|
||||||
timestamp: I18n.l(timestamp, format: :full)
|
timestamp: I18n.l(timestamp, format: :full)
|
||||||
), color: color[:gray]
|
), color: color[:gray]
|
||||||
end
|
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|
|
step.step_orderable_elements.order(:position).each do |e|
|
||||||
if e.orderable_type == 'StepTable' && @settings.dig('task', 'protocol', 'step_tables')
|
if e.orderable_type == 'StepTable' && @settings.dig('task', 'protocol', 'step_tables')
|
||||||
|
|
|
@ -6,6 +6,16 @@ module Reports::Docx::DrawStepAsset
|
||||||
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
|
asset_url = Rails.application.routes.url_helpers.asset_download_url(asset)
|
||||||
color = @color
|
color = @color
|
||||||
@docx.p
|
@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
|
@docx.p do
|
||||||
text (I18n.t 'projects.reports.elements.step_asset.file_name', file: asset.file_name), italic: true
|
text (I18n.t 'projects.reports.elements.step_asset.file_name', file: asset.file_name), italic: true
|
||||||
text ' '
|
text ' '
|
||||||
|
@ -16,14 +26,5 @@ module Reports::Docx::DrawStepAsset
|
||||||
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: color[:gray]
|
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,12 +5,12 @@ module Reports::Docx::DrawStepTable
|
||||||
color = @color
|
color = @color
|
||||||
timestamp = table.created_at
|
timestamp = table.created_at
|
||||||
@docx.p
|
@docx.p
|
||||||
|
@docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE
|
||||||
@docx.p do
|
@docx.p do
|
||||||
text I18n.t('projects.reports.elements.step_table.table_name', name: table.name), italic: true
|
text I18n.t('projects.reports.elements.step_table.table_name', name: table.name), italic: true
|
||||||
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: color[:gray]
|
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
|
||||||
end
|
end
|
||||||
@docx.table JSON.parse(table.contents_utf_8)['data'], border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -735,11 +735,15 @@ en:
|
||||||
sidebar_name: "Activity"
|
sidebar_name: "Activity"
|
||||||
no_activity: "No activities"
|
no_activity: "No activities"
|
||||||
module_repository:
|
module_repository:
|
||||||
|
name: "%{repository} of task %{my_module}"
|
||||||
|
table_name: "%{name}"
|
||||||
no_items: "No items"
|
no_items: "No items"
|
||||||
result_asset:
|
result_asset:
|
||||||
|
file_name: "%{file}"
|
||||||
user_time: "Uploaded by %{user} on %{timestamp}."
|
user_time: "Uploaded by %{user} on %{timestamp}."
|
||||||
full_preview_attached: "[full document attached to report]"
|
full_preview_attached: "[full document attached to report]"
|
||||||
result_table:
|
result_table:
|
||||||
|
table_name: "%{name}"
|
||||||
user_time: "Created by %{user} on %{timestamp}."
|
user_time: "Created by %{user} on %{timestamp}."
|
||||||
result_text:
|
result_text:
|
||||||
user_time: "Created by %{user} on %{timestamp}."
|
user_time: "Created by %{user} on %{timestamp}."
|
||||||
|
@ -752,11 +756,14 @@ en:
|
||||||
uncompleted:
|
uncompleted:
|
||||||
user_time: "Created by %{user} on %{timestamp}."
|
user_time: "Created by %{user} on %{timestamp}."
|
||||||
step_table:
|
step_table:
|
||||||
|
table_name: "%{name}"
|
||||||
user_time: "Table created on %{timestamp}."
|
user_time: "Table created on %{timestamp}."
|
||||||
step_asset:
|
step_asset:
|
||||||
|
file_name: "%{file}"
|
||||||
sidebar_name: "File %{file}"
|
sidebar_name: "File %{file}"
|
||||||
user_time: "File uploaded on %{timestamp}."
|
user_time: "File uploaded on %{timestamp}."
|
||||||
step_checklist:
|
step_checklist:
|
||||||
|
checklist_name: "%{name}"
|
||||||
user_time: "Checklist created on %{timestamp}."
|
user_time: "Checklist created on %{timestamp}."
|
||||||
checked: "checked"
|
checked: "checked"
|
||||||
result_comments:
|
result_comments:
|
||||||
|
|
Loading…
Add table
Reference in a new issue