fix: give format to repetition

This commit is contained in:
simon lehericey 2024-11-12 18:15:40 +01:00 committed by mfo
parent e563d81b7e
commit db053d36c9
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
2 changed files with 6 additions and 6 deletions

View file

@ -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

View file

@ -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