From db053d36c9e115fcfd09f3496a4cdcfb5213f7f2 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 12 Nov 2024 18:15:40 +0100 Subject: [PATCH] fix: give format to repetition --- app/models/champs/repetition_champ.rb | 4 ++-- app/services/procedure_export_service.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/champs/repetition_champ.rb b/app/models/champs/repetition_champ.rb index f8e6dfe46..0e9e8ef64 100644 --- a/app/models/champs/repetition_champ.rb +++ b/app/models/champs/repetition_champ.rb @@ -40,11 +40,11 @@ class Champs::RepetitionChamp < Champ self[attribute] end - def spreadsheet_columns(types_de_champ, export_template: nil) + def spreadsheet_columns(types_de_champ, export_template: nil, format:) [ ['Dossier ID', :dossier_id], ['Ligne', :index] - ] + dossier.champ_values_for_export(types_de_champ, row_id:, export_template:) + ] + dossier.champ_values_for_export(types_de_champ, row_id:, export_template:, format:) end end end diff --git a/app/services/procedure_export_service.rb b/app/services/procedure_export_service.rb index 03b3281de..181352d5c 100644 --- a/app/services/procedure_export_service.rb +++ b/app/services/procedure_export_service.rb @@ -18,7 +18,7 @@ class ProcedureExportService def to_xlsx @dossiers = @dossiers.downloadable_sorted_batch - tables = [:dossiers, :etablissements, :avis] + champs_repetables_options + tables = [:dossiers, :etablissements, :avis] + champs_repetables_options(format: :xlsx) # We recursively build multi page spreadsheet io = tables.reduce(nil) do |package, table| @@ -29,7 +29,7 @@ class ProcedureExportService def to_ods @dossiers = @dossiers.downloadable_sorted_batch - tables = [:dossiers, :etablissements, :avis] + champs_repetables_options + tables = [:dossiers, :etablissements, :avis] + champs_repetables_options(format: :ods) # We recursively build multi page spreadsheet io = StringIO.new(tables.reduce(nil) do |spreadsheet, table| @@ -103,7 +103,7 @@ class ProcedureExportService @avis ||= dossiers.flat_map(&:avis) end - def champs_repetables_options + def champs_repetables_options(format:) procedure .all_revisions_types_de_champ .repetition @@ -115,7 +115,7 @@ class ProcedureExportService { sheet_name: type_de_champ_repetition.libelle_for_export, instances: rows, - spreadsheet_columns: Proc.new { |instance| instance.spreadsheet_columns(types_de_champ, export_template: @export_template) } + spreadsheet_columns: Proc.new { |instance| instance.spreadsheet_columns(types_de_champ, export_template: @export_template, format:) } } end end