Include in exports types_de_champ from all revisions
This commit is contained in:
parent
8a2ae9d852
commit
1bd59c72e5
6 changed files with 117 additions and 27 deletions
|
@ -649,19 +649,19 @@ class Dossier < ApplicationRecord
|
|||
log_dossier_operation(avis.claimant, :demander_un_avis, avis)
|
||||
end
|
||||
|
||||
def spreadsheet_columns_csv
|
||||
spreadsheet_columns(with_etablissement: true)
|
||||
def spreadsheet_columns_csv(types_de_champ:, types_de_champ_private:)
|
||||
spreadsheet_columns(with_etablissement: true, types_de_champ: types_de_champ, types_de_champ_private: types_de_champ_private)
|
||||
end
|
||||
|
||||
def spreadsheet_columns_xlsx
|
||||
spreadsheet_columns
|
||||
def spreadsheet_columns_xlsx(types_de_champ:, types_de_champ_private:)
|
||||
spreadsheet_columns(types_de_champ: types_de_champ, types_de_champ_private: types_de_champ_private)
|
||||
end
|
||||
|
||||
def spreadsheet_columns_ods
|
||||
spreadsheet_columns
|
||||
def spreadsheet_columns_ods(types_de_champ:, types_de_champ_private:)
|
||||
spreadsheet_columns(types_de_champ: types_de_champ, types_de_champ_private: types_de_champ_private)
|
||||
end
|
||||
|
||||
def spreadsheet_columns(with_etablissement: false)
|
||||
def spreadsheet_columns(with_etablissement: false, types_de_champ:, types_de_champ_private:)
|
||||
columns = [
|
||||
['ID', id.to_s],
|
||||
['Email', user.email]
|
||||
|
@ -728,18 +728,34 @@ class Dossier < ApplicationRecord
|
|||
columns << ['Groupe instructeur', groupe_instructeur.label]
|
||||
end
|
||||
|
||||
columns + champs_for_export + annotations_for_export
|
||||
columns + champs_for_export(types_de_champ) + champs_private_for_export(types_de_champ_private)
|
||||
end
|
||||
|
||||
def champs_for_export
|
||||
champs.reject(&:exclude_from_export?).map do |champ|
|
||||
[champ.libelle, champ.for_export]
|
||||
def champs_for_export(types_de_champ)
|
||||
# Index values by stable_id
|
||||
values = champs.reject(&:exclude_from_export?).reduce({}) do |champs, champ|
|
||||
champs[champ.stable_id] = champ.for_export
|
||||
champs
|
||||
end
|
||||
|
||||
# Get all the champs values for the types de champ in the final list.
|
||||
# Dossier might not have corresponding champ – display nil.
|
||||
types_de_champ.map do |type_de_champ|
|
||||
[type_de_champ.libelle, values[type_de_champ.stable_id]]
|
||||
end
|
||||
end
|
||||
|
||||
def annotations_for_export
|
||||
champs_private.reject(&:exclude_from_export?).map do |champ|
|
||||
[champ.libelle, champ.for_export]
|
||||
def champs_private_for_export(types_de_champ)
|
||||
# Index values by stable_id
|
||||
values = champs_private.reject(&:exclude_from_export?).reduce({}) do |champs, champ|
|
||||
champs[champ.stable_id] = champ.for_export
|
||||
champs
|
||||
end
|
||||
|
||||
# Get all the champs values for the types de champ in the final list.
|
||||
# Dossier might not have corresponding champ – display nil.
|
||||
types_de_champ.map do |type_de_champ|
|
||||
[type_de_champ.libelle, values[type_de_champ.stable_id]]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue