fix(revisions): fix repetitions export with revisions
This commit is contained in:
parent
39c94992a7
commit
f6b8689a97
10 changed files with 78 additions and 57 deletions
|
@ -21,6 +21,7 @@
|
|||
#
|
||||
class Champs::RepetitionChamp < Champ
|
||||
accepts_nested_attributes_for :champs, allow_destroy: true
|
||||
delegate :libelle_for_export, to: :type_de_champ
|
||||
|
||||
def rows
|
||||
champs.group_by(&:row).values
|
||||
|
@ -57,13 +58,6 @@ class Champs::RepetitionChamp < Champ
|
|||
end
|
||||
end
|
||||
|
||||
# We have to truncate the label here as spreadsheets have a (30 char) limit on length.
|
||||
def libelle_for_export
|
||||
str = "(#{stable_id}) #{libelle}"
|
||||
# /\*?[] are invalid Excel worksheet characters
|
||||
ActiveStorage::Filename.new(str.delete('[]*?')).sanitized
|
||||
end
|
||||
|
||||
class Row < Hashie::Dash
|
||||
property :index
|
||||
property :dossier_id
|
||||
|
@ -73,19 +67,11 @@ class Champs::RepetitionChamp < Champ
|
|||
self[attribute]
|
||||
end
|
||||
|
||||
def spreadsheet_columns
|
||||
def spreadsheet_columns(types_de_champ)
|
||||
[
|
||||
['Dossier ID', :dossier_id],
|
||||
['Ligne', :index]
|
||||
] + exported_champs
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def exported_champs
|
||||
champs.reject(&:exclude_from_export?).map do |champ|
|
||||
[champ.libelle, champ.for_export]
|
||||
end
|
||||
] + Dossier.champs_for_export(champs, types_de_champ)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue