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