Skip to content

Commit

Permalink
Merge commit '06498631393980712f72f860aaa83977ad1b9a48' into feature/…
Browse files Browse the repository at this point in the history
…import-2023-06-06

# Conflicts:
#	app/components/simple_format_component.rb
#	app/views/users/registrations/new.html.haml
#	app/views/users/sessions/new.html.haml
#	config/locales/fr.yml
  • Loading branch information
maatinito committed Aug 28, 2023
2 parents ca18099 + 0649863 commit af0213c
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 24 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
color: $dark-grey;
}


.mandatory {
color: $dark-red;
}
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,8 @@
&.move-handle {
background-image: image-url("icons/move-handle.svg");
}

&.mandatory {
width: 10px;
}
}
3 changes: 0 additions & 3 deletions app/components/dsfr/input_component/input_component.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 2 additions & 0 deletions app/components/editable_champ/asterisk_mandatory_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class EditableChamp::AsteriskMandatoryComponent < ApplicationComponent
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en:
required: required
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fr:
required: obligatoire
Original file line number Diff line number Diff line change
@@ -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" }
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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 [email protected]?
= "#{t('.optional_champ')}"

- if @champ.forked_with_changes?
%span.updated-at.highlighted
Expand All @@ -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')
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
%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
%span.fr-icon.fr-icon-error-warning-line.fr-text-default--info.fr-mt-1v{ "aria-hidden": "true" }
.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:,
Expand Down
2 changes: 1 addition & 1 deletion app/components/simple_format_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/support/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/registrations/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

Expand Down
1 change: 0 additions & 1 deletion app/views/users/sessions/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions spec/system/users/brouillon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit af0213c

Please sign in to comment.