diff --git a/app/components/types_de_champ_editor/block_component/block_component.html.haml b/app/components/types_de_champ_editor/block_component/block_component.html.haml index 770b4767162..388cbf6ffd9 100644 --- a/app/components/types_de_champ_editor/block_component/block_component.html.haml +++ b/app/components/types_de_champ_editor/block_component/block_component.html.haml @@ -1,3 +1,3 @@ %ul.types-de-champ-block{ id: block_id, data: sortable_options } - - @coordinates.each.with_index do |coordinate, i| - = render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, upper_coordinates: @upper_coordinates + @coordinates.take(i)) + - @coordinates.each do |coordinate| + = render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, upper_coordinates: coordinate.upper_coordinates) diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index 019d21972b3..dcb9b537af3 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -383,6 +383,11 @@ def annotations revision: [], procedure: [] }, + revision_types_de_champ_public: { + type_de_champ: { piece_justificative_template_attachment: :blob, revision: [], procedure: [] }, + revision: [], + procedure: [] + }, procedure: [] }).find(@procedure.id) end diff --git a/app/models/procedure_revision_type_de_champ.rb b/app/models/procedure_revision_type_de_champ.rb index 8953adc0d0a..c4842da20d3 100644 --- a/app/models/procedure_revision_type_de_champ.rb +++ b/app/models/procedure_revision_type_de_champ.rb @@ -46,6 +46,10 @@ def upper_coordinates upper += parent.upper_coordinates end + if type_de_champ.private? + upper += revision.revision_types_de_champ_public + end + upper end diff --git a/spec/models/procedure_revision_type_de_champ_spec.rb b/spec/models/procedure_revision_type_de_champ_spec.rb index 8759aa57e18..448f954cc6c 100644 --- a/spec/models/procedure_revision_type_de_champ_spec.rb +++ b/spec/models/procedure_revision_type_de_champ_spec.rb @@ -23,5 +23,33 @@ it { expect(l2_2.upper_coordinates.map(&:libelle)).to match_array(["l1", "l2.1"]) } end + + context 'when the coordinate is an annotation' do + let(:procedure) do + create(:procedure, + types_de_champ_private: [ + { libelle: 'a1' }, + { libelle: 'a2' } + ], + types_de_champ_public: [ + { libelle: 'l1' }, + { + type: :repetition, libelle: 'l2', children: [ + { libelle: 'l2.1' }, + { libelle: 'l2.2' } + ] + } + ]) + end + + let(:a2) do + procedure + .draft_revision + .revision_types_de_champ.joins(:type_de_champ) + .find_by(type_de_champ: { libelle: 'a2' }) + end + + it { expect(a2.upper_coordinates.map(&:libelle)).to match_array(["l1", "l2", "a1"]) } + end end end