From c2b7c12497dbd2a9ff4271e8bc3120e7a8342cd2 Mon Sep 17 00:00:00 2001 From: Andrej Date: Fri, 25 Oct 2024 12:46:58 +0200 Subject: [PATCH] Add default text if not repository columns are selected for reports [SCI-11211] --- app/services/reports/docx/draw_my_module_repository.rb | 7 ++++++- app/services/reports/docx/repository_helper.rb | 2 ++ config/locales/en.yml | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/services/reports/docx/draw_my_module_repository.rb b/app/services/reports/docx/draw_my_module_repository.rb index b5102a25a..11f1ed0c8 100644 --- a/app/services/reports/docx/draw_my_module_repository.rb +++ b/app/services/reports/docx/draw_my_module_repository.rb @@ -20,7 +20,12 @@ module Reports::Docx::DrawMyModuleRepository @docx.p I18n.t('projects.reports.elements.module_repository.name', repository: repository.name, my_module: my_module.name), bold: true, size: Constants::REPORT_DOCX_STEP_ELEMENTS_TITLE_SIZE - @docx.table table, border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE + + if table.present? + @docx.table table, border_size: Constants::REPORT_DOCX_TABLE_BORDER_SIZE + else + @docx.p I18n.t('projects.reports.elements.module_repository.no_columns'), italic: true + end @docx.p @docx.p diff --git a/app/services/reports/docx/repository_helper.rb b/app/services/reports/docx/repository_helper.rb index 26d2a43b6..d8166ca9b 100644 --- a/app/services/reports/docx/repository_helper.rb +++ b/app/services/reports/docx/repository_helper.rb @@ -5,6 +5,8 @@ module Reports::Docx::RepositoryHelper include ActionView::Helpers::NumberHelper def prepare_row_columns_for_docx(repository_data, my_module = nil, repository = nil) + return if repository_data[:headers].blank? + result = [repository_data[:headers]] excluded_columns = repository_data[:excluded_columns] diff --git a/config/locales/en.yml b/config/locales/en.yml index 880b00f85..5e1c931a8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -978,6 +978,7 @@ en: name: "%{repository} of task %{my_module}" table_name: "%{name}" no_items: "No items" + no_columns: "No columns selected" result: user_time: "Added on %{timestamp} by %{user}." result_asset: