diff --git a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml index ac49bb0b9..8a8ad398a 100644 --- a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml +++ b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml @@ -1,7 +1,7 @@ %li.type-de-champ.flex.column.justify-start.fr-mb-6w{ html_options } .type-de-champ-container .flex.justify-between.section.head - .position.flex.align-center= @coordinate.position.to_s + .position.flex.align-center= (@coordinate.position + 1).to_s %button.fr-btn.fr-btn--tertiary-no-outline.fr-icon-arrow-up-line.move-up{ move_button_options(:up) } %button.fr-btn.fr-btn--tertiary-no-outline.fr-icon-arrow-down-line.move-down{ move_button_options(:down) } diff --git a/app/components/types_de_champ_editor/select_champ_template_position_component/select_champ_template_position_component.html.haml b/app/components/types_de_champ_editor/select_champ_template_position_component/select_champ_template_position_component.html.haml index e2f7ecc24..023415677 100644 --- a/app/components/types_de_champ_editor/select_champ_template_position_component/select_champ_template_position_component.html.haml +++ b/app/components/types_de_champ_editor/select_champ_template_position_component/select_champ_template_position_component.html.haml @@ -1,4 +1,4 @@ %div{ id: block_id, data: { 'select-champ-position-template-target': 'template', turbo_force: :server } } %select - @coordinates.each do |coordinate| - %option{ value: coordinate.stable_id }= "#{coordinate.position} #{coordinate.libelle}" + %option{ value: coordinate.stable_id }= "#{coordinate.position + 1} #{coordinate.libelle}" diff --git a/spec/system/administrateurs/types_de_champ_spec.rb b/spec/system/administrateurs/types_de_champ_spec.rb index ee25c259f..38900c2a9 100644 --- a/spec/system/administrateurs/types_de_champ_spec.rb +++ b/spec/system/administrateurs/types_de_champ_spec.rb @@ -261,7 +261,7 @@ describe 'As an administrateur I can edit types de champ', js: true do page.find(initial_first_coordinate_selector).click expect(page).to have_selector("#{initial_first_coordinate_selector} option", count: 3) expect(page.find(initial_first_coordinate_selector).find("option[selected]").value.to_s).to eq(initial_first_coordinate.stable_id.to_s) - expect(page.find(initial_first_coordinate_selector).all("option").map(&:text)).to match_array(['0 first_tdc', '1 middle_tdc', '2 last_tdc']) + expect(page.find(initial_first_coordinate_selector).all("option").map(&:text)).to match_array(['1 first_tdc', '2 middle_tdc', '3 last_tdc']) # renaming a tdc renames it's option within "##{dom_id(initial_first_coordinate, :type_de_champ_editor)}" do @@ -272,7 +272,7 @@ describe 'As an administrateur I can edit types de champ', js: true do expect(page).to have_text('Formulaire enregistré') page.find(initial_first_coordinate_selector).click expect(page).to have_css("#{initial_first_coordinate_selector} option", count: 3) - expect(page.find(initial_first_coordinate_selector).all("option").map(&:text)).to match_array(['0 renamed', '1 middle_tdc', '2 last_tdc']) + expect(page.find(initial_first_coordinate_selector).all("option").map(&:text)).to match_array(['1 renamed', '2 middle_tdc', '3 last_tdc']) end scenario 'when select is changed, it move the coordinates' do @@ -290,7 +290,7 @@ describe 'As an administrateur I can edit types de champ', js: true do # check reorder rerendered champ component between target->destination reordered_coordinates.map(&:reload).map do |coordinate| - expect(page).to have_selector("##{ActionView::RecordIdentifier.dom_id(coordinate, :type_de_champ_editor)} .position", text: coordinate.position) + expect(page).to have_selector("##{ActionView::RecordIdentifier.dom_id(coordinate, :type_de_champ_editor)} .position", text: coordinate.position + 1) end end end @@ -323,7 +323,7 @@ describe 'As an administrateur I can edit types de champ', js: true do expect(page).to have_selector("#{first_child_coordinate_selector} option", count: 2) opts = page.find(first_child_coordinate_selector).all("option").map(&:text) - expect(opts).to match_array(children_coordinates.map { "#{_1.position} #{_1.libelle}" }) + expect(opts).to match_array(children_coordinates.map { "#{_1.position + 1} #{_1.libelle}" }) end scenario 'when first child select is changed, move champ in repetition' do @@ -343,7 +343,7 @@ describe 'As an administrateur I can edit types de champ', js: true do # check reorder rerendered champ component between target->destination reordered_coordinates.map(&:reload).map do |coordinate| - expect(page).to have_selector("##{ActionView::RecordIdentifier.dom_id(coordinate, :type_de_champ_editor)} .position", text: coordinate.position) + expect(page).to have_selector("##{ActionView::RecordIdentifier.dom_id(coordinate, :type_de_champ_editor)} .position", text: coordinate.position + 1) end end end