diff --git a/app/controllers/instructeurs/dossiers_controller.rb b/app/controllers/instructeurs/dossiers_controller.rb index a148e129a..1f9bc3dd9 100644 --- a/app/controllers/instructeurs/dossiers_controller.rb +++ b/app/controllers/instructeurs/dossiers_controller.rb @@ -244,8 +244,8 @@ module Instructeurs def champs_private_params params.require(:dossier).permit(champs_private_attributes: [ - :id, :primary_value, :secondary_value, :piece_justificative_file, :value, value: [], - champs_attributes: [:id, :_destroy, :value, :primary_value, :secondary_value, :piece_justificative_file, value: []] + :id, :primary_value, :secondary_value, :piece_justificative_file, :value_other, :external_id, :numero_allocataire, :code_postal, :departement, :code_departement, :value, value: [], + champs_attributes: [:id, :_destroy, :value, :primary_value, :secondary_value, :piece_justificative_file, :value_other, :external_id, :numero_allocataire, :code_postal, :departement, :code_departement, value: []] ]) end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 6ba476c78..0f0c33f1d 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -337,8 +337,8 @@ module Users def champs_params params.permit(dossier: { champs_attributes: [ - :id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, value: [], - champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, value: []] + :id, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, :departement, :code_departement, value: [], + champs_attributes: [:id, :_destroy, :value, :value_other, :external_id, :primary_value, :secondary_value, :numero_allocataire, :code_postal, :piece_justificative_file, :departement, :code_departement, value: []] ] }) end diff --git a/app/javascript/components/ComboCommunesSearch.jsx b/app/javascript/components/ComboCommunesSearch.jsx index b02c5070e..ae2b005ba 100644 --- a/app/javascript/components/ComboCommunesSearch.jsx +++ b/app/javascript/components/ComboCommunesSearch.jsx @@ -49,12 +49,31 @@ const [placeholderDepartement, placeholderCommune] = ]; function ComboCommunesSearch(params) { - const [departementCode, setDepartementCode] = useState(); + const hiddenDepartementFieldId = `${params.hiddenFieldId}:departement`; + const hiddenDepartementField = useMemo( + () => + document.querySelector(`input[data-attr="${hiddenDepartementFieldId}"]`), + [params.hiddenFieldId] + ); + const hiddenCodeDepartementField = useMemo( + () => + document.querySelector( + `input[data-attr="${params.hiddenFieldId}:code_departement"]` + ), + [params.hiddenFieldId] + ); const inputId = useMemo( () => document.querySelector(`input[data-uuid="${params.hiddenFieldId}"]`)?.id, [params.hiddenFieldId] ); + const [departementCode, setDepartementCode] = useState( + () => hiddenCodeDepartementField?.value + ); + const departementValue = useMemo( + () => hiddenDepartementField?.value, + [hiddenDepartementField] + ); const departementDescribedBy = `${inputId}_departement_notice`; const communeDescribedBy = `${inputId}_commune_notice`; @@ -68,12 +87,17 @@ function ComboCommunesSearch(params) {