diff --git a/app/components/types_de_champ_editor/select_champ_position_component.rb b/app/components/types_de_champ_editor/select_champ_position_component.rb index d6f607ff8..22b06c806 100644 --- a/app/components/types_de_champ_editor/select_champ_position_component.rb +++ b/app/components/types_de_champ_editor/select_champ_position_component.rb @@ -5,7 +5,7 @@ class TypesDeChampEditor::SelectChampPositionComponent < ApplicationComponent end def options - [["Selectionner une option", @coordinate.stable_id]] + [["Sélectionner une option", @coordinate.stable_id]] end def describedby_id diff --git a/app/components/types_de_champ_editor/select_champ_position_component/select_champ_position_component.html.haml b/app/components/types_de_champ_editor/select_champ_position_component/select_champ_position_component.html.haml index 7561a63c3..c51b1d287 100644 --- a/app/components/types_de_champ_editor/select_champ_position_component/select_champ_position_component.html.haml +++ b/app/components/types_de_champ_editor/select_champ_position_component/select_champ_position_component.html.haml @@ -1,3 +1,3 @@ = form_with(url: move_and_morph_admin_procedure_type_de_champ_path(@coordinate.revision.procedure, @coordinate.type_de_champ.stable_id), class: 'fr-ml-3w flex', method: :patch, data: { turbo: true }) do |f| - = label_tag :target_stable_id, "Deplacer le champ après ", for: describedby_id, class: 'flex align-center flex-no-shrink fr-mr-3w' - = select_tag :target_stable_id, options_for_select(options), id: describedby_id, class: 'fr-select', aria: { discribedby: describedby_id }, data: { 'select-champ-position-template-target': 'select', selected: @coordinate.stable_id } + = label_tag :target_stable_id, "Déplacer le champ après ", for: describedby_id, class: 'flex align-center flex-no-shrink fr-mr-3w' + = select_tag :target_stable_id, options_for_select(options), id: describedby_id, class: 'fr-select', data: { 'select-champ-position-template-target': 'select', selected: @coordinate.stable_id } 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 023415677..2558d2ad5 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,7 @@ %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 + 1} #{coordinate.libelle}" + - if coordinate.type_de_champ.header_section? + %option{ value: coordinate.stable_id }= "----- #{coordinate.libelle} -----" + - else + %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 38900c2a9..8cbba47a7 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(['1 first_tdc', '2 middle_tdc', '3 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(['1 renamed', '2 middle_tdc', '3 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 @@ -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} #{_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