From a1abaa4ac2a610c2eedd4c9e51ed16c622dca667 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Tue, 15 Oct 2024 10:10:59 +0200 Subject: [PATCH 01/13] Replace span by div & tab-index by tabindex --- .../dropdown/menu_component/menu_component.html.haml | 2 +- app/views/invites/_dropdown.html.haml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/components/dropdown/menu_component/menu_component.html.haml b/app/components/dropdown/menu_component/menu_component.html.haml index b1a98d8bc..d580c563b 100644 --- a/app/components/dropdown/menu_component/menu_component.html.haml +++ b/app/components/dropdown/menu_component/menu_component.html.haml @@ -2,7 +2,7 @@ %button{ class: button_class_names, id: button_id, disabled: disabled?, data: data, "aria-expanded": "false", 'aria-haspopup': 'true', 'aria-controls': menu_id } = button_inner_html - %div{ data: { menu_button_target: 'menu' }, id: menu_id, 'aria-labelledby': button_id, role: menu_role, 'tab-index': -1, class: menu_class_names } + %div{ data: { menu_button_target: 'menu' }, id: menu_id, 'aria-labelledby': button_id, role: menu_role, 'tabindex': -1, class: menu_class_names } = menu_header_html -# the dropdown can be a menu with a list of item diff --git a/app/views/invites/_dropdown.html.haml b/app/views/invites/_dropdown.html.haml index 45a00864c..3d7de5a12 100644 --- a/app/views/invites/_dropdown.html.haml +++ b/app/views/invites/_dropdown.html.haml @@ -1,5 +1,6 @@ - invites = dossier.invites.load -= render Dropdown::MenuComponent.new(wrapper: :span, wrapper_options: {class: 'invite-user-action'}, button_options: { class: ['fr-btn--secondary'] }, menu_options: { id: 'invite-content' }) do |menu| += render Dropdown::MenuComponent.new(wrapper: :div, wrapper_options: {class: 'invite-user-action'}, button_options: { class: ['fr-btn--secondary'] }, menu_options: { id: 'invite-content' }) do |menu| + = 'lab' - menu.with_button_inner_html do = dsfr_icon('fr-icon-user-add-fill', :sm, :mr) - if invites.present? From b0b1cdbbeb2535e654d7f5f068201bd16f915ca3 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Tue, 15 Oct 2024 11:15:08 +0200 Subject: [PATCH 02/13] Remove duplicate id --- .../champ_label_content_component.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml index 09fdd72f9..ddbec2cf3 100644 --- a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml +++ b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml @@ -21,7 +21,7 @@ %span.fr-hint-text{ data: { controller: 'date-input-hint' } }= hint - if @champ.description.present? - %span.fr-hint-text{ id: @champ.describedby_id }= render SimpleFormatComponent.new(@champ.description, allow_a: true) + %span.fr-hint-text= render SimpleFormatComponent.new(@champ.description, allow_a: true) - if @champ.textarea? %span.sr-only= t('.recommended_size', size: @champ.character_limit_base) From d86673156f01b842a835dbec8f757c4901e8d5d3 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Tue, 15 Oct 2024 15:23:39 +0200 Subject: [PATCH 03/13] Specify current stage in title --- config/locales/metas.en.yml | 8 ++++---- config/locales/metas.fr.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/locales/metas.en.yml b/config/locales/metas.en.yml index a8533b1bf..fcec3b045 100644 --- a/config/locales/metas.en.yml +++ b/config/locales/metas.en.yml @@ -12,13 +12,13 @@ en: identite: title: "New file (%{procedure_label}) - Step 1: Identity" show: - title: "Summary · File nº %{number} (%{procedure_label})" + title: "Summary · File %{number} (%{procedure_label})" demande: - title: "Application · File nº %{number} (%{procedure_label})" + title: "Application · File %{number} (%{procedure_label})" messagerie: - title: "Mailbox · File nº %{number} (%{procedure_label})" + title: "Mailbox · File %{number} (%{procedure_label})" brouillon: - title: "Modification of draft nº %{number} (%{procedure_label})" + title: "File %{number} in draft (%{procedure_label}) - Step 2: Form" merci: title: "File submitted (%{procedure_label})" activate: diff --git a/config/locales/metas.fr.yml b/config/locales/metas.fr.yml index b8cc06caf..44f503cd4 100644 --- a/config/locales/metas.fr.yml +++ b/config/locales/metas.fr.yml @@ -12,13 +12,13 @@ fr: identite: title: "Nouveau dossier (%{procedure_label}) - Étape 1 : Identité" show: - title: "Résumé · Dossier nº %{number} (%{procedure_label})" + title: "Résumé · Dossier %{number} (%{procedure_label})" demande: - title: "Demande · Dossier nº %{number} (%{procedure_label})" + title: "Demande · Dossier %{number} (%{procedure_label})" messagerie: - title: "Messagerie · Dossier nº %{number} (%{procedure_label})" + title: "Messagerie · Dossier %{number} (%{procedure_label})" brouillon: - title: "Modification du brouillon nº %{number} (%{procedure_label})" + title: "Dossier %{number} en brouillon (%{procedure_label}) - Étape 2 : Formulaire" merci: title: "Dossier envoyé (%{procedure_label})" activate: From 48f1cd4a4a81125640cb5fcf0d1d2add129a7f37 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Tue, 15 Oct 2024 16:23:55 +0200 Subject: [PATCH 04/13] Enhance contrast of notification dot --- app/assets/stylesheets/notifications.scss | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/assets/stylesheets/notifications.scss b/app/assets/stylesheets/notifications.scss index fb3923cfc..7097b9368 100644 --- a/app/assets/stylesheets/notifications.scss +++ b/app/assets/stylesheets/notifications.scss @@ -1,11 +1,9 @@ -@import "colors"; - span.notifications { position: absolute; width: 8px; height: 8px; border-radius: 4px; - background-color: $orange; + background-color: var(--background-flat-warning); } .fr-tabs__list span.notifications { From 4e64eb1af5e3472566dfa6b0ba083d640f5efed2 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Tue, 15 Oct 2024 17:12:53 +0200 Subject: [PATCH 05/13] Hide pesudo-element content from assistive technologies --- app/assets/stylesheets/buttons.scss | 4 +--- .../batch_operation_component.html.haml | 1 + .../dropdown/menu_component/menu_component.html.haml | 1 + app/views/layouts/_header.haml | 2 +- public/500.html | 2 +- public/502.html | 2 +- public/503.html | 2 +- public/504.html | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/buttons.scss b/app/assets/stylesheets/buttons.scss index be434a232..1c60811ad 100644 --- a/app/assets/stylesheets/buttons.scss +++ b/app/assets/stylesheets/buttons.scss @@ -151,10 +151,8 @@ .dropdown-button { white-space: nowrap; - &::after { + [aria-hidden="true"].fr-ml-2v::after { content: "▾"; - margin-left: $default-spacer; - font-weight: bold; } &.icon-only { diff --git a/app/components/dossiers/batch_operation_component/batch_operation_component.html.haml b/app/components/dossiers/batch_operation_component/batch_operation_component.html.haml index f75cbc6da..c8357feca 100644 --- a/app/components/dossiers/batch_operation_component/batch_operation_component.html.haml +++ b/app/components/dossiers/batch_operation_component/batch_operation_component.html.haml @@ -13,6 +13,7 @@ -# Dropdown button title %button#batch_operation_others.fr-btn.fr-btn--sm.fr-btn--secondary.fr-ml-1w.dropdown-button{ disabled: true, data: { menu_button_target: 'button', batch_operation_target: 'dropdown' } } = t('.operations.other') + %span.fr-ml-2v{ 'aria-hidden': 'true' } #state-menu.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' }, "aria-labelledby" => "batch_operation_others" } %ul.dropdown-items diff --git a/app/components/dropdown/menu_component/menu_component.html.haml b/app/components/dropdown/menu_component/menu_component.html.haml index d580c563b..7b6f16b4f 100644 --- a/app/components/dropdown/menu_component/menu_component.html.haml +++ b/app/components/dropdown/menu_component/menu_component.html.haml @@ -1,6 +1,7 @@ = content_tag(@wrapper, wrapper_options) do %button{ class: button_class_names, id: button_id, disabled: disabled?, data: data, "aria-expanded": "false", 'aria-haspopup': 'true', 'aria-controls': menu_id } = button_inner_html + %span.fr-ml-2v{ 'aria-hidden': 'true' } %div{ data: { menu_button_target: 'menu' }, id: menu_id, 'aria-labelledby': button_id, role: menu_role, 'tabindex': -1, class: menu_class_names } = menu_header_html diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml index fda1d2b0c..d65475e72 100644 --- a/app/views/layouts/_header.haml +++ b/app/views/layouts/_header.haml @@ -53,7 +53,7 @@ = render partial: 'shared/help/help_dropdown_instructeur' - else -# NB: on mobile in order to have links correctly aligned, we need a left icon # - = link_to t('help'), t("links.common.faq.url"), class: 'fr-btn dropdown-button' + = link_to t('help'), t("links.common.faq.url"), class: 'fr-btn' diff --git a/public/500.html b/public/500.html index 2bb269345..0f25f7b6e 100644 --- a/public/500.html +++ b/public/500.html @@ -2109,7 +2109,7 @@
  • Aide diff --git a/public/502.html b/public/502.html index c26dea27f..1462bcfca 100644 --- a/public/502.html +++ b/public/502.html @@ -2108,7 +2108,7 @@
  • Aide diff --git a/public/503.html b/public/503.html index 896d3bd4c..592e9380c 100644 --- a/public/503.html +++ b/public/503.html @@ -2108,7 +2108,7 @@
  • Aide diff --git a/public/504.html b/public/504.html index f2265dc7a..196f24022 100644 --- a/public/504.html +++ b/public/504.html @@ -2108,7 +2108,7 @@
  • Aide From fd049f6025b6c6718b1d697843e2e3724ba00cc2 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Fri, 18 Oct 2024 16:45:40 +0200 Subject: [PATCH 06/13] Improve status message delivery to assistive technologies --- app/helpers/application_helper.rb | 9 +------ app/views/layouts/_flash_messages.html.haml | 30 +++++++++++++-------- spec/helpers/application_helper_spec.rb | 6 ++--- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a2f9c6029..0ca885593 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -36,16 +36,9 @@ module ApplicationHelper end end - def flash_class(level, sticky: false, fixed: false) + def flash_class(sticky: false, fixed: false) class_names = [] - case level - when 'notice' - class_names << 'alert-success' - when 'alert', 'error' - class_names << 'alert-danger' - end - if sticky class_names << 'sticky' end diff --git a/app/views/layouts/_flash_messages.html.haml b/app/views/layouts/_flash_messages.html.haml index b0a3e5d72..55dd13ac8 100644 --- a/app/views/layouts/_flash_messages.html.haml +++ b/app/views/layouts/_flash_messages.html.haml @@ -1,14 +1,22 @@ -#flash_messages{ aria: { live: 'assertive' } } - - if flash.any? - #flash_message.center +#flash_messages + #flash_message.center + - if flash.any? - flash.each do |key, value| - sticky = defined?(sticky) ? sticky : false - fixed = defined?(fixed) ? fixed : false - - if value.class == Array - .alert{ class: flash_class(key, sticky: sticky, fixed: fixed), role: flash_role(key) } - - value.each do |message| - = sanitize_with_link(message) - %br - - elsif value.present? - .alert{ class: flash_class(key, sticky: sticky, fixed: fixed), role: flash_role(key) } - = sanitize_with_link(value) + - if flash_role(key) == 'status' + .alert.alert-success{ role: 'status', class: flash_class(sticky: sticky, fixed: fixed), tabindex: '-1', data: { controller: 'autofocus' } } + - if value.class == Array + - value.each do |message| + = sanitize_with_link(message) + %br + - elsif value.present? + = sanitize_with_link(value) + - elsif flash_role(key) == 'alert' + .alert.alert-danger{ role: 'alert', class: flash_class(sticky: sticky, fixed: fixed), tabindex: '-1', data: { controller: 'autofocus' } } + - if value.class == Array + - value.each do |message| + = sanitize_with_link(message) + %br + - elsif value.present? + = sanitize_with_link(value) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 44416c4b8..6b70a8097 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -71,10 +71,8 @@ describe ApplicationHelper do end describe "#flash_class" do - it { expect(flash_class('notice')).to eq 'alert-success' } - it { expect(flash_class('alert', sticky: true, fixed: true)).to eq 'alert-danger sticky alert-fixed' } - it { expect(flash_class('error')).to eq 'alert-danger' } - it { expect(flash_class('unknown-level')).to eq '' } + it { expect(flash_class(sticky: true)).to eq 'sticky' } + it { expect(flash_class(fixed: true)).to eq 'alert-fixed' } end describe "#try_format_date" do From e21ebc75e17054d18884905a715719c81fa17c49 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Fri, 18 Oct 2024 17:06:03 +0200 Subject: [PATCH 07/13] Explain context of the 'revoke authorization' link to assistive technologies --- app/views/invites/_form.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml index 824d1b36b..8f3922f6f 100644 --- a/app/views/invites/_form.html.haml +++ b/app/views/invites/_form.html.haml @@ -4,13 +4,13 @@ %h5.fr-h6= t('views.invites.form.edit_dossier', count: invites.size) - if invites.present? - #invite-list{ morphing ? { tabindex: "-1" } : {} } + #invite-list %ul - - invites.each do |invite| + - invites.each_with_index do |invite, index| %li - = invite.email + %span{ :id => "invite_#{index}" }= invite.email %small{ 'data-turbo': 'true' } - = link_to t('views.invites.form.withdraw_permission'), invite_path(invite), data: { turbo_method: :delete, turbo_confirm: t('views.invites.form.want_to_withdraw_permission', email: invite.email) }, class: "fr-btn fr-btn--sm fr-btn--tertiary-no-outline" + = link_to t('views.invites.form.withdraw_permission'), invite_path(invite), data: { turbo_method: :delete, turbo_confirm: t('views.invites.form.want_to_withdraw_permission', email: invite.email) }, class: "fr-btn fr-btn--sm fr-btn--tertiary-no-outline", id: "link_#{index}", "aria-labelledby": "link_#{index} invite_#{index}" - if dossier.brouillon? %p= t('views.invites.form.submit_dossier_yourself') From 536160f83e94a2c42341a8a394f8327495be5a30 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Mon, 21 Oct 2024 11:35:18 +0200 Subject: [PATCH 08/13] Remove useless aria-live attribute --- .../input_status_message_component.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml b/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml index 305d2d07f..9edef67b1 100644 --- a/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml +++ b/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml @@ -1,4 +1,4 @@ -.fr-messages-group{ id: @describedby_id, aria: { live: :assertive } } +.fr-messages-group{ id: @describedby_id } - if @error_full_messages.size > 0 %p{ class: class_names('fr-message' => true, "fr-message--#{@errors_on_attribute ? 'error' : 'valid'}" => true) } = "« #{@champ.libelle} » " From c91d8698bda9ae55025c6445ad543f09c6d40519 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Mon, 21 Oct 2024 14:13:53 +0200 Subject: [PATCH 09/13] Remove useless note for screen readers --- .../champ_label_content_component.html.haml | 2 -- spec/system/users/brouillon_spec.rb | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml index ddbec2cf3..a6dc331f1 100644 --- a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml +++ b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.html.haml @@ -2,8 +2,6 @@ - if @champ.public? - if @champ.mandatory? = render EditableChamp::AsteriskMandatoryComponent.new - - else - %span.sr-only= t('.optional_champ') - if @champ.forked_with_changes? %span.updated-at.highlighted diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index ade916005..06eccfb32 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -442,7 +442,7 @@ describe 'The user', js: true do fill_individual - fill_in('age (facultatif)', with: 10) + fill_in('age', with: 10) click_on 'Déposer le dossier' expect(page).to have_current_path(merci_dossier_path(user_dossier)) end @@ -513,7 +513,7 @@ describe 'The user', js: true do fill_individual - fill_in('age (facultatif)', with: '18') + fill_in('age', with: '18') expect(page).to have_css('label', text: 'nom', visible: :visible) expect(page).to have_css('.icon.mandatory') click_on 'Déposer le dossier' @@ -550,7 +550,7 @@ describe 'The user', js: true do expect(page).to have_no_css('legend', text: 'info voiture', visible: true) expect(page).to have_no_css('label', text: 'tonnage', visible: true) - fill_in('age du candidat (facultatif)', with: '18') + fill_in('age du candidat', with: '18') expect(page).to have_css('legend', text: 'permis de conduire', visible: true) expect(page).to have_css('legend', text: 'info voiture', visible: true) expect(page).to have_no_css('label', text: 'tonnage', visible: true) @@ -563,10 +563,10 @@ describe 'The user', js: true do expect(page).to have_css('label', text: 'parking', visible: true) # try to fill with invalid data - fill_in('tonnage (facultatif)', with: 'a') + fill_in('tonnage', with: 'a') expect(page).to have_no_css('label', text: 'parking', visible: true) - fill_in('age du candidat (facultatif)', with: '2') + fill_in('age du candidat', with: '2') expect(page).to have_no_css('legend', text: 'permis de conduire', visible: true) expect(page).to have_no_css('label', text: 'tonnage', visible: true) @@ -578,7 +578,7 @@ describe 'The user', js: true do expect(page).to have_no_css('legend', text: 'permis de conduire', visible: true) expect(page).to have_no_css('label', text: 'tonnage', visible: true) - fill_in('age du candidat (facultatif)', with: '18') + fill_in('age du candidat', with: '18') wait_for_autosave # the champ keeps their previous value so they are all displayed From f3d0968da172e9716388b743c74a593b5b11764b Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Wed, 23 Oct 2024 14:57:55 +0200 Subject: [PATCH 10/13] Enable restitution of morphed messages --- app/views/layouts/_flash_messages.html.haml | 4 ++-- app/views/layouts/application.turbo_stream.haml | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/_flash_messages.html.haml b/app/views/layouts/_flash_messages.html.haml index 55dd13ac8..f8b280447 100644 --- a/app/views/layouts/_flash_messages.html.haml +++ b/app/views/layouts/_flash_messages.html.haml @@ -1,5 +1,5 @@ -#flash_messages - #flash_message.center +#flash_messages{ tabindex: '-1' } + #flash_message.center{ class: defined?(unique_classname) ? unique_classname : '' } - if flash.any? - flash.each do |key, value| - sticky = defined?(sticky) ? sticky : false diff --git a/app/views/layouts/application.turbo_stream.haml b/app/views/layouts/application.turbo_stream.haml index c359b707a..bb1d0ef95 100644 --- a/app/views/layouts/application.turbo_stream.haml +++ b/app/views/layouts/application.turbo_stream.haml @@ -1,7 +1,9 @@ - if flash.any? - = turbo_stream.replace 'flash_messages', partial: 'layouts/flash_messages' + - unique_classname= "u#{SecureRandom.hex}" + = turbo_stream.replace 'flash_messages', partial: 'layouts/flash_messages', locals: { unique_classname: } + = turbo_stream.focus 'flash_messages' = turbo_stream.show 'flash_messages' - = turbo_stream.hide 'flash_messages', delay: 30000 + = turbo_stream.hide_all ".#{unique_classname}", delay: 15000 - flash.clear = yield From dd362055dff125802d9c5adde3420a6feffed5a7 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Wed, 23 Oct 2024 14:58:21 +0200 Subject: [PATCH 11/13] Remove useless code --- spec/support/system_helpers.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb index e68926aed..7728cb875 100644 --- a/spec/support/system_helpers.rb +++ b/spec/support/system_helpers.rb @@ -76,13 +76,6 @@ module SystemHelpers click_on 'Ajouter un champ' end - def remove_flash_message - 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();") - end - def hide_autonotice_message expect(page).to have_text('Formulaire enregistré') execute_script("document.querySelector('#autosave-notice').classList.add('hidden');") From 84870615d8f38d951b78700c8a9784d38891d190 Mon Sep 17 00:00:00 2001 From: mfo Date: Wed, 23 Oct 2024 15:18:43 +0200 Subject: [PATCH 12/13] feat(flash_messages): dry up code and ensure turbo_force: :server otherwise morphing does not refresh page with new attrs --- app/helpers/application_helper.rb | 8 ++++++- app/views/layouts/_flash_messages.html.haml | 25 +++++++-------------- spec/helpers/application_helper_spec.rb | 6 +++-- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0ca885593..88a398cd7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -36,9 +36,15 @@ module ApplicationHelper end end - def flash_class(sticky: false, fixed: false) + def flash_class(level, sticky: false, fixed: false) class_names = [] + case level + when 'notice' + class_names << 'alert-success' + when 'alert', 'error' + class_names << 'alert-danger' + end if sticky class_names << 'sticky' end diff --git a/app/views/layouts/_flash_messages.html.haml b/app/views/layouts/_flash_messages.html.haml index f8b280447..d2e0eff4c 100644 --- a/app/views/layouts/_flash_messages.html.haml +++ b/app/views/layouts/_flash_messages.html.haml @@ -1,22 +1,13 @@ -#flash_messages{ tabindex: '-1' } +#flash_messages{ tabindex: '-1', data: { turbo_force: :server } } #flash_message.center{ class: defined?(unique_classname) ? unique_classname : '' } - if flash.any? - flash.each do |key, value| - sticky = defined?(sticky) ? sticky : false - fixed = defined?(fixed) ? fixed : false - - if flash_role(key) == 'status' - .alert.alert-success{ role: 'status', class: flash_class(sticky: sticky, fixed: fixed), tabindex: '-1', data: { controller: 'autofocus' } } - - if value.class == Array - - value.each do |message| - = sanitize_with_link(message) - %br - - elsif value.present? - = sanitize_with_link(value) - - elsif flash_role(key) == 'alert' - .alert.alert-danger{ role: 'alert', class: flash_class(sticky: sticky, fixed: fixed), tabindex: '-1', data: { controller: 'autofocus' } } - - if value.class == Array - - value.each do |message| - = sanitize_with_link(message) - %br - - elsif value.present? - = sanitize_with_link(value) + .alert{ role: flash_role(key), class: flash_class(key, sticky: sticky, fixed: fixed) } + - if value.class == Array + - value.each do |message| + = sanitize_with_link(message) + %br + - elsif value.present? + = sanitize_with_link(value) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 6b70a8097..44416c4b8 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -71,8 +71,10 @@ describe ApplicationHelper do end describe "#flash_class" do - it { expect(flash_class(sticky: true)).to eq 'sticky' } - it { expect(flash_class(fixed: true)).to eq 'alert-fixed' } + it { expect(flash_class('notice')).to eq 'alert-success' } + it { expect(flash_class('alert', sticky: true, fixed: true)).to eq 'alert-danger sticky alert-fixed' } + it { expect(flash_class('error')).to eq 'alert-danger' } + it { expect(flash_class('unknown-level')).to eq '' } end describe "#try_format_date" do From 2429f11d5c8aa2b927b4b437851cd659b1a542fe Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 10:39:36 +0100 Subject: [PATCH 13/13] fix(spec): fill_in(label) search by grep like, so if another label contains your label, you got an Ambiguous match --- spec/system/users/brouillon_spec.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index 06eccfb32..98c414e4b 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -428,7 +428,7 @@ describe 'The user', js: true do let(:procedure) do create(:procedure, :published, :for_individual, types_de_champ_public: [ - { type: :integer_number, libelle: 'age', mandatory: false, stable_id: }, + { type: :integer_number, libelle: 'UNIQ_LABEL', mandatory: false, stable_id: }, { type: :repetition, libelle: 'repetition', condition:, children: [ { type: :text, libelle: 'nom', mandatory: true } @@ -441,8 +441,7 @@ describe 'The user', js: true do log_in(user, procedure) fill_individual - - fill_in('age', with: 10) + fill_in('UNIQ_LABEL', with: 10) click_on 'Déposer le dossier' expect(page).to have_current_path(merci_dossier_path(user_dossier)) end @@ -494,7 +493,7 @@ describe 'The user', js: true do let(:procedure) do create(:procedure, :published, :for_individual, types_de_champ_public: [ - { type: :integer_number, libelle: 'age', mandatory: false, stable_id: }, + { type: :integer_number, libelle: 'UNIQ_LABEL', mandatory: false, stable_id: }, { type: :text, libelle: 'nom', mandatory: true, condition: } ]) end @@ -513,7 +512,7 @@ describe 'The user', js: true do fill_individual - fill_in('age', with: '18') + fill_in('UNIQ_LABEL', with: '18') expect(page).to have_css('label', text: 'nom', visible: :visible) expect(page).to have_css('.icon.mandatory') click_on 'Déposer le dossier'