commit
51e97b2d89
4 changed files with 22 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
= turbo_stream.remove @row_id
|
||||
= turbo_stream.remove "safe-row-selector-#{@row_id}"
|
||||
|
|
13
spec/controllers/champs/repetition_controller_spec.rb
Normal file
13
spec/controllers/champs/repetition_controller_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
describe Champs::RepetitionController, type: :controller do
|
||||
describe '#remove' do
|
||||
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :repetition, children: [{ libelle: 'Nom' }, { type: :integer_number, libelle: 'Age' }] }]) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
before { sign_in dossier.user }
|
||||
it 'removes repetition' do
|
||||
rows, repetitions = dossier.champs.partition { _1.parent_id.present? }
|
||||
expect { delete :remove, params: { champ_id: repetitions.first.id, row_id: rows.first.row_id }, format: :turbo_stream }
|
||||
.to change { dossier.reload.champs.size }.from(3).to(1)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -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' }]) }
|
||||
|
|
Loading…
Reference in a new issue