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 link_style
end end
if !settings['exclude_timestamps'] || experiment.archived?
@docx.p do @docx.p do
unless settings['exclude_timestamps'] unless settings['exclude_timestamps']
text I18n.t('projects.reports.elements.experiment.user_time', text I18n.t('projects.reports.elements.experiment.user_time',
code: experiment.code, timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray] code: experiment.code,
timestamp: I18n.l(experiment.created_at, format: :full)), color: color[:gray]
text ' | ' if experiment.archived?
end end
if experiment.archived? text I18n.t('search.index.archived'), color: color[:gray] if experiment.archived?
text ' | '
text I18n.t('search.index.archived'), color: color[:gray]
end end
end end
html = custom_auto_link(experiment.description, team: @report_team) html = custom_auto_link(experiment.description, team: @report_team)

View file

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

View file

@ -8,8 +8,10 @@ module Reports::Docx::DrawResultComments
@docx.p @docx.p
@docx.p I18n.t('projects.reports.elements.result_comments.name', result: result.name), @docx.p I18n.t('projects.reports.elements.result_comments.name', result: result.name),
bold: true, size: Constants::REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE 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 comment_ts = comment.created_at
@docx.p unless index.zero?
@docx.p I18n.t('projects.reports.elements.result_comments.comment_prefix', @docx.p I18n.t('projects.reports.elements.result_comments.comment_prefix',
user: comment.user.full_name, user: comment.user.full_name,
date: I18n.l(comment_ts, format: :full_date), 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) html = custom_auto_link(comment.message, 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)
@docx.p
end end
end end
end end

View file

@ -40,8 +40,8 @@ module Reports::Docx::DrawResultTable
end end
@docx.p do @docx.p do
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 ' '
unless settings['exclude_timestamps'] unless settings['exclude_timestamps']
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: color[:gray] timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray]
end end

View file

@ -6,14 +6,17 @@ module Reports::Docx::DrawResultText
timestamp = element.created_at timestamp = element.created_at
settings = @settings settings = @settings
color = @color color = @color
if result_text.name.present? || !settings['exclude_timestamps']
@docx.p do @docx.p do
text result_text.name.presence || '', italic: true text result_text.name.to_s, italic: true
text ' ' text ' ' if result_text.name.present?
unless settings['exclude_timestamps'] unless settings['exclude_timestamps']
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)), color: color[:gray] timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end end
end end
end
html = custom_auto_link(result_text.text, team: @report_team) html = custom_auto_link(result_text.text, 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)

View file

@ -11,6 +11,8 @@ module Reports::Docx::DrawStep
@docx.h4( @docx.h4(
"#{I18n.t('projects.reports.elements.step.step_pos', pos: step.position_plus_one)} #{step.name}" "#{I18n.t('projects.reports.elements.step.step_pos', pos: step.position_plus_one)} #{step.name}"
) )
unless settings['exclude_task_metadata'] || settings['exclude_timestamps']
@docx.p do @docx.p do
unless settings['exclude_task_metadata'] unless settings['exclude_task_metadata']
if step.completed if step.completed
@ -28,6 +30,7 @@ module Reports::Docx::DrawStep
), color: color[:gray] ), color: color[:gray]
end end
end end
end
step.step_orderable_elements.order(:position).each do |element| step.step_orderable_elements.order(:position).each do |element|
case element.orderable_type case element.orderable_type
@ -46,9 +49,6 @@ module Reports::Docx::DrawStep
end end
draw_step_comments(step) if @settings.dig('task', 'protocol', 'step_comments') draw_step_comments(step) if @settings.dig('task', 'protocol', 'step_comments')
@docx.p
@docx.p
end end
def handle_step_table(table) 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 link I18n.t('projects.reports.elements.download'), asset_url do
italic true italic true
end end
text ' '
unless settings['exclude_timestamps'] unless settings['exclude_timestamps']
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: color[:gray] timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end end

View file

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

View file

@ -8,8 +8,10 @@ module Reports::Docx::DrawStepComments
@docx.p @docx.p
@docx.p I18n.t('projects.reports.elements.step_comments.name', step: step.name), @docx.p I18n.t('projects.reports.elements.step_comments.name', step: step.name),
bold: true, size: Constants::REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE 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 comment_ts = comment.created_at
@docx.p unless index.zero?
@docx.p I18n.t('projects.reports.elements.step_comments.comment_prefix', @docx.p I18n.t('projects.reports.elements.step_comments.comment_prefix',
user: comment.user.full_name, user: comment.user.full_name,
date: I18n.l(comment_ts, format: :full_date), 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) html = custom_auto_link(comment.message, 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)
@docx.p
end end
end end
end end

View file

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

View file

@ -6,14 +6,18 @@ module Reports::Docx::DrawStepText
timestamp = element.created_at timestamp = element.created_at
color = @color color = @color
settings = @settings settings = @settings
if step_text.name.present? || !settings['exclude_timestamps']
@docx.p do @docx.p do
text step_text.name.presence || '', italic: true text step_text.name.to_s, italic: true
text ' ' text ' ' if step_text.name.present?
unless settings['exclude_timestamps'] unless settings['exclude_timestamps']
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)), color: color[:gray] timestamp: I18n.l(timestamp, format: :full)), color: color[:gray]
end end
end end
end
if step_text.text.present? if step_text.text.present?
html = custom_auto_link(step_text.text, team: @report_team) html = custom_auto_link(step_text.text, team: @report_team)
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url, Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,