chore(dossier): cleanup champs nested attributes

This commit is contained in:
Paul Chavard 2022-11-15 14:31:29 +01:00
parent c90db00e5b
commit 53eb3e6ad0
2 changed files with 2 additions and 12 deletions

View file

@ -394,11 +394,6 @@ module Users
champs_public_attributes: [ champs_public_attributes: [
:id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: [], :id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: [],
champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: []] champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: []]
],
# FIXME: remove after migration
champs_attributes: [
:id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: [],
champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :identifiant, :numero_fiscal, :reference_avis, :ine, :piece_justificative_file, :departement, :code_departement, value: []]
] ]
}) })
end end
@ -457,12 +452,7 @@ module Users
errors = [] errors = []
if champs_params[:dossier] if champs_params[:dossier]
# FIXME: remove after migration @dossier.assign_attributes(champs_params[:dossier])
dossier_params = champs_params[:dossier]
if dossier_params.key?(:champs_attributes)
dossier_params[:champs_public_attributes] = dossier_params.delete(:champs_attributes)
end
@dossier.assign_attributes(dossier_params)
# FIXME: in some cases a removed repetition bloc row is submitted. # FIXME: in some cases a removed repetition bloc row is submitted.
# In this case it will be treated as a new record, and the action will fail. # In this case it will be treated as a new record, and the action will fail.
@dossier.champs_public.filter(&:block?).each do |champ| @dossier.champs_public.filter(&:block?).each do |champ|

View file

@ -20,7 +20,7 @@
# type_de_champ_id :integer # type_de_champ_id :integer
# #
class Champs::RepetitionChamp < Champ class Champs::RepetitionChamp < Champ
accepts_nested_attributes_for :champs, allow_destroy: true accepts_nested_attributes_for :champs
delegate :libelle_for_export, to: :type_de_champ delegate :libelle_for_export, to: :type_de_champ
def rows def rows