From fbb7bd7989628a2f5013a76b9204725d098d1423 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Thu, 3 Oct 2024 14:50:37 +0200 Subject: [PATCH 1/3] Adds title before error list & remove useless link --- .../errors_full_messages_component.en.yml | 14 ++++++++++---- .../errors_full_messages_component.fr.yml | 14 ++++++++++---- .../errors_full_messages_component.html.haml | 3 ++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.en.yml b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.en.yml index 0a595e80a..99235b8b1 100644 --- a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.en.yml +++ b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.en.yml @@ -1,7 +1,13 @@ --- en: sumup_html: - one: | - Your file has 1 error. Fix-it to continue : - other: | - Your file has %{count} errors. Fix-them to continue : + title: + one: | + Your file has 1 error + other: | + Your file has %{count} errors + content: + one: | + Fix-it to continue: + other: | + Fix-them to continue: diff --git a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.fr.yml b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.fr.yml index 3d94f636f..8ed2c3f63 100644 --- a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.fr.yml +++ b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.fr.yml @@ -1,7 +1,13 @@ --- fr: sumup_html: - one: | - Votre dossier contient 1 champ en erreur. Corrigez-la pour poursuivre : - other: | - Votre dossier contient %{count} champs en erreurs. Corrigez-les pour poursuivre : + title: + one: | + Votre dossier contient 1 champ en erreur + other: | + Votre dossier contient %{count} champs en erreur + content: + one: | + Corrigez-la pour poursuivre : + other: | + Corrigez-les pour poursuivre : diff --git a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml index ada4150b5..4b0245804 100644 --- a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml +++ b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml @@ -1,4 +1,5 @@ .fr-alert.fr-alert--error.fr-mb-3w{ role: "alertdialog" } - if dedup_and_partitioned_errors.size > 0 - %p#sumup-errors= t('.sumup_html', count: dedup_and_partitioned_errors.size, url: dedup_and_partitioned_errors.first.anchor) + %h3#sumup-errors.fr-alert__title= t('.sumup_html.title', count: dedup_and_partitioned_errors.size) + %p= t('.sumup_html.content', count: dedup_and_partitioned_errors.size) = render ExpandableErrorList.new(errors: dedup_and_partitioned_errors) From 8ca1f82b0126711b96bed31152279f5f8f180dc3 Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Fri, 4 Oct 2024 10:26:18 +0200 Subject: [PATCH 2/3] Place focus on error block on page reload --- .../errors_full_messages_component.html.haml | 5 +++-- app/javascript/controllers/autofocus_controller.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml index 4b0245804..b28de1de3 100644 --- a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml +++ b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml @@ -1,5 +1,6 @@ -.fr-alert.fr-alert--error.fr-mb-3w{ role: "alertdialog" } +.fr-alert.fr-alert--error.fr-mb-3w{ role: 'alert' } - if dedup_and_partitioned_errors.size > 0 - %h3#sumup-errors.fr-alert__title= t('.sumup_html.title', count: dedup_and_partitioned_errors.size) + %h3#sumup-errors.fr-alert__title{ data: { controller: 'autofocus' }, tabindex: '-1' } + = t('.sumup_html.title', count: dedup_and_partitioned_errors.size) %p= t('.sumup_html.content', count: dedup_and_partitioned_errors.size) = render ExpandableErrorList.new(errors: dedup_and_partitioned_errors) diff --git a/app/javascript/controllers/autofocus_controller.ts b/app/javascript/controllers/autofocus_controller.ts index 289185948..72b5198ad 100644 --- a/app/javascript/controllers/autofocus_controller.ts +++ b/app/javascript/controllers/autofocus_controller.ts @@ -2,8 +2,10 @@ import { Controller } from '@hotwired/stimulus'; export class AutofocusController extends Controller { connect() { - const element = this.element as HTMLInputElement; + const element = this.element as HTMLInputElement | HTMLElement; element.focus(); - element.setSelectionRange(0, element.value.length); + if ('value' in element) { + element.setSelectionRange(0, element.value.length); + } } } From 89d31ddf113b788c43ca65e53f16be9d679e3a8a Mon Sep 17 00:00:00 2001 From: Corinne Durrmeyer Date: Mon, 14 Oct 2024 14:44:42 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Improve=20rendering=20of=20=E2=80=9Cn=C2=B0?= =?UTF-8?q?=E2=80=9D=20by=20assistive=20technologies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../errors_full_messages_component.html.haml | 1 + app/views/shared/dossiers/_header.html.haml | 2 +- app/views/users/dossiers/show/_header.html.haml | 2 +- config/locales/en.yml | 2 +- config/locales/fr.yml | 2 +- spec/views/users/dossiers/demande.html.haml_spec.rb | 2 +- spec/views/users/dossiers/show.html.haml_spec.rb | 2 +- spec/views/users/dossiers/show/_header.html.haml_spec.rb | 6 +++--- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml index b28de1de3..01ffd40bf 100644 --- a/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml +++ b/app/components/dossiers/errors_full_messages_component/errors_full_messages_component.html.haml @@ -1,4 +1,5 @@ .fr-alert.fr-alert--error.fr-mb-3w{ role: 'alert' } + - if dedup_and_partitioned_errors.size > 0 %h3#sumup-errors.fr-alert__title{ data: { controller: 'autofocus' }, tabindex: '-1' } = t('.sumup_html.title', count: dedup_and_partitioned_errors.size) diff --git a/app/views/shared/dossiers/_header.html.haml b/app/views/shared/dossiers/_header.html.haml index c162b080d..5a93fc5b4 100644 --- a/app/views/shared/dossiers/_header.html.haml +++ b/app/views/shared/dossiers/_header.html.haml @@ -2,7 +2,7 @@ = procedure_libelle(dossier.procedure) = status_badge_user(dossier, 'super') %h2 - = t('views.users.dossiers.show.header.dossier_number', dossier_id: dossier.id) + = t('views.users.dossiers.show.header.dossier_number_html', dossier_id: dossier.id) = t('views.users.dossiers.show.header.created_date', date_du_dossier: I18n.l(dossier.created_at)) = render(partial: 'users/dossiers/expiration_banner', locals: {dossier: dossier}) diff --git a/app/views/users/dossiers/show/_header.html.haml b/app/views/users/dossiers/show/_header.html.haml index 76d30870f..167029020 100644 --- a/app/views/users/dossiers/show/_header.html.haml +++ b/app/views/users/dossiers/show/_header.html.haml @@ -5,7 +5,7 @@ = status_badge_user(dossier, 'super') = pending_correction_badge(:for_user) if dossier.pending_correction? %h2 - = t('views.users.dossiers.show.header.dossier_number', dossier_id: dossier.id) + = t('views.users.dossiers.show.header.dossier_number_html', dossier_id: dossier.id) - if dossier.depose_at.present? = t('views.users.dossiers.show.header.submit_date', date_du_dossier: I18n.l(dossier.depose_at)) diff --git a/config/locales/en.yml b/config/locales/en.yml index ffebb947e..0a7bf8a67 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -461,7 +461,7 @@ en: summary: "Summary" request: "Request" mailbox: "Mailbox" - dossier_number: "File n. %{dossier_id}" + dossier_number_html: "File number  %{dossier_id}" created_date: "- Draft on %{date_du_dossier}" submit_date: "- Submit on %{date_du_dossier}" status_overview: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b8b280bbd..1d512a13f 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -464,7 +464,7 @@ fr: summary: "Résumé" request: "Demande" mailbox: "Messagerie" - dossier_number: "Dossier nº %{dossier_id}" + dossier_number_html: "Dossier numéro  %{dossier_id}" created_date: "- En brouillon depuis le %{date_du_dossier}" submit_date: "- Déposé le %{date_du_dossier}" status_overview: diff --git a/spec/views/users/dossiers/demande.html.haml_spec.rb b/spec/views/users/dossiers/demande.html.haml_spec.rb index c0cf8ae36..c0a61176b 100644 --- a/spec/views/users/dossiers/demande.html.haml_spec.rb +++ b/spec/views/users/dossiers/demande.html.haml_spec.rb @@ -12,7 +12,7 @@ describe 'users/dossiers/demande', type: :view do subject! { render } it 'renders the header' do - expect(rendered).to have_text("Dossier nº #{dossier.id}") + expect(rendered).to have_text("Dossier numéro nº #{dossier.id}") end it 'renders the dossier infos' do diff --git a/spec/views/users/dossiers/show.html.haml_spec.rb b/spec/views/users/dossiers/show.html.haml_spec.rb index 7f947db25..84d2bc475 100644 --- a/spec/views/users/dossiers/show.html.haml_spec.rb +++ b/spec/views/users/dossiers/show.html.haml_spec.rb @@ -11,7 +11,7 @@ describe 'users/dossiers/show', type: :view do subject! { render } it 'renders a summary of the dossier state' do - expect(rendered).to have_text("Dossier nº #{dossier.id}") + expect(rendered).to have_text("Dossier numéro nº #{dossier.id}") expect(rendered).to have_text('dossier est en construction') end diff --git a/spec/views/users/dossiers/show/_header.html.haml_spec.rb b/spec/views/users/dossiers/show/_header.html.haml_spec.rb index 2b41319fb..b759aace6 100644 --- a/spec/views/users/dossiers/show/_header.html.haml_spec.rb +++ b/spec/views/users/dossiers/show/_header.html.haml_spec.rb @@ -12,7 +12,7 @@ describe 'users/dossiers/show/header', type: :view do it 'affiche les informations du dossier' do expect(rendered).to have_text(dossier.procedure.libelle) - expect(rendered).to have_text("Dossier nº #{dossier.id}") + expect(rendered).to have_text("Dossier numéro nº #{dossier.id}") expect(rendered).to have_text("en construction") expect(rendered).to have_selector("nav.fr-tabs") @@ -25,7 +25,7 @@ describe 'users/dossiers/show/header', type: :view do let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } it "affiche les informations du dossier" do - expect(rendered).to have_text("Dossier nº #{dossier.id}") + expect(rendered).to have_text("Dossier numéro nº #{dossier.id}") expect(rendered).to have_text("en construction") end end @@ -35,7 +35,7 @@ describe 'users/dossiers/show/header', type: :view do let(:dossier) { create(:dossier, :accepte, procedure: procedure) } it "n'affiche pas les informations de décision" do - expect(rendered).to have_text("Dossier nº #{dossier.id}") + expect(rendered).to have_text("Dossier numéro nº #{dossier.id}") expect(rendered).to have_text("traité") end end