correctif(champs/repetitions#remove): les row id etant des ulid commence par un int. utiliser l'ulid comme selecteur css n'est pas valide. il faut donc avoir un selecteur CSS 'safe', et envoyer le row_id

This commit is contained in:
Martin 2023-01-19 10:48:01 +01:00
parent f59354f787
commit 8528939b75
3 changed files with 9 additions and 8 deletions

View file

@ -1,9 +1,9 @@
- row_id = "row-#{@row.first.row_id}"
- row_id = "safe-row-selector-#{@row.first.row_id}"
.row{ id: row_id }
- @row.each do |champ|
= fields_for champ.input_name, champ do |form|
= render EditableChamp::EditableChampComponent.new form: form, champ: champ, seen_at: @seen_at
.flex.row-reverse{ 'data-turbo': 'true' }
= link_to champs_repetition_path(@champ.id, row_id:), data: { turbo_method: :delete }, class: 'fr-btn fr-btn--sm fr-btn--tertiary fr-text-action-high--red-marianne' do
= link_to champs_repetition_path(@champ.id, row_id: @row.first.row_id), data: { turbo_method: :delete }, class: 'fr-btn fr-btn--sm fr-btn--tertiary fr-text-action-high--red-marianne' do
Supprimer lélément

View file

@ -1 +1 @@
= turbo_stream.remove @row_id
= turbo_stream.remove "safe-row-selector-#{@row_id}"

View file

@ -123,11 +123,12 @@ describe 'The user' do
expect(page).to have_content('Supprimer', count: 2)
within '.repetition .row:first-child' do
click_on 'Supprimer lélément'
end
expect(page).to have_content('Supprimer', count: 1)
expect do
within '.repetition .row:first-child' do
click_on 'Supprimer lélément'
end
expect(page).to have_content('Supprimer', count: 1)
end.to change { Champ.count }
end
let(:simple_procedure) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ mandatory: true, libelle: 'texte obligatoire' }, { mandatory: false, libelle: 'texte optionnel' }]) }