Changements sur le caractère obligatoire / facultatif et l'asterisque interface usager et page de connexion
This commit is contained in:
parent
0d1754d715
commit
804f89f444
18 changed files with 42 additions and 24 deletions
|
@ -17,6 +17,7 @@
|
||||||
color: $dark-grey;
|
color: $dark-grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.mandatory {
|
.mandatory {
|
||||||
color: $dark-red;
|
color: $dark-red;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,4 +173,8 @@
|
||||||
&.move-handle {
|
&.move-handle {
|
||||||
background-image: image-url("icons/move-handle.svg");
|
background-image: image-url("icons/move-handle.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.mandatory {
|
||||||
|
width: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,8 @@
|
||||||
= @form.label @attribute, label_opts do
|
= @form.label @attribute, label_opts do
|
||||||
- capture do
|
- capture do
|
||||||
= label
|
= label
|
||||||
- if @required
|
|
||||||
%span.mandatory *
|
|
||||||
- if hint?
|
- if hint?
|
||||||
%span.fr-hint-text= hint
|
%span.fr-hint-text= hint
|
||||||
|
|
||||||
= @form.public_send(@input_type, @attribute, input_opts)
|
= @form.public_send(@input_type, @attribute, input_opts)
|
||||||
|
|
||||||
- if errors_on_attribute?
|
- if errors_on_attribute?
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
class EditableChamp::AsteriskMandatoryComponent < ApplicationComponent
|
||||||
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
en:
|
||||||
|
required: required
|
|
@ -0,0 +1,2 @@
|
||||||
|
fr:
|
||||||
|
required: obligatoire
|
|
@ -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" }
|
|
@ -3,3 +3,4 @@ en:
|
||||||
changes_to_save: "modifications to submit"
|
changes_to_save: "modifications to submit"
|
||||||
modified_at: "modified on %{datetime}"
|
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.
|
check_content_rebased: The type of this field or its description has been modified by the administration. Check its content.
|
||||||
|
optional_champ: (optional)
|
||||||
|
|
|
@ -2,4 +2,5 @@
|
||||||
fr:
|
fr:
|
||||||
changes_to_save: "modification à déposer"
|
changes_to_save: "modification à déposer"
|
||||||
modified_at: "modifié le %{datetime}"
|
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)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#{@champ.libelle}
|
= @champ.libelle
|
||||||
- if @champ.mandatory?
|
- if @champ.mandatory? && @champ.type_champ != "checkbox"
|
||||||
%span.mandatory *
|
= render EditableChamp::AsteriskMandatoryComponent.new
|
||||||
|
- elsif !@champ.mandatory?
|
||||||
|
= "#{t('.optional_champ')}"
|
||||||
|
|
||||||
- if @champ.forked_with_changes?
|
- if @champ.forked_with_changes?
|
||||||
%span.updated-at.highlighted
|
%span.updated-at.highlighted
|
||||||
|
@ -9,6 +11,7 @@
|
||||||
%span.updated-at{ class: highlight_if_unseen_class }
|
%span.updated-at{ class: highlight_if_unseen_class }
|
||||||
= t('.modified_at', datetime: try_format_datetime(@champ.updated_at))
|
= 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)
|
- if @champ.rebased_at.present? && @champ.rebased_at > (@seen_at || @champ.updated_at) && current_user.owns_or_invite?(@champ.dossier)
|
||||||
%span.updated-at.highlighted
|
%span.updated-at.highlighted
|
||||||
= t('.check_content_rebased')
|
= t('.check_content_rebased')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
= @form.check_box :value,
|
= @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',
|
'true',
|
||||||
'false'
|
'false'
|
||||||
|
|
|
@ -28,8 +28,8 @@ class SimpleFormatComponent < ApplicationComponent
|
||||||
@allow_a = allow_a
|
@allow_a = allow_a
|
||||||
|
|
||||||
@text = (text || "").gsub(/\R/, "\n\n") # force double \n otherwise a single one won't split paragraph
|
@text = (text || "").gsub(/\R/, "\n\n") # force double \n otherwise a single one won't split paragraph
|
||||||
.split("\n\n") #
|
.split("\n\n")
|
||||||
.map(&:lstrip) # this block prevent redcarpet to consider " text" as block code by lstriping
|
.map(&:lstrip) # this block prevent redcarpet to consider " text" as block code by lstriping
|
||||||
.join("\n\n")
|
.join("\n\n")
|
||||||
.gsub(EMAIL_IN_TEXT_REGEX) { _1.gsub('_', '\\_') } # Workaround for redcarpet bug on autolink email having _. Cf tests
|
.gsub(EMAIL_IN_TEXT_REGEX) { _1.gsub('_', '\\_') } # Workaround for redcarpet bug on autolink email having _. Cf tests
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
.recommandations
|
.recommandations
|
||||||
%h2
|
%h2
|
||||||
= t('.intro_html')
|
= t('.intro_html')
|
||||||
%p.mandatory-explanation= t('asterisk_html', scope: [:utils])
|
%p.mandatory-explanation= t('mandatory_champs', scope: [:utils])
|
||||||
|
|
||||||
- if !user_signed_in?
|
- if !user_signed_in?
|
||||||
.fr-input-group
|
.fr-input-group
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
%h2.fr-h6= I18n.t('views.registrations.new.subtitle')
|
%h2.fr-h6= I18n.t('views.registrations.new.subtitle')
|
||||||
|
|
||||||
.fr-fieldset__element
|
.fr-fieldset__element
|
||||||
%p.fr-text--sm= t('utils.asterisk_html')
|
%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: true })
|
.fr-fieldset__element= render Dsfr::InputComponent.new(form: f, attribute: :email, input_type: :email_field, opts: { autocomplete: 'email', autofocus: true })
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
%h2.fr-h6= I18n.t('views.users.sessions.new.subtitle')
|
%h2.fr-h6= I18n.t('views.users.sessions.new.subtitle')
|
||||||
|
|
||||||
.fr-fieldset__element
|
.fr-fieldset__element
|
||||||
%p.fr-text--sm= t('utils.asterisk_html')
|
%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: true })
|
.fr-fieldset__element= render Dsfr::InputComponent.new(form: f, attribute: :email, input_type: :email_field, opts: { autocomplete: 'email', autofocus: true })
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ en:
|
||||||
deconnexion: "Log out"
|
deconnexion: "Log out"
|
||||||
pj: "Attachments"
|
pj: "Attachments"
|
||||||
asterisk_html: Fields marked by an asterisk ( <span class = mandatory>*</span> ) are mandatory.
|
asterisk_html: Fields marked by an asterisk ( <span class = mandatory>*</span> ) are mandatory.
|
||||||
|
mandatory_champs: All fields are mandatory.
|
||||||
file_number: File number
|
file_number: File number
|
||||||
subject: Subject
|
subject: Subject
|
||||||
message: Message
|
message: Message
|
||||||
|
|
|
@ -40,7 +40,8 @@ fr:
|
||||||
i_dont_know: Je ne sais pas
|
i_dont_know: Je ne sais pas
|
||||||
deconnexion: "Déconnexion"
|
deconnexion: "Déconnexion"
|
||||||
pj: "Pièces jointes"
|
pj: "Pièces jointes"
|
||||||
asterisk_html: Les champs suivis d’un astérisque ( <span class = mandatory> * </span> ) sont obligatoires.
|
asterisk_html: Les champs suivis d’un astérisque ( * ) sont obligatoires.
|
||||||
|
mandatory_champs: Tous les champs sont obligatoires.
|
||||||
file_number: Numéro de dossier
|
file_number: Numéro de dossier
|
||||||
subject: Sujet
|
subject: Sujet
|
||||||
message: Message
|
message: Message
|
||||||
|
|
|
@ -12,9 +12,9 @@ describe 'The user' do
|
||||||
fill_individual
|
fill_individual
|
||||||
|
|
||||||
# fill data
|
# fill data
|
||||||
fill_in('text *', with: 'super texte')
|
fill_in('text', with: 'super texte', match: :first)
|
||||||
fill_in('textarea', with: 'super textarea')
|
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'))
|
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
|
find("input[type=datetime-local]").send_keys(:arrow_up).send_keys(:arrow_down) # triggers onChange
|
||||||
fill_in('number', with: '42')
|
fill_in('number', with: '42')
|
||||||
|
@ -329,7 +329,7 @@ describe 'The user' do
|
||||||
|
|
||||||
fill_individual
|
fill_individual
|
||||||
|
|
||||||
fill_in('age', with: 10)
|
fill_in('age (facultatif)', with: 10)
|
||||||
click_on 'Déposer le dossier'
|
click_on 'Déposer le dossier'
|
||||||
expect(page).to have_current_path(merci_dossier_path(user_dossier))
|
expect(page).to have_current_path(merci_dossier_path(user_dossier))
|
||||||
end
|
end
|
||||||
|
@ -400,9 +400,9 @@ describe 'The user' do
|
||||||
|
|
||||||
fill_individual
|
fill_individual
|
||||||
|
|
||||||
fill_in('age', with: '18')
|
fill_in('age (facultatif)', with: '18')
|
||||||
expect(page).to have_css('label', text: 'nom *', visible: :visible)
|
expect(page).to have_css('label', text: 'nom', visible: :visible)
|
||||||
|
expect(page).to have_css('.icon.mandatory')
|
||||||
click_on 'Déposer le dossier'
|
click_on 'Déposer le dossier'
|
||||||
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||||
end
|
end
|
||||||
|
@ -437,7 +437,7 @@ describe 'The user' do
|
||||||
expect(page).to have_no_css('legend h2', text: 'info voiture', 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)
|
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('label', text: 'permis de conduire', visible: true)
|
||||||
expect(page).to have_css('legend h2', text: 'info voiture', 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)
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
@ -450,10 +450,10 @@ describe 'The user' do
|
||||||
expect(page).to have_css('label', text: 'parking', visible: true)
|
expect(page).to have_css('label', text: 'parking', visible: true)
|
||||||
|
|
||||||
# try to fill with invalid data
|
# 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)
|
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: 'permis de conduire', visible: true)
|
||||||
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
expect(page).to have_no_css('label', text: 'tonnage', visible: true)
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ describe 'The user' do
|
||||||
expect(page).to have_no_css('label', text: 'permis de conduire', visible: true)
|
expect(page).to have_no_css('label', text: 'permis de conduire', visible: true)
|
||||||
expect(page).to have_no_css('label', text: 'tonnage', 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)
|
wait_for_autosave(false)
|
||||||
|
|
||||||
# the champ keeps their previous value so they are all displayed
|
# the champ keeps their previous value so they are all displayed
|
||||||
|
|
Loading…
Reference in a new issue