Merge pull request #8950 from mfo/US/conditional-header-section

correctif(usager.depot-dossier): ETQ usager, les titres de section conditionnés sont visible meme si la condition n'est pas remplie
This commit is contained in:
LeSim 2023-04-24 09:09:17 +00:00 committed by GitHub
commit 29e9606b48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View file

@ -12,10 +12,11 @@ class EditableChamp::HeaderSectionComponent < ApplicationComponent
end
def header_section_classnames
class_names = ["fr-h#{level}"]
class_names << 'header-section' if @champ.dossier.auto_numbering_section_headers_for?(@champ)
class_names
class_names(
"fr-h#{level}": true,
'header-section': @champ.dossier.auto_numbering_section_headers_for?(@champ),
'hidden': !@champ.visible?
)
end
def tag_for_depth

View file

@ -1,2 +1,2 @@
= tag.send(tag_for_depth, class: header_section_classnames) do
= tag.send(tag_for_depth, class: header_section_classnames, id: @champ.input_group_id) do
= libelle

View file

@ -406,6 +406,7 @@ describe 'The user' do
types_de_champ_public: [
{ type: :integer_number, libelle: 'age', stable_id: age_stable_id },
{ type: :yes_no, libelle: 'permis de conduire', stable_id: permis_stable_id, condition: permis_condition },
{ type: :header_section, libelle: 'info voiture', condition: permis_condition },
{ type: :integer_number, libelle: 'tonnage', stable_id: tonnage_stable_id, condition: tonnage_condition },
{ type: :text, libelle: 'parking', condition: parking_condition }
])
@ -418,10 +419,12 @@ describe 'The user' do
expect(page).to have_css('label', text: 'age', visible: true)
expect(page).to have_no_css('label', text: 'permis de conduire', visible: true)
expect(page).to have_no_css('legend h2', text: 'info voiture', visible: true)
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
fill_in('age', with: '18')
expect(page).to have_css('label', text: 'permis de conduire', visible: true)
expect(page).to have_css('legend h2', text: 'info voiture', visible: true)
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
choose('Oui')