From bc7a79f150e3253b90b34f9b2934154ef0b4c0b5 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 11 May 2023 09:57:42 +0200 Subject: [PATCH 1/4] fix(admin): typo in character limit option --- .../champ_component/champ_component.fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/types_de_champ_editor/champ_component/champ_component.fr.yml b/app/components/types_de_champ_editor/champ_component/champ_component.fr.yml index a37f69652..bdee6be20 100644 --- a/app/components/types_de_champ_editor/champ_component/champ_component.fr.yml +++ b/app/components/types_de_champ_editor/champ_component/champ_component.fr.yml @@ -11,5 +11,5 @@ fr: zones_humides: Zones humides d’importance internationale znieff: ZNIEFF character_limit: - unlimited: Pas de limite de charactères + unlimited: Pas de limite de caractère limit: Limité à %{limit} caractères From 36331f71a452df6a880951483462dfa907720c2e Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 12 May 2023 10:03:13 +0200 Subject: [PATCH 2/4] wording --- app/components/types_de_champ_editor/champ_component.rb | 8 ++++---- .../champ_component/champ_component.html.haml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/types_de_champ_editor/champ_component.rb b/app/components/types_de_champ_editor/champ_component.rb index 1b1296126..2ee7c9e6a 100644 --- a/app/components/types_de_champ_editor/champ_component.rb +++ b/app/components/types_de_champ_editor/champ_component.rb @@ -125,10 +125,10 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent def options_for_character_limit [ [t('.character_limit.unlimited'), nil], - [t('.character_limit.limit', limit: 400), 400], - [t('.character_limit.limit', limit: 1000), 1000], - [t('.character_limit.limit', limit: 5000), 5000], - [t('.character_limit.limit', limit: 10000), 10000] + [t('.character_limit.limit', limit: '400'), 400], + [t('.character_limit.limit', limit: '1 000'), 1000], + [t('.character_limit.limit', limit: '5 000'), 5000], + [t('.character_limit.limit', limit: '10 000'), 10000] ] end end diff --git a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml index 665c80759..206243564 100644 --- a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml +++ b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml @@ -104,7 +104,7 @@ - if type_de_champ.textarea? .cell = form.label :character_limit, for: dom_id(type_de_champ, :character_limit) do - Spécifier un nombre maximal de caractères (non restrictif) : + Spécifier un nombre maximal conseillé de caractères : = form.select :character_limit, options_for_character_limit, id: dom_id(type_de_champ, :character_limit) - if type_de_champ.block? From 7b17bfe0a1e33549c105b4809467c63980b49e4f Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 12 May 2023 10:03:54 +0200 Subject: [PATCH 3/4] feat: add info for screen reader --- .../textarea_component/textarea_component.en.yml | 1 + .../textarea_component/textarea_component.fr.yml | 3 ++- .../textarea_component/textarea_component.html.haml | 2 ++ app/models/champs/textarea_champ.rb | 8 ++++---- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/components/editable_champ/textarea_component/textarea_component.en.yml b/app/components/editable_champ/textarea_component/textarea_component.en.yml index 8e9b49901..18b61d2a0 100644 --- a/app/components/editable_champ/textarea_component/textarea_component.en.yml +++ b/app/components/editable_champ/textarea_component/textarea_component.en.yml @@ -1,3 +1,4 @@ en: remaining_characters: You have %{remaining_words} characters remaining. excess_characters: You have %{excess_words} characters too many. + recommended_size: The recommended maximum size is %{size} characters. diff --git a/app/components/editable_champ/textarea_component/textarea_component.fr.yml b/app/components/editable_champ/textarea_component/textarea_component.fr.yml index ca85e677e..ed78a7998 100644 --- a/app/components/editable_champ/textarea_component/textarea_component.fr.yml +++ b/app/components/editable_champ/textarea_component/textarea_component.fr.yml @@ -1,3 +1,4 @@ fr: remaining_characters: Il vous reste %{remaining_words} caractères. - excess_characters: Vous avez dépassé la taille conseillée de %{excess_words} caractères. + excess_characters: Vous avez dépassé la taille conseillée de %{excess_words} caractères. Réduire le nombre de caractère. + recommended_size: La taille maximale conseillée est de %{size} caractères. diff --git a/app/components/editable_champ/textarea_component/textarea_component.html.haml b/app/components/editable_champ/textarea_component/textarea_component.html.haml index 4df4aad44..394cf15ec 100644 --- a/app/components/editable_champ/textarea_component/textarea_component.html.haml +++ b/app/components/editable_champ/textarea_component/textarea_component.html.haml @@ -1,3 +1,5 @@ +%span.sr-only= t('.recommended_size', size: @champ.character_limit_base) + ~ @form.text_area :value, id: @champ.input_id, aria: { describedby: @champ.describedby_id }, diff --git a/app/models/champs/textarea_champ.rb b/app/models/champs/textarea_champ.rb index ab2b229e0..24a744c59 100644 --- a/app/models/champs/textarea_champ.rb +++ b/app/models/champs/textarea_champ.rb @@ -41,16 +41,16 @@ class Champs::TextareaChamp < Champs::TextChamp analyze_character_count == :warning end + def character_limit_base + character_limit&.to_i + end + private def character_count return value&.bytesize end - def character_limit_base - character_limit&.to_i - end - def character_limit_threshold_75 character_limit_base * 0.75 end From 017ebbcd18cdfd2fc1efb2bdb53ba7cce3fb0d4c Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 12 May 2023 10:04:11 +0200 Subject: [PATCH 4/4] UI: change alert to warning --- .../textarea_component/textarea_component.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/editable_champ/textarea_component/textarea_component.html.haml b/app/components/editable_champ/textarea_component/textarea_component.html.haml index 394cf15ec..8a18048ed 100644 --- a/app/components/editable_champ/textarea_component/textarea_component.html.haml +++ b/app/components/editable_champ/textarea_component/textarea_component.html.haml @@ -12,5 +12,5 @@ = t('.remaining_characters', remaining_words: @champ.remaining_characters) - if @champ.character_limit_warning? - %span.fr-icon-close-circle-fill.fr-text-default--error.characters-count + %span.fr-icon-warning-fill.fr-text-default--warning.characters-count = t('.excess_characters', excess_words: @champ.excess_characters)