diff --git a/app/assets/stylesheets/forms.scss b/app/assets/stylesheets/forms.scss index 051f77d3646..c8ec70d05d7 100644 --- a/app/assets/stylesheets/forms.scss +++ b/app/assets/stylesheets/forms.scss @@ -40,6 +40,7 @@ color: $dark-grey; } + .mandatory { color: $dark-red; } diff --git a/app/assets/stylesheets/icons.scss b/app/assets/stylesheets/icons.scss index 8bf4fb12dfd..37c0a156a9f 100644 --- a/app/assets/stylesheets/icons.scss +++ b/app/assets/stylesheets/icons.scss @@ -173,4 +173,8 @@ &.move-handle { background-image: image-url("icons/move-handle.svg"); } + + &.mandatory { + width: 10px; + } } diff --git a/app/components/dsfr/input_component/input_component.html.haml b/app/components/dsfr/input_component/input_component.html.haml index 018def6afa5..5fb6b0615df 100644 --- a/app/components/dsfr/input_component/input_component.html.haml +++ b/app/components/dsfr/input_component/input_component.html.haml @@ -2,11 +2,8 @@ = @form.label @attribute, label_opts do - capture do = label - - if @required - %span.mandatory  * - if hint? %span.fr-hint-text= hint - = @form.public_send(@input_type, @attribute, input_opts) - if errors_on_attribute? diff --git a/app/components/editable_champ/asterisk_mandatory_component.rb b/app/components/editable_champ/asterisk_mandatory_component.rb new file mode 100644 index 00000000000..d71d395a091 --- /dev/null +++ b/app/components/editable_champ/asterisk_mandatory_component.rb @@ -0,0 +1,2 @@ +class EditableChamp::AsteriskMandatoryComponent < ApplicationComponent +end diff --git a/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.en.yml b/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.en.yml new file mode 100644 index 00000000000..907c5b002de --- /dev/null +++ b/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.en.yml @@ -0,0 +1,2 @@ +en: + required: required diff --git a/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.fr.yml b/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.fr.yml new file mode 100644 index 00000000000..7b0e090ee96 --- /dev/null +++ b/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.fr.yml @@ -0,0 +1,2 @@ +fr: + required: obligatoire diff --git a/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.html.haml b/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.html.haml new file mode 100644 index 00000000000..fbea9237465 --- /dev/null +++ b/app/components/editable_champ/asterisk_mandatory_component/asterisk_mandatory_component.html.haml @@ -0,0 +1,3 @@ +%svg.icon.mandatory{ xmlns: "http://www.w3.org/2000/svg", role: "img", 'aria-label': t('.required'), width: 10, height: 10, viewBox: "0 0 1200 1200", "xml:space" => "preserve" } + %desc= t('.required') + %path{ d: "M489.838 29.354v443.603L68.032 335.894 0 545.285l421.829 137.086-260.743 358.876 178.219 129.398L600.048 811.84l260.673 358.806 178.146-129.398-260.766-358.783L1200 545.379l-68.032-209.403-421.899 137.07V29.443H489.84l-.002-.089z" } diff --git a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.en.yml b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.en.yml index 052df2f893d..9d642dd7263 100644 --- a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.en.yml +++ b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.en.yml @@ -3,3 +3,4 @@ en: changes_to_save: "modifications to submit" modified_at: "modified on %{datetime}" check_content_rebased: The type of this field or its description has been modified by the administration. Check its content. + optional_champ: (optional) diff --git a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.fr.yml b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.fr.yml index 8ae8a9d065b..0201f614036 100644 --- a/app/components/editable_champ/champ_label_content_component/champ_label_content_component.fr.yml +++ b/app/components/editable_champ/champ_label_content_component/champ_label_content_component.fr.yml @@ -2,4 +2,5 @@ fr: changes_to_save: "modification à déposer" modified_at: "modifié le %{datetime}" - check_content_rebased: Le type de ce champ ou sa description ont été modifiés par l’administration. Vérifier son contenu. + check_content_rebased: Le type de ce champ ou sa description ont été modifiés par l'administration. Vérifier son contenu. + optional_champ: (facultatif) 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 298c3a8672f..5aeff2c6bea 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 @@ -1,6 +1,8 @@ -#{@champ.libelle} -- if @champ.mandatory? - %span.mandatory * += @champ.libelle +- if @champ.mandatory? && @champ.type_champ != "checkbox" + = render EditableChamp::AsteriskMandatoryComponent.new +- elsif !@champ.mandatory? + = "#{t('.optional_champ')}" - if @champ.forked_with_changes? %span.updated-at.highlighted @@ -9,6 +11,7 @@ %span.updated-at{ class: highlight_if_unseen_class } = t('.modified_at', datetime: try_format_datetime(@champ.updated_at)) + - if @champ.rebased_at.present? && @champ.rebased_at > (@seen_at || @champ.updated_at) && current_user.owns_or_invite?(@champ.dossier) %span.updated-at.highlighted = t('.check_content_rebased') diff --git a/app/components/editable_champ/checkbox_component/checkbox_component.html.haml b/app/components/editable_champ/checkbox_component/checkbox_component.html.haml index a1e3b5e940b..34e6a0a5a5a 100644 --- a/app/components/editable_champ/checkbox_component/checkbox_component.html.haml +++ b/app/components/editable_champ/checkbox_component/checkbox_component.html.haml @@ -1,4 +1,4 @@ = @form.check_box :value, - { required: @champ.required?, id: @champ.input_id, checked: @champ.true?, aria: { describedby: @champ.describedby_id } }, + { required: @champ.required?, id: @champ.input_id, checked: @champ.true?, aria: { describedby: @champ.describedby_id }, class: class_names('required' => @champ.required?)}, 'true', 'false' diff --git a/app/components/instructeurs/en_construction_menu_component/en_construction_menu_component.html.haml b/app/components/instructeurs/en_construction_menu_component/en_construction_menu_component.html.haml index 0c691ca45e7..0983ca0ed4c 100644 --- a/app/components/instructeurs/en_construction_menu_component/en_construction_menu_component.html.haml +++ b/app/components/instructeurs/en_construction_menu_component/en_construction_menu_component.html.haml @@ -8,7 +8,7 @@ %span.fr-icon.fr-icon-draft-line.fr-text-default--info.fr-mt-1v{ "aria-hidden": "true" } .dropdown-description %h4= t('.revert_en_construction') - L’usager sera notifié qu’il peut modifier son dossier + L’usager sera informé qu’il peut modifier son dossier - menu.with_item do = link_to('#', onclick: "DS.showMotivation(event, 'pending_correction');", role: 'menuitem') do @@ -16,7 +16,7 @@ .dropdown-description %h4= t('.request_correction') - L’usager sera notifié que des modifications sont attendues + L’usager sera informé que des modifications sont attendues - menu.with_item(class: "inactive form-inside fr-pt-1v") do = render partial: 'instructeurs/dossiers/instruction_button_motivation', locals: { dossier:, diff --git a/app/components/simple_format_component.rb b/app/components/simple_format_component.rb index e2c07a8e988..02f9b86b56b 100644 --- a/app/components/simple_format_component.rb +++ b/app/components/simple_format_component.rb @@ -28,7 +28,7 @@ def initialize(text, allow_a: true, class_names_map: {}) @allow_a = allow_a @text = (text || "").gsub(/\R/, "\n\n") # force double \n otherwise a single one won't split paragraph - .split("\n\n") # + .split("\n\n") .map { _1.sub(/^\s+(?=[0-9]\.|[^ *-])/, "") } # this block prevent redcarpet to consider " text" as block code by lstriping .join("\n\n") .gsub(EMAIL_IN_TEXT_REGEX) { _1.gsub('_', '\\_') } # Workaround for redcarpet bug on autolink email having _. Cf tests diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml index e8101b9746c..01c05c156ca 100644 --- a/app/views/support/index.html.haml +++ b/app/views/support/index.html.haml @@ -13,7 +13,7 @@ .recommandations %h2 = t('.intro_html') - %p.mandatory-explanation= t('asterisk_html', scope: [:utils]) + %p.mandatory-explanation= t('mandatory_champs', scope: [:utils]) - if !user_signed_in? .fr-input-group diff --git a/app/views/users/registrations/new.html.haml b/app/views/users/registrations/new.html.haml index dffa36abece..969bfec3caf 100644 --- a/app/views/users/registrations/new.html.haml +++ b/app/views/users/registrations/new.html.haml @@ -16,7 +16,7 @@ %h2.fr-h6= I18n.t('views.registrations.new.subtitle') .fr-fieldset__element - %p.fr-text--sm= t('utils.asterisk_html')+'coucou' + %p.fr-text--sm= t('utils.mandatory_champs') .fr-fieldset__element= render Dsfr::InputComponent.new(form: f, attribute: :email, input_type: :email_field, opts: { autocomplete: 'email', autofocus: false }) diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml index dc0a8fc1cea..cc4165b6899 100644 --- a/app/views/users/sessions/new.html.haml +++ b/app/views/users/sessions/new.html.haml @@ -2,7 +2,6 @@ = content_for(:title, t('metas.signin.title')) = render partial: 'shared/social_login', locals: { title: t('views.users.sessions.new.social_sign_in') } --# = render partial: 'shared/france_connect_login', locals: { url: france_connect_particulier_path } .form-column.procedure-context-content #session-new.auth-form.sign-in-form diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index df3eacd0734..6dc80a5b031 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -12,9 +12,9 @@ fill_individual # fill data - fill_in('text *', with: 'super texte') + fill_in('text', with: 'super texte', match: :first) fill_in('textarea', with: 'super textarea') - fill_in('date *', with: '12-12-2012') + fill_in('date', with: '12-12-2012', match: :first) fill_in('datetime', with: Time.zone.parse('2023-01-06T07:05')) find("input[type=datetime-local]").send_keys(:arrow_up).send_keys(:arrow_down) # triggers onChange fill_in('number', with: '42') @@ -341,7 +341,7 @@ fill_individual - fill_in('age', with: 10) + fill_in('age (facultatif)', with: 10) click_on 'Déposer le dossier' expect(page).to have_current_path(merci_dossier_path(user_dossier)) end @@ -412,9 +412,9 @@ fill_individual - fill_in('age', with: '18') - expect(page).to have_css('label', text: 'nom *', visible: :visible) - + fill_in('age (facultatif)', 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' expect(page).to have_current_path(brouillon_dossier_path(user_dossier)) end @@ -449,7 +449,7 @@ 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') + fill_in('age (facultatif)', 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) @@ -462,10 +462,10 @@ expect(page).to have_css('label', text: 'parking', visible: true) # try to fill with invalid data - fill_in('tonnage', with: 'a') + fill_in('tonnage (facultatif)', with: 'a') expect(page).to have_no_css('label', text: 'parking', visible: true) - fill_in('age', with: '2') + fill_in('age (facultatif)', with: '2') expect(page).to have_no_css('label', text: 'permis de conduire', visible: true) expect(page).to have_no_css('label', text: 'tonnage', visible: true) @@ -477,7 +477,7 @@ expect(page).to have_no_css('label', text: 'permis de conduire', visible: true) expect(page).to have_no_css('label', text: 'tonnage', visible: true) - fill_in('age', with: '18') + fill_in('age (facultatif)', with: '18') wait_for_autosave(false) # the champ keeps their previous value so they are all displayed