Merge pull request #7941 from rekonder/aj_SCI_11056

Remove some empty in docx reports [SCI-11056]
This commit is contained in:
ajugo 2024-10-08 11:13:25 +02:00 committed by GitHub
commit bf723cd43e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 70 additions and 57 deletions

View file

@ -15,14 +15,15 @@ module Reports::Docx::DrawExperiment
link_style
end
@docx.p do
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.experiment.user_time',
code: experiment.code, timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
end
if experiment.archived?
text ' | '
text I18n.t('search.index.archived'), color: color[:gray]
if !settings['exclude_timestamps'] || experiment.archived?
@docx.p do
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.experiment.user_time',
code: experiment.code,
timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
text ' | ' if experiment.archived?
end
text I18n.t('search.index.archived'), color: color[:gray] if experiment.archived?
end
end
html = custom_auto_link(experiment.description, team: @report_team)

View file

@ -16,14 +16,15 @@ module Reports::Docx::DrawMyModule
link_style
end
@docx.p do
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.module.user_time', code: my_module.code,
timestamp: I18n.l(my_module.created_at, format: :full)), color: color[:gray]
end
if my_module.archived?
text ' | '
text I18n.t('search.index.archived'), color: color[:gray]
if my_module.archived? || !settings['exclude_timestamps']
@docx.p do
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.module.user_time', code: my_module.code,
timestamp: I18n.l(my_module.created_at, format: :full)), color: color[:gray]
text ' | ' if my_module.archived?
end
text I18n.t('search.index.archived'), color: color[:gray] if my_module.archived?
end
end
@ -74,10 +75,13 @@ module Reports::Docx::DrawMyModule
filter_steps_for_report(my_module.protocol.steps, @settings).order(:position).each do |step|
draw_step(step)
end
draw_results(my_module) unless without_results
@docx.p
unless without_results
draw_results(my_module)
@docx.p
end
subject.children.active.each do |child|
next if without_repositories && child.type_of == 'my_module_repository'

View file

@ -20,7 +20,6 @@ module Reports::Docx::DrawMyModuleProtocol
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)
@docx.p
@docx.p
end
end
end

View file

@ -8,8 +8,10 @@ module Reports::Docx::DrawResultComments
@docx.p
@docx.p I18n.t('projects.reports.elements.result_comments.name', result: result.name),
bold: true, size: Constants::REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE
comments.each do |comment|
comments.find_each.with_index do |comment, index|
comment_ts = comment.created_at
@docx.p unless index.zero?
@docx.p I18n.t('projects.reports.elements.result_comments.comment_prefix',
user: comment.user.full_name,
date: I18n.l(comment_ts, format: :full_date),
@ -17,7 +19,6 @@ module Reports::Docx::DrawResultComments
html = custom_auto_link(comment.message, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)
@docx.p
end
end
end

View file

@ -40,8 +40,8 @@ module Reports::Docx::DrawResultTable
end
@docx.p do
text I18n.t 'projects.reports.elements.result_table.table_name', name: table.name
text ' '
unless settings['exclude_timestamps']
text ' '
text I18n.t('projects.reports.elements.result_table.user_time',
timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray]
end

View file

@ -6,12 +6,15 @@ module Reports::Docx::DrawResultText
timestamp = element.created_at
settings = @settings
color = @color
@docx.p do
text result_text.name.presence || '', italic: true
text ' '
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
if result_text.name.present? || !settings['exclude_timestamps']
@docx.p do
text result_text.name.to_s, italic: true
text ' ' if result_text.name.present?
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
end
end
html = custom_auto_link(result_text.text, team: @report_team)

View file

@ -11,21 +11,24 @@ module Reports::Docx::DrawStep
@docx.h4(
"#{I18n.t('projects.reports.elements.step.step_pos', pos: step.position_plus_one)} #{step.name}"
)
@docx.p do
unless settings['exclude_task_metadata']
if step.completed
text I18n.t('protocols.steps.completed'), color: color[:green], bold: true
else
text I18n.t('protocols.steps.uncompleted'), color: color[:gray], bold: true
unless settings['exclude_task_metadata'] || settings['exclude_timestamps']
@docx.p do
unless settings['exclude_task_metadata']
if step.completed
text I18n.t('protocols.steps.completed'), color: color[:green], bold: true
else
text I18n.t('protocols.steps.uncompleted'), color: color[:gray], bold: true
end
end
unless settings['exclude_timestamps']
text ' | ' unless settings['exclude_task_metadata']
text I18n.t(
"projects.reports.elements.step.#{step_type_str}.user_time",
user: user.full_name,
timestamp: I18n.l(timestamp, format: :full)
), color: color[:gray]
end
end
unless settings['exclude_timestamps']
text ' | ' unless settings['exclude_task_metadata']
text I18n.t(
"projects.reports.elements.step.#{step_type_str}.user_time",
user: user.full_name,
timestamp: I18n.l(timestamp, format: :full)
), color: color[:gray]
end
end
@ -46,9 +49,6 @@ module Reports::Docx::DrawStep
end
draw_step_comments(step) if @settings.dig('task', 'protocol', 'step_comments')
@docx.p
@docx.p
end
def handle_step_table(table)

View file

@ -23,8 +23,8 @@ module Reports::Docx::DrawStepAsset
link I18n.t('projects.reports.elements.download'), asset_url do
italic true
end
text ' '
unless settings['exclude_timestamps']
text ' '
text I18n.t('projects.reports.elements.step_asset.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end

View file

@ -16,8 +16,8 @@ module Reports::Docx::DrawStepChecklist
team,
I18n.t('projects.reports.elements.step_checklist.checklist_name', name: checklist.name)
).text, italic: true
text ' '
unless settings['exclude_timestamps']
text ' '
text I18n.t('projects.reports.elements.step_checklist.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end

View file

@ -8,8 +8,10 @@ module Reports::Docx::DrawStepComments
@docx.p
@docx.p I18n.t('projects.reports.elements.step_comments.name', step: step.name),
bold: true, size: Constants::REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE
comments.each do |comment|
comments.find_each.with_index do |comment, index|
comment_ts = comment.created_at
@docx.p unless index.zero?
@docx.p I18n.t('projects.reports.elements.step_comments.comment_prefix',
user: comment.user.full_name,
date: I18n.l(comment_ts, format: :full_date),
@ -17,7 +19,6 @@ module Reports::Docx::DrawStepComments
html = custom_auto_link(comment.message, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
link_style: @link_style }).html_to_word_converter(html)
@docx.p
end
end
end

View file

@ -39,8 +39,8 @@ module Reports::Docx::DrawStepTable
end
@docx.p do
text I18n.t("projects.reports.elements.#{table_type}.table_name", name: table.name), italic: true
text ' '
unless settings['exclude_timestamps']
text ' '
text I18n.t("projects.reports.elements.#{table_type}.user_time",
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end

View file

@ -6,12 +6,16 @@ module Reports::Docx::DrawStepText
timestamp = element.created_at
color = @color
settings = @settings
@docx.p do
text step_text.name.presence || '', italic: true
text ' '
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
if step_text.name.present? || !settings['exclude_timestamps']
@docx.p do
text step_text.name.to_s, italic: true
text ' ' if step_text.name.present?
unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.result_text.user_time',
timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end
end
end
if step_text.text.present?