fix: give format to repetition
This commit is contained in:
parent
e563d81b7e
commit
db053d36c9
2 changed files with 6 additions and 6 deletions
|
@ -40,11 +40,11 @@ class Champs::RepetitionChamp < Champ
|
||||||
self[attribute]
|
self[attribute]
|
||||||
end
|
end
|
||||||
|
|
||||||
def spreadsheet_columns(types_de_champ, export_template: nil)
|
def spreadsheet_columns(types_de_champ, export_template: nil, format:)
|
||||||
[
|
[
|
||||||
['Dossier ID', :dossier_id],
|
['Dossier ID', :dossier_id],
|
||||||
['Ligne', :index]
|
['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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ProcedureExportService
|
||||||
|
|
||||||
def to_xlsx
|
def to_xlsx
|
||||||
@dossiers = @dossiers.downloadable_sorted_batch
|
@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
|
# We recursively build multi page spreadsheet
|
||||||
io = tables.reduce(nil) do |package, table|
|
io = tables.reduce(nil) do |package, table|
|
||||||
|
@ -29,7 +29,7 @@ class ProcedureExportService
|
||||||
|
|
||||||
def to_ods
|
def to_ods
|
||||||
@dossiers = @dossiers.downloadable_sorted_batch
|
@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
|
# We recursively build multi page spreadsheet
|
||||||
io = StringIO.new(tables.reduce(nil) do |spreadsheet, table|
|
io = StringIO.new(tables.reduce(nil) do |spreadsheet, table|
|
||||||
|
@ -103,7 +103,7 @@ class ProcedureExportService
|
||||||
@avis ||= dossiers.flat_map(&:avis)
|
@avis ||= dossiers.flat_map(&:avis)
|
||||||
end
|
end
|
||||||
|
|
||||||
def champs_repetables_options
|
def champs_repetables_options(format:)
|
||||||
procedure
|
procedure
|
||||||
.all_revisions_types_de_champ
|
.all_revisions_types_de_champ
|
||||||
.repetition
|
.repetition
|
||||||
|
@ -115,7 +115,7 @@ class ProcedureExportService
|
||||||
{
|
{
|
||||||
sheet_name: type_de_champ_repetition.libelle_for_export,
|
sheet_name: type_de_champ_repetition.libelle_for_export,
|
||||||
instances: rows,
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue