Skip to content

Commit

Permalink
Merge commit '75d2ad9a4df9472a46b4e5dd983954e4e06b0a5b' into feature/…
Browse files Browse the repository at this point in the history
…import-2023-10-10

# Conflicts:
#	app/controllers/users/commencer_controller.rb
#	app/views/commencer/show.html.haml
#	config/locales/en.yml
#	config/locales/fr.yml
  • Loading branch information
maatinito committed Jan 26, 2024
2 parents 23dc1c3 + 75d2ad9 commit 8d25d2c
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 78 deletions.
5 changes: 5 additions & 0 deletions app/controllers/users/commencer_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def commencer
if user_signed_in?
set_prefilled_dossier_ownership if @prefilled_dossier&.orphan?
check_prefilled_dossier_ownership if @prefilled_dossier

revision = @revision.draft? ? @revision : @procedure.revisions.where.not(id: @procedure.draft_revision_id)
@dossiers = current_user.dossiers.select(:id, :created_at, :depose_at, :state).visible_by_user.where(revision:).order(created_at: :desc).to_a
@drafts, @not_drafts = @dossiers.partition(&:brouillon?)
@preview_dossiers = @dossiers.take(3)
else
# pf specific: allows social logins (google, france connect,...) to get back when logged
store_user_location!(@procedure, @prefilled_dossier)
Expand Down
62 changes: 32 additions & 30 deletions app/views/commencer/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

.commencer.form
- if !user_signed_in?

= render Dsfr::CalloutComponent.new(title: t("views.commencer.show.start_procedure"), heading_level: 'h2') do |c|
= render Dsfr::CalloutComponent.new(title: t(".start_procedure"), heading_level: 'h2') do |c|
- c.body do
= render partial: 'shared/social_login', locals: { title: t('views.commencer.show.social_title') }
= render partial: 'shared/social_login', locals: { title: t('.social_title') }
%p.fr-hr-or= t('views.shared.france_connect_login.separator')
%h2.fr-h5= t('views.shared.account.title', name: APPLICATION_NAME)
%br
Expand All @@ -18,50 +17,53 @@
%li
= link_to t('views.shared.account.already_user'), commencer_sign_in_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token), class: 'fr-btn fr-btn--secondary fr-btn--lg fr-my-2w'
- else
- revision = @revision.draft? ? @revision : @procedure.revisions.where.not(id: @procedure.draft_revision_id)
- dossiers = current_user.dossiers.visible_by_user.where(revision: revision)
- drafts = dossiers.merge(Dossier.state_brouillon)
- not_drafts = dossiers.merge(Dossier.state_not_brouillon)

- if @prefilled_dossier
= render Dsfr::CalloutComponent.new(title: t("views.commencer.show.prefilled_draft"), heading_level: 'h2') do |c|
= render Dsfr::CalloutComponent.new(title: t(".prefilled_draft"), heading_level: 'h2') do |c|
- c.body do
%p= t('views.commencer.show.prefilled_draft_detail_html', time_ago: time_ago_in_words(@prefilled_dossier.created_at), procedure: @procedure.libelle)
= link_to t('views.commencer.show.go_to_prefilled_file'), url_for_dossier(@prefilled_dossier), class: 'fr-btn fr-mb-2w'
%p= t('.prefilled_draft_detail_html', time_ago: time_ago_in_words(@prefilled_dossier.created_at), procedure: @procedure.libelle)
= link_to t('.go_to_prefilled_file'), url_for_dossier(@prefilled_dossier), class: 'fr-btn fr-mb-2w'

- elsif dossiers.empty?
= link_to t('views.commencer.show.start_procedure'), url_for_new_dossier(@revision), class: 'fr-btn fr-mb-2w'
- elsif @dossiers.empty?
= link_to t('.start_procedure'), url_for_new_dossier(@revision), class: 'fr-btn fr-mb-2w'

- elsif drafts.size == 1 && not_drafts.empty?
- dossier = drafts.first
= render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_draft"), heading_level: 'h2') do |c|
- elsif @drafts.size == 1 && @not_drafts.empty?
- dossier = @drafts.first
= render Dsfr::CalloutComponent.new(title: t(".already_draft"), heading_level: 'h2') do |c|
- c.body do
%p
= t('views.commencer.show.already_draft_detail_html', time_ago: time_ago_in_words(dossier.created_at), procedure: dossier.procedure.libelle)
= t('.already_draft_detail_html', time_ago: time_ago_in_words(dossier.created_at), procedure: @procedure.libelle)
%ul.fr-btns-group.fr-btns-group--inline
%li= link_to t('views.commencer.show.continue_file'), url_for_dossier(dossier), class: 'fr-btn'
%li= link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary'
%li= link_to t('.continue_file'), url_for_dossier(dossier), class: 'fr-btn'
%li= link_to t('.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary'

- elsif not_drafts.size == 1
- dossier = not_drafts.first
= render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_not_draft"), heading_level: 'h2') do |c|
- elsif @not_drafts.size == 1
- dossier = @not_drafts.first
= render Dsfr::CalloutComponent.new(title: t(".already_not_draft"), heading_level: 'h2') do |c|
- c.body do
%p
= t('views.commencer.show.already_not_draft_detail_html', time_ago: time_ago_in_words(dossier.depose_at), procedure: dossier.procedure.libelle)
= t('.already_not_draft_detail_html', time_ago: time_ago_in_words(dossier.depose_at), procedure: @procedure.libelle)
%ul.fr-btns-group.fr-btns-group--inline
%li= link_to t('views.commencer.show.show_my_submitted_file'), url_for_dossier(dossier), class: 'fr-btn'
%li= link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary'
%li= link_to t('.show_my_submitted_file'), url_for_dossier(dossier), class: 'fr-btn'
%li= link_to t('.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary'

- else
= render Dsfr::CalloutComponent.new(title: t("views.commencer.show.existing_dossiers"), heading_level: 'h2') do |c|
= render Dsfr::CalloutComponent.new(title: t(".existing_dossiers"), heading_level: 'h2') do |c|
- c.body do
%ul.fr-btns-group.fr-btns-group--inline
%li= link_to t('views.commencer.show.show_dossiers'), dossiers_path, class: "fr-btn"
%li= link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: "fr-btn fr-btn--secondary"
%li= link_to t('.show_dossiers'), dossiers_path(procedure_id: @procedure.id), class: "fr-btn"
%li= link_to t('.start_new_file'), url_for_new_dossier(@revision), class: "fr-btn fr-btn--secondary"
%p= t('.already_created', count: @preview_dossiers.size)
%ul
- @preview_dossiers.each do |dossier|
%li= link_to t('.already_created_details_html',
id: number_with_html_delimiter(dossier.id),
created_at: time_ago_in_words(dossier.created_at),
state: dossier_display_state(dossier.state, lower: true)),
dossier_path(dossier)

- if @procedure.feature_enabled?(:dossier_pdf_vide)
%hr
%p= t('views.commencer.show.want_empty_pdf', service: @procedure&.service&.nom, adresse: @procedure&.service&.adresse)
%p= t('.want_empty_pdf', service: @procedure&.service&.nom, adresse: @procedure&.service&.adresse)

%br
= link_to t('views.commencer.show.download_empty_pdf'), commencer_dossier_vide_for_revision_path(@revision), class: "fr-btn fr-btn--secondary fr-mb-2w"
= link_to t('.download_empty_pdf'), commencer_dossier_vide_for_revision_path(@revision), class: "fr-btn fr-btn--secondary fr-mb-2w"
21 changes: 1 addition & 20 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#
# To use a different locale, set it with `I18n.locale`:
#
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
Expand Down Expand Up @@ -198,7 +197,7 @@ en:
adress_html: "By mail : DINUM , 20 avenue de Ségur 75007 Paris"
remedies:
title: "Remedies"
line_one: "If you report tu us a lack of accessibility that prevents you from accessing any content or functionality of the site, and do not manage to receive a rapid response from us, you are entitled to send your complaints or a request for referral to the Rights Defender."
line_one: "If you notice a lack of accessibility that prevents you from accessing a content or functionality of the site, and you report it to us and do not manage to obtain a rapid response from us, you are entitled to send your complaints or a request for referral to the Rights Defender."
line_two: "Several means are available to you:"
remedies_one:
label: "A contact form"
Expand All @@ -209,24 +208,6 @@ en:
url: "https://www.defenseurdesdroits.fr/fr/saisir/delegues"
title: "Contact the delegate of the Human Rights Defender in your region - new tab"
remedies_three: "Send a letter by mail (free of charge, no stamp) at Défenseur des droits Libre réponse 71120 75342 Paris CEDEX 07"
commencer:
show:
start_procedure: Start the procedure
existing_dossiers: You already have files for this procedure
show_dossiers: View my current files
prefilled_draft: "You have a prefilled file"
prefilled_draft_detail_html: "You are ready to continue a prefilled file for the \"%{procedure}\" procedure, started <strong>%{time_ago} ago</strong>."
already_draft: "You already started to fill a file"
already_draft_detail_html: "You started to fill a file for the \"%{procedure}\" procedure <strong>%{time_ago} ago</strong>"
already_not_draft: "You already submitted a file"
already_not_draft_detail_html: "You submitted a file for the \"%{procedure}\" procedure <strong>%{time_ago} ago</strong>."
go_to_prefilled_file: 'Continue to fill my prefilled file'
continue_file: "Continue to fill my file"
start_new_file: "Start a new file"
show_my_submitted_file: 'Show my submitted file'
want_empty_pdf: "You prefer to submit a paper form? You can download an empty PDF file, and send it to the right administration : %{service} - %{adresse}"
download_empty_pdf: 'Download an empty PDF file'
social_title: "Connect safely and quickly using"
prefill_descriptions:
edit:
intro_html: "You'd like to allow your users to <strong>create a prefilled file</strong>, with data you already have, for the procedure « %{libelle} »."
Expand Down
18 changes: 0 additions & 18 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,6 @@ fr:
url: "https://www.defenseurdesdroits.fr/fr/saisir/delegues"
title: "Contacter le délégué du Défenseur des droits dans votre région - nouvel onglet"
remedies_three: "Envoyer un courrier par la poste (gratuit, ne pas mettre de timbre) Défenseur des droits Libre réponse 71120 75342 Paris CEDEX 07"
commencer:
show:
start_procedure: Commencer la démarche
existing_dossiers: Vous avez déjà des dossiers pour cette démarche
show_dossiers: Voir mes dossiers en cours
prefilled_draft: "Vous avez un dossier prérempli"
prefilled_draft_detail_html: "Vous êtes prêt·e à poursuivre un dossier prérempli sur la démarche « %{procedure} », commencé il y a <strong>%{time_ago}</strong>."
already_draft: "Vous avez déjà commencé à remplir un dossier"
already_draft_detail_html: "Il y a <strong>%{time_ago}</strong>, vous avez commencé à remplir un dossier sur la démarche « %{procedure} »."
already_not_draft: "Vous avez déjà déposé un dossier"
already_not_draft_detail_html: "Il y a <strong>%{time_ago}</strong>, vous avez déposé un dossier sur la démarche « %{procedure} »."
go_to_prefilled_file: 'Poursuivre mon dossier prérempli'
continue_file: 'Continuer à remplir mon dossier'
start_new_file: 'Commencer un nouveau dossier'
show_my_submitted_file: 'Voir mon dossier déposé'
want_empty_pdf: "Vous souhaitez effectuer une demande par papier ? Vous pouvez télécharger un dossier vide au format PDF, et l’envoyer à l’administration concernée : %{service} - %{adresse}"
download_empty_pdf: 'Télécharger un dossier vide au format PDF'
social_title: "Rapide, simple et sûr, connectez-vous avec"
prefill_descriptions:
edit:
intro_html: "Vous souhaitez permettre à vos usager·ères la <strong>création d'un dossier prérempli</strong>, à partir de données dont vous disposez déjà, pour la démarche « %{libelle} »."
Expand Down
24 changes: 24 additions & 0 deletions config/locales/views/users/commencer/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
en:
commencer:
show:
start_procedure: Start the procedure
social_title: "Connect safely and quickly using"
existing_dossiers: You already have files for this procedure
show_dossiers: View my current files
prefilled_draft: "You have a prefilled file"
prefilled_draft_detail_html: "You are ready to continue a prefilled file for the \"%{procedure}\" procedure, started <strong>%{time_ago} ago</strong>."
already_draft: "You already started to fill a file"
already_draft_detail_html: "You started to fill a file for the \"%{procedure}\" procedure <strong>%{time_ago} ago</strong>"
already_not_draft: "You already submitted a file"
already_not_draft_detail_html: "You submitted a file for the \"%{procedure}\" procedure <strong>%{time_ago} ago</strong>."
go_to_prefilled_file: 'Continue to fill my prefilled file'
continue_file: "Continue to fill my file"
start_new_file: "Start a new file"
show_my_submitted_file: 'Show my submitted file'
want_empty_pdf: "You prefer to submit a paper form? You can download an empty PDF file, and send it to the right administration : %{service} - %{adresse}"
download_empty_pdf: 'Download an empty PDF file'
already_created:
one: "Your previous file :"
other: "Your last %{count} created files :"
already_created_details_html:
"N° %{id}, created %{created_at} ago and %{state}"
24 changes: 24 additions & 0 deletions config/locales/views/users/commencer/fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
fr:
commencer:
show:
start_procedure: Commencer la démarche
social_title: "Rapide, simple et sûr, connectez-vous avec"
existing_dossiers: Vous avez déjà des dossiers pour cette démarche
show_dossiers: Voir mes dossiers en cours
prefilled_draft: "Vous avez un dossier prérempli"
prefilled_draft_detail_html: "Vous êtes prêt·e à poursuivre un dossier prérempli sur la démarche « %{procedure} », commencé il y a <strong>%{time_ago}</strong>."
already_draft: "Vous avez déjà commencé à remplir un dossier"
already_draft_detail_html: "Il y a <strong>%{time_ago}</strong>, vous avez commencé à remplir un dossier sur la démarche « %{procedure} »."
already_not_draft: "Vous avez déjà déposé un dossier"
already_not_draft_detail_html: "Il y a <strong>%{time_ago}</strong>, vous avez déposé un dossier sur la démarche « %{procedure} »."
go_to_prefilled_file: 'Poursuivre mon dossier prérempli'
continue_file: 'Continuer à remplir mon dossier'
start_new_file: 'Commencer un nouveau dossier'
show_my_submitted_file: 'Voir mon dossier déposé'
want_empty_pdf: "Vous souhaitez effectuer une demande par papier ? Vous pouvez télécharger un dossier vide au format PDF, et l’envoyer à l’administration concernée : %{service} - %{adresse}"
download_empty_pdf: 'Télécharger un dossier vide au format PDF'
already_created:
one: "Votre dernier dossier :"
other: "Vos %{count} derniers dossiers créés :"
already_created_details_html:
"N° %{id}, créé il y a %{created_at} et %{state}"
28 changes: 18 additions & 10 deletions spec/views/commencer/show.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@

let(:stored_query_params) { false }
let(:procedure) { create(:procedure, :published, :for_individual, :with_service) }
let(:dossiers) { drafts + not_drafts }
let(:drafts) { [] }
let(:not_drafts) { [] }
let(:preview_dossiers) { dossiers.take(3) }

before do
assign(:procedure, procedure)
assign(:revision, procedure.published_revision)
assign(:dossiers, dossiers)
assign(:drafts, drafts)
assign(:not_drafts, not_drafts)
assign(:preview_dossiers, preview_dossiers)
if user
sign_in user
end
Expand Down Expand Up @@ -65,39 +73,39 @@
end

context 'and they have a pending draft' do
let!(:brouillon) { create(:dossier, user: user, procedure: procedure) }
let!(:drafts) { [create(:dossier, user: user, procedure: procedure)] }

it_behaves_like 'it renders a link to create a new dossier', 'Commencer un nouveau dossier'

it 'renders a link to resume the pending draft' do
subject
expect(rendered).to have_text(time_ago_in_words(brouillon.created_at))
expect(rendered).to have_link('Continuer à remplir mon dossier', href: brouillon_dossier_path(brouillon))
expect(rendered).to have_text(time_ago_in_words(drafts.first.created_at))
expect(rendered).to have_link('Continuer à remplir mon dossier', href: brouillon_dossier_path(drafts.first))
end
end

context 'and they have a submitted dossier' do
let!(:brouillon) { create(:dossier, user: user, procedure: procedure) }
let!(:dossier) { create(:dossier, :en_construction, :with_individual, user: user, procedure: procedure) }
let!(:drafts) { [create(:dossier, user: user, procedure: procedure)] }
let!(:not_drafts) { [create(:dossier, :en_construction, :with_individual, user: user, procedure: procedure)] }

it_behaves_like 'it renders a link to create a new dossier', 'Commencer un nouveau dossier'

it 'renders a link to the submitted dossier' do
subject
expect(rendered).to have_text(time_ago_in_words(dossier.depose_at))
expect(rendered).to have_link('Voir mon dossier', href: dossier_path(dossier))
expect(rendered).to have_text(time_ago_in_words(not_drafts.first.depose_at))
expect(rendered).to have_link('Voir mon dossier', href: dossier_path(not_drafts.first))
end
end

context 'and they have several submitted dossiers' do
let!(:brouillon) { create(:dossier, user: user, procedure: procedure) }
let!(:dossiers) { create_list(:dossier, 2, :en_construction, :with_individual, user: user, procedure: procedure) }
let!(:drafts) { [create(:dossier, user: user, procedure: procedure)] }
let!(:not_drafts) { create_list(:dossier, 2, :en_construction, :with_individual, user: user, procedure: procedure) }

it_behaves_like 'it renders a link to create a new dossier', 'Commencer un nouveau dossier'

it 'renders a link to the dossiers list' do
subject
expect(rendered).to have_link('Voir mes dossiers en cours', href: dossiers_path)
expect(rendered).to have_link('Voir mes dossiers en cours', href: dossiers_path(procedure_id: procedure.id))
end
end

Expand Down

0 comments on commit 8d25d2c

Please sign in to comment.