Merge pull request #10255 from demarches-simplifiees/fix-move-after-edit-list
ETQ Administrateur : Amélioration de l'accessibilité et de l'ergonomie de la liste d'édition du formulaire "déplacer après"
This commit is contained in:
commit
ce95fe1794
4 changed files with 10 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue