tech(review): implement some pair review suggestions
This commit is contained in:
parent
e7eee7ba72
commit
69346ad41f
9 changed files with 17 additions and 17 deletions
|
@ -18,9 +18,9 @@ class TypesDeChampEditor::AddChampButtonComponent < ApplicationComponent
|
|||
|
||||
def button_title
|
||||
if annotations?
|
||||
"Ajouter une annotation"
|
||||
"Ajouter une annotation"
|
||||
else
|
||||
"Ajouter un champ"
|
||||
"Ajouter un champ"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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}"
|
||||
.position.flex.align-center= @coordinate.position.to_s
|
||||
.fr-btn.fr-btn--tertiary-no-outline.handle.fr-icon-drag-move-2-line{ title: "Déplacer le champ vers le haut ou vers le bas" }
|
||||
%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) }
|
||||
|
|
|
@ -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, "Déplacer le champ", for: describedby_id, class: 'flex align-center flex-no-shrink fr-mr-3w'
|
||||
= label_tag :target_stable_id, "Déplacer ce champ à la place de ", 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 }
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
%div{ id: block_id, data: { 'select-champ-position-template-target': 'template', turbo_force: :server } }
|
||||
%select
|
||||
%option{ disabled: :disabled } Selectionner une option
|
||||
- @coordinates.each do |coordinate|
|
||||
%option{ value: coordinate.stable_id }= "#{coordinate.position} #{coordinate.libelle}"
|
||||
|
|
|
@ -64,7 +64,7 @@ module Administrateurs
|
|||
def move_and_morph
|
||||
source_type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
|
||||
target_type_de_champ = draft.find_and_ensure_exclusive_use(params[:target_stable_id])
|
||||
@coordinate = @source_coordinate = draft.coordinate_for(source_type_de_champ)
|
||||
@coordinate = draft.coordinate_for(source_type_de_champ)
|
||||
from = @coordinate.position
|
||||
to = draft.coordinate_for(target_type_de_champ).position
|
||||
@coordinate = draft.move_type_de_champ(@coordinate.stable_id, to)
|
||||
|
|
|
@ -44,6 +44,7 @@ export class SelectChampPositionTemplateController extends ApplicationController
|
|||
.map((option) => {
|
||||
if (option.value == focusedSelectStableId) {
|
||||
option.setAttribute('selected', 'selected');
|
||||
option.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
|
||||
return option.outerHTML;
|
||||
|
|
|
@ -71,11 +71,11 @@ module SystemHelpers
|
|||
|
||||
# Add a new type de champ in the procedure editor
|
||||
def add_champ
|
||||
click_on 'Ajouter un champ'
|
||||
click_on 'Ajouter un champ'
|
||||
end
|
||||
|
||||
def remove_flash_message
|
||||
expect(page).to have_button('Ajouter un champ', disabled: false)
|
||||
expect(page).to have_button('Ajouter un champ', disabled: false)
|
||||
expect(page).to have_content('Formulaire enregistré')
|
||||
execute_script("document.querySelector('#flash_message').remove();")
|
||||
execute_script("document.querySelector('#autosave-notice').remove();")
|
||||
|
|
|
@ -8,7 +8,7 @@ describe 'As an administrateur I can edit annotation', js: true do
|
|||
end
|
||||
|
||||
scenario "adding a new champ" do
|
||||
click_on 'Ajouter une annotation'
|
||||
click_on 'Ajouter une annotation'
|
||||
|
||||
select('Carte', from: 'Type de champ')
|
||||
# ensure UI update is ok
|
||||
|
|
|
@ -38,7 +38,7 @@ describe 'As an administrateur I can edit types de champ', js: true do
|
|||
}
|
||||
|
||||
# Champs are automatically saved
|
||||
expect(page).to have_button('Ajouter un champ', disabled: false)
|
||||
expect(page).to have_button('Ajouter un champ', disabled: false)
|
||||
page.refresh
|
||||
expect(page).to have_selector('.type-de-champ', count: 3)
|
||||
|
||||
|
@ -111,7 +111,7 @@ describe 'As an administrateur I can edit types de champ', js: true do
|
|||
page.refresh
|
||||
|
||||
within '.type-de-champ .editor-block' do
|
||||
click_on 'Ajouter un champ'
|
||||
click_on 'Ajouter un champ'
|
||||
|
||||
fill_in 'Libellé du champ', with: 'libellé de champ 1'
|
||||
end
|
||||
|
@ -259,9 +259,9 @@ describe 'As an administrateur I can edit types de champ', js: true do
|
|||
scenario 'when select is focused, it seeds its options' do
|
||||
# once clicked, the select is updated with root champs options only, preselected on coordinates and have nice libelles
|
||||
page.find(initial_first_coordinate_selector).click
|
||||
expect(page).to have_selector("#{initial_first_coordinate_selector} option", count: 4)
|
||||
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(["Selectionner une option", '0 first_tdc', '1 middle_tdc', '2 last_tdc'])
|
||||
expect(page.find(initial_first_coordinate_selector).all("option").map(&:text)).to match_array(['0 first_tdc', '1 middle_tdc', '2 last_tdc'])
|
||||
|
||||
# renaming a tdc renames it's option
|
||||
within "##{dom_id(initial_first_coordinate, :type_de_champ_editor)}" do
|
||||
|
@ -269,7 +269,7 @@ describe 'As an administrateur I can edit types de champ', js: true do
|
|||
end
|
||||
wait_until { initial_first_coordinate.reload.libelle == 'renamed' }
|
||||
page.find(initial_first_coordinate_selector).click
|
||||
expect(page.find(initial_first_coordinate_selector).all("option").map(&:text)).to match_array(["Selectionner une option", '0 renamed', '1 middle_tdc', '2 last_tdc'])
|
||||
expect(page.find(initial_first_coordinate_selector).all("option").map(&:text)).to match_array(['0 renamed', '1 middle_tdc', '2 last_tdc'])
|
||||
end
|
||||
|
||||
scenario 'when select is changed, it move the coordinates' do
|
||||
|
@ -287,7 +287,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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -317,10 +317,10 @@ describe 'As an administrateur I can edit types de champ', js: true do
|
|||
|
||||
scenario 'when first child select is focused, seed with repetition only tdcs' do
|
||||
page.find(first_child_coordinate_selector).click
|
||||
expect(page).to have_selector("#{first_child_coordinate_selector} option", count: 3)
|
||||
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(["Selectionner une option"] + children_coordinates.map { "#{_1.position} #{_1.libelle}" })
|
||||
expect(opts).to match_array(children_coordinates.map { "#{_1.position} #{_1.libelle}" })
|
||||
end
|
||||
|
||||
scenario 'when first child select is changed, move champ in repetition' do
|
||||
|
|
Loading…
Reference in a new issue