diff --git a/app/components/types_de_champ_editor/add_champ_button_component.rb b/app/components/types_de_champ_editor/add_champ_button_component.rb index c9221b4a7..ad23aaf41 100644 --- a/app/components/types_de_champ_editor/add_champ_button_component.rb +++ b/app/components/types_de_champ_editor/add_champ_button_component.rb @@ -33,7 +33,7 @@ class TypesDeChampEditor::AddChampButtonComponent < ApplicationComponent libelle: champ_libelle, type_champ: TypeDeChamp.type_champs.fetch(:text), private: annotations? ? true : nil, - parent_id: @parent&.stable_id, + parent_stable_id: @parent&.stable_id, after_stable_id: '' }.compact } diff --git a/app/controllers/administrateurs/types_de_champ_controller.rb b/app/controllers/administrateurs/types_de_champ_controller.rb index ffbe6ac18..5a4127f03 100644 --- a/app/controllers/administrateurs/types_de_champ_controller.rb +++ b/app/controllers/administrateurs/types_de_champ_controller.rb @@ -55,7 +55,7 @@ module Administrateurs def type_de_champ_create_params params .required(:type_de_champ) - .permit(:type_champ, :parent_id, :private, :libelle, :after_stable_id) + .permit(:type_champ, :parent_stable_id, :private, :libelle, :after_stable_id) end def type_de_champ_update_params diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index ae44b3360..8d366ca8a 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -43,8 +43,7 @@ class ProcedureRevision < ApplicationRecord end def add_type_de_champ(params) - parent_stable_id = params.delete(:parent_id) - after_stable_id = params.delete(:after_id) + parent_stable_id = params.delete(:parent_stable_id) after_stable_id = params.delete(:after_stable_id) coordinate = {} diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index 8b57b1d13..7c8be9a92 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -78,7 +78,7 @@ describe Champ do procedure.active_revision.add_type_de_champ( libelle: 'header', type_champ: 'header_section', - parent_id: procedure.types_de_champ.find(&:repetition?).stable_id + parent_stable_id: procedure.types_de_champ.find(&:repetition?).stable_id ) end end @@ -524,7 +524,7 @@ describe Champ do let(:champ_text_attrs) { attributes_for(:champ_text, type_de_champ: tdc_text, row: 1) } before do - procedure.active_revision.add_type_de_champ(libelle: 'sub integer', type_champ: 'integer_number', parent_id: tdc_repetition.stable_id) + procedure.active_revision.add_type_de_champ(libelle: 'sub integer', type_champ: 'integer_number', parent_stable_id: tdc_repetition.stable_id) end context 'when creating the model directly' do diff --git a/spec/models/champs/header_section_champ_spec.rb b/spec/models/champs/header_section_champ_spec.rb index 1a823e4b0..a32602c4a 100644 --- a/spec/models/champs/header_section_champ_spec.rb +++ b/spec/models/champs/header_section_champ_spec.rb @@ -38,7 +38,7 @@ describe Champs::HeaderSectionChamp do revision.add_type_de_champ( libelle: tdc.libelle, type_champ: tdc.type_champ, - parent_id: tdc_repetition.stable_id + parent_stable_id: tdc_repetition.stable_id ) end end diff --git a/spec/models/concern/tags_substitution_concern_spec.rb b/spec/models/concern/tags_substitution_concern_spec.rb index be992abde..5b489c8b3 100644 --- a/spec/models/concern/tags_substitution_concern_spec.rb +++ b/spec/models/concern/tags_substitution_concern_spec.rb @@ -163,8 +163,8 @@ describe TagsSubstitutionConcern, type: :model do let(:template) { '--Répétition--' } let(:repetition) do repetition_tdc = procedure.active_revision.add_type_de_champ(type_champ: 'repetition', libelle: 'Répétition') - procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Nom', parent_id: repetition_tdc.stable_id) - procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Prénom', parent_id: repetition_tdc.stable_id) + procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Nom', parent_stable_id: repetition_tdc.stable_id) + procedure.active_revision.add_type_de_champ(type_champ: 'text', libelle: 'Prénom', parent_stable_id: repetition_tdc.stable_id) repetition_tdc end diff --git a/spec/models/dossier_rebase_concern_spec.rb b/spec/models/dossier_rebase_concern_spec.rb index 640ef84fd..1ddf4f535 100644 --- a/spec/models/dossier_rebase_concern_spec.rb +++ b/spec/models/dossier_rebase_concern_spec.rb @@ -182,7 +182,7 @@ describe Dossier do procedure.draft_revision.add_type_de_champ({ type_champ: TypeDeChamp.type_champs.fetch(:checkbox), libelle: "oui ou non", - parent_id: repetition_type_de_champ.stable_id + parent_stable_id: repetition_type_de_champ.stable_id }) procedure.draft_revision.remove_type_de_champ(yes_no_type_de_champ.stable_id) @@ -365,8 +365,8 @@ describe Dossier do let!(:procedure) do create(:procedure).tap do |p| repetition = p.draft_revision.add_type_de_champ(type_champ: :repetition, libelle: 'p1') - p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c1', parent_id: repetition.stable_id) - p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c2', parent_id: repetition.stable_id) + p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c1', parent_stable_id: repetition.stable_id) + p.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c2', parent_stable_id: repetition.stable_id) p.publish! end end @@ -377,7 +377,7 @@ describe Dossier do context 'when a child tdc is added in the middle' do before do - added_tdc = procedure.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c3', parent_id: repetition_stable_id) + added_tdc = procedure.draft_revision.add_type_de_champ(type_champ: :text, libelle: 'c3', parent_stable_id: repetition_stable_id) procedure.draft_revision.move_type_de_champ(added_tdc.stable_id, 1) end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 18108847f..9f528c3c7 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -1477,7 +1477,7 @@ describe Dossier do draft = proc_test.draft_revision tdc_repetition = draft.add_type_de_champ(type_champ: :repetition, libelle: "repetition") - draft.add_type_de_champ(type_champ: :communes, libelle: "communes", parent_id: tdc_repetition.stable_id) + draft.add_type_de_champ(type_champ: :communes, libelle: "communes", parent_stable_id: tdc_repetition.stable_id) dossier_test = create(:dossier, procedure: proc_test) repetition = proc_test.types_de_champ_for_procedure_presentation.repetition.first diff --git a/spec/models/procedure_revision_spec.rb b/spec/models/procedure_revision_spec.rb index 2ac3d6e69..7e01495da 100644 --- a/spec/models/procedure_revision_spec.rb +++ b/spec/models/procedure_revision_spec.rb @@ -34,7 +34,7 @@ describe ProcedureRevision do end context 'with a repetition child' do - let(:tdc_params) { text_params.merge(parent_id: type_de_champ_repetition.stable_id) } + let(:tdc_params) { text_params.merge(parent_stable_id: type_de_champ_repetition.stable_id) } it do expect { subject }.to change { draft.reload.types_de_champ.count }.from(4).to(5) @@ -93,7 +93,7 @@ describe ProcedureRevision do draft.add_type_de_champ({ type_champ: TypeDeChamp.type_champs.fetch(:text), libelle: "second child", - parent_id: type_de_champ_repetition.stable_id + parent_stable_id: type_de_champ_repetition.stable_id }) end @@ -101,7 +101,7 @@ describe ProcedureRevision do draft.add_type_de_champ({ type_champ: TypeDeChamp.type_champs.fetch(:text), libelle: "last child", - parent_id: type_de_champ_repetition.stable_id + parent_stable_id: type_de_champ_repetition.stable_id }) end @@ -159,7 +159,7 @@ describe ProcedureRevision do draft.add_type_de_champ({ type_champ: TypeDeChamp.type_champs.fetch(:text), libelle: "second child", - parent_id: type_de_champ_repetition.stable_id + parent_stable_id: type_de_champ_repetition.stable_id }) end @@ -167,7 +167,7 @@ describe ProcedureRevision do draft.add_type_de_champ({ type_champ: TypeDeChamp.type_champs.fetch(:text), libelle: "last child", - parent_id: type_de_champ_repetition.stable_id + parent_stable_id: type_de_champ_repetition.stable_id }) end