From d8a8d1fdab1fca70d6329d6f05ee19575ff50f67 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 2 Dec 2021 16:19:17 +0100 Subject: [PATCH] feat(instructeur/dossier/header/_expiration_banner): split trads and add dedicated expiration banner for instructeur. also enhance wording to include duree conservation + extension_conservation feat(expiration_banner): enhance wording of expiration feat(dossiers/expiration_banner): enhance wording regarding expiration to include duree_conservation_dossiers_dans_ds + extension_conservation, also add spec on expiration_banner for instructeur --- app/models/dossier.rb | 4 ++ .../dossiers/_expiration_banner.html.haml | 26 ++++++++ .../instructeurs/dossiers/_header.html.haml | 3 + .../dossiers/_expiration_banner.html.haml | 16 ++--- config/locales/en.yml | 4 +- config/locales/fr.yml | 4 +- config/locales/shared.en.yml | 17 ++--- config/locales/shared.fr.yml | 18 ++--- .../locales/views/instructeurs/header/en.yml | 11 ++++ .../locales/views/instructeurs/header/fr.yml | 11 ++++ config/locales/views/users/header/en.yml | 11 ++++ config/locales/views/users/header/fr.yml | 11 ++++ spec/models/instructeur_spec.rb | 4 +- .../_expiration_banner.html.haml_spec.rb | 66 +++++++++++++++++++ .../procedures/_header.html.haml_spec.rb | 7 +- .../procedures/_list.html.haml_spec.rb | 2 +- .../_expiration_banner.html.haml_spec.rb | 14 ++-- 17 files changed, 182 insertions(+), 47 deletions(-) create mode 100644 app/views/instructeurs/dossiers/_expiration_banner.html.haml create mode 100644 config/locales/views/instructeurs/header/en.yml create mode 100644 config/locales/views/instructeurs/header/fr.yml create mode 100644 config/locales/views/users/header/en.yml create mode 100644 config/locales/views/users/header/fr.yml create mode 100644 spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 0487959ef..c40d6be2e 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -646,6 +646,10 @@ class Dossier < ApplicationRecord parts.join end + def duree_totale_conservation_in_months + procedure.duree_conservation_dossiers_dans_ds + (conservation_extension / 1.month.to_i) + end + def avis_for_instructeur(instructeur) if instructeur.dossiers.include?(self) avis.order(created_at: :asc) diff --git a/app/views/instructeurs/dossiers/_expiration_banner.html.haml b/app/views/instructeurs/dossiers/_expiration_banner.html.haml new file mode 100644 index 000000000..0dee1a5ea --- /dev/null +++ b/app/views/instructeurs/dossiers/_expiration_banner.html.haml @@ -0,0 +1,26 @@ +-# small expires mention +- if dossier.expirable? + %p.expires_at.mb-2 + + %small= t("shared.dossiers.header.expires_at.#{dossier.state}", date: safe_expiration_date(dossier), duree_conservation_totale: dossier.duree_totale_conservation_in_months) + -# big banner warning + - if dossier.close_to_expiration? + .card.warning.mb-3 + .card-title= t('instructeurs.dossiers.header.banner.title') + %p + - if dossier.brouillon? + = t('instructeurs.dossiers.header.banner.states.brouillon') + - elsif dossier.en_construction? + = t('instructeurs.dossiers.header.banner.states.en_construction') + - elsif dossier.termine? + = t('instructeurs.dossiers.header.banner.states.termine') + + - if dossier.expiration_can_be_extended? + %br + = button_to t('instructeurs.dossiers.header.banner.button_delay_expiration'), users_dossier_repousser_expiration_path(dossier), class: 'button secondary mt-2' + + +- else + %p.expires_at_en_instruction + %small= t("shared.dossiers.header.expires_at.en_instruction") + diff --git a/app/views/instructeurs/dossiers/_header.html.haml b/app/views/instructeurs/dossiers/_header.html.haml index a2d2de025..19e8073f5 100644 --- a/app/views/instructeurs/dossiers/_header.html.haml +++ b/app/views/instructeurs/dossiers/_header.html.haml @@ -9,9 +9,12 @@ = dossier.procedure.libelle.truncate_words(10) %li = "Dossier nº #{dossier.id}" + .header-actions = render partial: 'instructeurs/dossiers/header_actions', locals: { dossier: dossier } + = render(partial: 'instructeurs/dossiers/expiration_banner', locals: {dossier: dossier}) + %ul.tabs - notifications_summary = current_instructeur.notifications_for_dossier(dossier) diff --git a/app/views/users/dossiers/_expiration_banner.html.haml b/app/views/users/dossiers/_expiration_banner.html.haml index 8f4689117..ab04fea8f 100644 --- a/app/views/users/dossiers/_expiration_banner.html.haml +++ b/app/views/users/dossiers/_expiration_banner.html.haml @@ -1,22 +1,22 @@ -# small expires mention - if dossier.expirable? - %p.expires_at - %small= t("shared.dossiers.header.expires_at.#{dossier.state}", date: safe_expiration_date(dossier)) + %p.expires_at.mb-2 + %small= t("shared.dossiers.header.expires_at.#{dossier.state}", date: safe_expiration_date(dossier), duree_conservation_totale: dossier.duree_totale_conservation_in_months) -# big banner warning - if dossier.close_to_expiration? - .card.warning.mt-2.mb-3 - .card-title= t('shared.dossiers.header.banner.title') + .card.warning.mb-3 + .card-title= t('users.dossiers.header.banner.title') %p - if dossier.brouillon? - = t('shared.dossiers.header.banner.states.brouillon') + = t('users.dossiers.header.banner.states.brouillon') - elsif dossier.en_construction? - = t('shared.dossiers.header.banner.states.en_construction') + = t('users.dossiers.header.banner.states.en_construction') - elsif dossier.termine? - = t('shared.dossiers.header.banner.states.termine') + = t('users.dossiers.header.banner.states.termine') - if dossier.expiration_can_be_extended? %br - = button_to t('shared.dossiers.header.banner.button_delay_expiration'), users_dossier_repousser_expiration_path(dossier), class: 'button secondary mt-2' + = button_to t('users.dossiers.header.banner.button_delay_expiration'), users_dossier_repousser_expiration_path(dossier), class: 'button secondary mt-2' - else diff --git a/config/locales/en.yml b/config/locales/en.yml index 37d74c65f..88f1b2139 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -134,11 +134,13 @@ en: edit_identity: "Edit identity data" instructeurs: dossiers: + archived_dossier: "This file will be kept for an additional month" deleted_by_user: "File deleted by user" avis: introduction_file_explaination: "File attached to the request for advice" users: dossiers: + archived_dossier: "Your file will be kept %{duree_conservation_dossiers_dans_ds} more months" autosave: autosave_draft: Your draft is automatically saved. more_infos: More informations @@ -382,8 +384,6 @@ en: ask_deletion: undergoingreview: "Your file is undergoing review. It is no longer possible to delete your file. To cancel the undergoingreview contact the adminitration via the mailbox." deleted_dossier: "Your file has been successfully deleted" - extend_conservation: - archived_dossier: "Your file will be archived for an additional month" update_brouillon: draft_saved: "Your draft has been saved." etablissement: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index ae571a661..81afc6b1d 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -130,6 +130,7 @@ fr: edit_identity: "Modifier l’identité" instructeurs: dossiers: + archived_dossier: "Le dossier sera conservé 1 mois supplémentaire" deleted_by_user: "Dossier supprimé par l'usager" avis: introduction_file_explaination: "Fichier joint à la demande d’avis" @@ -389,13 +390,12 @@ fr: test_procedure: "Ce dossier est déposé sur une démarche en test. Toute modification de la démarche par l’administrateur (ajout d'un champ, publication de la démarche...) entraînera sa suppression." no_access: "Vous n’avez pas accès à ce dossier" no_longer_editable: "Votre dossier ne peut plus être modifié" + archived_dossier: "Votre dossier sera conservé %{duree_conservation_dossiers_dans_ds} mois supplémentaire" create_commentaire: message_send: "Votre message a bien été envoyé à l’instructeur en charge de votre dossier." ask_deletion: undergoingreview: "L’instruction de votre dossier a commencé, il n’est plus possible de supprimer votre dossier. Si vous souhaitez annuler l’instruction contactez votre administration par la messagerie de votre dossier." deleted_dossier: "Votre dossier a bien été supprimé." - extend_conservation: - archived_dossier: "Votre dossier sera conservé un mois supplémentaire" update_brouillon: draft_saved: "Votre brouillon a bien été sauvegardé." etablissement: diff --git a/config/locales/shared.en.yml b/config/locales/shared.en.yml index 718513321..3f0316661 100644 --- a/config/locales/shared.en.yml +++ b/config/locales/shared.en.yml @@ -9,19 +9,12 @@ en: code_postal_notice: It is usually composed of 5 digits. header: expires_at: - brouillon: "Expires at %{date}" - en_construction: "Expires at %{date}" + brouillon: "Expires at %{date} (%{duree_conservation_totale} months after the creation of this file)" + en_construction: "Expires at %{date} (%{duree_conservation_totale} months after the last la edition of this file)" en_instruction: "This file is being instructed, the administration will answer as soon as possible" - accepte: "Expires at %{date}" - refuse: "Expires at %{date}" - sans_suite: "Expires at %{date}" - banner: - title: Your file will expire - states: - brouillon: Your file is still in draft and will soon expire. So it will be deleted soon without being instructed. If you want to pursue your procedure you can submit it now. Otherwise you are able to delay its expiration by clicking on the underneath button. - en_construction: Your file is pending for instruction. The maximum delay is 6 months, but your can extend the duration by a month by clicking on the underneath button. - termine: Your file had been processed and will soon expire.So it will be deleted soon. If you want to keep it, your can dowload a PDF file of it. - button_delay_expiration: "Delay deletion" + accepte: "Expires at %{date} (%{duree_conservation_totale} months after the acceptation of this file)" + refuse: "Expires at %{date} (%{duree_conservation_totale} months after the rejection of this file)" + sans_suite: "Expires at %{date} (%{duree_conservation_totale} months after this file had been closed)" champs: cnaf: show: diff --git a/config/locales/shared.fr.yml b/config/locales/shared.fr.yml index cbeb937df..538aeb966 100644 --- a/config/locales/shared.fr.yml +++ b/config/locales/shared.fr.yml @@ -9,19 +9,13 @@ fr: code_postal_notice: Il est généralement composé de 5 chiffres. header: expires_at: - brouillon: "Expirera le %{date}" - en_construction: "Expirera le %{date}" + brouillon: "Expirera le %{date} (%{duree_conservation_totale} mois après la création du dossier)" + en_construction: "Expirera le %{date} (%{duree_conservation_totale} mois après la dernière date d'édition)" en_instruction: "Ce dossier est en instruction, il n'expirera pas" - accepte: "Expirera le %{date}" - refuse: "Expirera le %{date}" - sans_suite: "Expirera le %{date}" - banner: - title: Votre dossier va expirer - states: - brouillon: Votre dossier est en brouillon, mais va bientôt expirer. Cela signifie qu’il va bientôt être supprimé sans avoir été déposé. Si vous souhaitez le conserver afin de poursuivre la démarche, vous pouvez le conserver un mois de plus en cliquant sur le bouton ci-dessous. - en_construction: Votre dossier est en attente de prise en charge par l'administration. Le delais de prise en charge maximale est de 6 mois. Vous pouvez toutefois entendre cette durée d'un mois en cliquant sur le bouton suivant. - termine: Le traitement de votre dossier est terminé, mais il va bientôt expirer. Cela signifie qu’il va bientôt être supprimé. Si vous souhaitez conserver une trace, vous pouvez le télécharger au format PDF. - button_delay_expiration: "Repousser sa suppression" + accepte: "Expirera le %{date} (%{duree_conservation_totale} mois après l'acceptation du dossier)" + refuse: "Expirera le %{date} (%{duree_conservation_totale} mois après le refus du dossier)" + sans_suite: "Expirera le %{date} (%{duree_conservation_totale} mois après que le dossier aie été classé sans suite)" + champs: cnaf: diff --git a/config/locales/views/instructeurs/header/en.yml b/config/locales/views/instructeurs/header/en.yml new file mode 100644 index 000000000..44ee0126a --- /dev/null +++ b/config/locales/views/instructeurs/header/en.yml @@ -0,0 +1,11 @@ +en: + instructeurs: + dossiers: + header: + banner: + title: This file will expire + states: + brouillon: "" # not applicable, instructeur does not see brouillons + en_construction: This file is pending for instruction. The maximum delay is 6 months, you can extend the duration by a month by clicking on the underneath button. + termine: This file had been processed and will soon expire. So it will be deleted soon. If you want to keep it, you can dowload a PDF file of it. + button_delay_expiration: "Delay deletion" diff --git a/config/locales/views/instructeurs/header/fr.yml b/config/locales/views/instructeurs/header/fr.yml new file mode 100644 index 000000000..2248ed793 --- /dev/null +++ b/config/locales/views/instructeurs/header/fr.yml @@ -0,0 +1,11 @@ +fr: + instructeurs: + dossiers: + header: + banner: + title: Ce dossier va expirer + states: + brouillon: "" # not applicable, instructeur does not see brouillons + en_construction: Ce dossier est en attente de prise en charge. Vous pouvez toutefois entendre cette durée d'un mois en cliquant sur le bouton suivant. + termine: Le traitement de ce dossier est terminé, mais il va bientôt expirer. Cela signifie qu’il va bientôt être supprimé. Si vous souhaitez conserver une trace, vous pouvez le télécharger au format PDF. + button_delay_expiration: "Repousser sa suppression" diff --git a/config/locales/views/users/header/en.yml b/config/locales/views/users/header/en.yml new file mode 100644 index 000000000..b8e533c40 --- /dev/null +++ b/config/locales/views/users/header/en.yml @@ -0,0 +1,11 @@ +en: + users: + dossiers: + header: + banner: + title: Your file will expire + states: + brouillon: Your file is still in draft and will soon expire. So it will be deleted soon without being instructed. If you want to pursue your procedure you can submit it now. Otherwise you are able to delay its expiration by clicking on the underneath button. + en_construction: Your file is pending for instruction. The maximum delay is 6 months, but you can extend the duration by a month by clicking on the underneath button. + termine: Your file had been processed and will soon expire. So it will be deleted soon. If you want to keep it, you can dowload a PDF file of it. + button_delay_expiration: "Delay deletion" diff --git a/config/locales/views/users/header/fr.yml b/config/locales/views/users/header/fr.yml new file mode 100644 index 000000000..3749b98a9 --- /dev/null +++ b/config/locales/views/users/header/fr.yml @@ -0,0 +1,11 @@ +fr: + users: + dossiers: + header: + banner: + title: Votre dossier va expirer + states: + brouillon: Votre dossier est en brouillon, mais va bientôt expirer. Cela signifie qu’il va bientôt être supprimé sans avoir été déposé. Si vous souhaitez le conserver afin de poursuivre la démarche, vous pouvez le conserver un mois de plus en cliquant sur le bouton ci-dessous. + en_construction: Votre dossier est en attente de prise en charge par l'administration. Le delais de prise en charge maximale est de 6 mois. Vous pouvez toutefois entendre cette durée d'un mois en cliquant sur le bouton suivant. + termine: Le traitement de votre dossier est terminé, mais il va bientôt expirer. Cela signifie qu’il va bientôt être supprimé. Si vous souhaitez conserver une trace, vous pouvez le télécharger au format PDF. + button_delay_expiration: "Repousser sa suppression" diff --git a/spec/models/instructeur_spec.rb b/spec/models/instructeur_spec.rb index 7cdfd8304..874beb40a 100644 --- a/spec/models/instructeur_spec.rb +++ b/spec/models/instructeur_spec.rb @@ -719,8 +719,8 @@ describe Instructeur, type: :model do it { expect(subject['a_suivre']).to eq(0) } it { expect(subject['suivis']).to eq(0) } - it { expect(subject['traites']).to eq(2) } - it { expect(subject['tous']).to eq(2) } + it { expect(subject['traites']).to eq(1) } + it { expect(subject['tous']).to eq(1) } it { expect(subject['archives']).to eq(0) } it { expect(subject['expirant']).to eq(0) } end diff --git a/spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb b/spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb new file mode 100644 index 000000000..e1434fb5f --- /dev/null +++ b/spec/views/instructeur/dossiers/_expiration_banner.html.haml_spec.rb @@ -0,0 +1,66 @@ +describe 'instructeur/dossiers/expiration_banner.html.haml', type: :view do + include DossierHelper + let(:duree_conservation_dossiers_dans_ds) { 3 } + let(:dossier) do + create(:dossier, state, attributes.merge( + id: 1, + state: state, + procedure: create(:procedure, procedure_expires_when_termine_enabled: expiration_enabled, duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds) + )) + end + let(:i18n_key_state) { state } + subject do + render('instructeurs/dossiers/expiration_banner.html.haml', + dossier: dossier, + current_user: build(:user)) + end + + context 'with procedure having procedure_expires_when_termine_enabled not enabled' do + let(:expiration_enabled) { false } + let(:attributes) { { processed_at: 6.months.ago } } + let(:state) { :accepte } + + it 'render estimated expiration date' do + expect(subject).not_to have_selector('.expires_at') + end + end + + context 'with procedure having procedure_expires_when_termine_enabled enabled' do + let(:expiration_enabled) { true } + + context 'with dossier.en_construction?' do + let(:attributes) { { en_construction_at: 6.months.ago } } + let(:state) { :en_construction } + + it 'render estimated expiration date' do + expect(subject).to have_selector('.expires_at', + text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}", + date: safe_expiration_date(dossier), + duree_conservation_totale: duree_conservation_dossiers_dans_ds)) + end + end + + context 'with dossier.en_instruction?' do + let(:state) { :en_instruction } + let(:attributes) { {} } + + it 'render estimated expiration date' do + expect(subject).to have_selector('p.expires_at_en_instruction', + text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}")) + end + end + + context 'with dossier.en_processed_at?' do + let(:state) { :accepte } + let(:attributes) { {} } + + it 'render estimated expiration date' do + allow(dossier).to receive(:processed_at).and_return(6.months.ago) + expect(subject).to have_selector('.expires_at', + text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}", + date: safe_expiration_date(dossier), + duree_conservation_totale: duree_conservation_dossiers_dans_ds)) + end + end + end +end diff --git a/spec/views/instructeur/procedures/_header.html.haml_spec.rb b/spec/views/instructeur/procedures/_header.html.haml_spec.rb index a9da674d0..8e1734994 100644 --- a/spec/views/instructeur/procedures/_header.html.haml_spec.rb +++ b/spec/views/instructeur/procedures/_header.html.haml_spec.rb @@ -1,5 +1,7 @@ describe 'instructeurs/procedures/_header.html.haml', type: :view do - let(:procedure) { create(:procedure, id: 1, procedure_expires_when_termine_enabled: expiration_enabled)} + let(:procedure) { create(:procedure, id: 1, procedure_expires_when_termine_enabled: expiration_enabled) } + + before { allow(view).to receive(:current_instructeur).and_return(create(:instructeur)) } subject do render('instructeurs/procedures/header.html.haml', @@ -12,8 +14,7 @@ describe 'instructeurs/procedures/_header.html.haml', type: :view do archives_count: 0, expirant_count: 0, has_en_cours_notifications: false, - has_termine_notifications: false, - current_instructeur: build_stubbed(:instructeur)) + has_termine_notifications: false) end context 'when procedure_expires_when_termine_enabled is true' do diff --git a/spec/views/instructeur/procedures/_list.html.haml_spec.rb b/spec/views/instructeur/procedures/_list.html.haml_spec.rb index 513013386..7de854f9a 100644 --- a/spec/views/instructeur/procedures/_list.html.haml_spec.rb +++ b/spec/views/instructeur/procedures/_list.html.haml_spec.rb @@ -1,5 +1,5 @@ describe 'instructeurs/procedures/_list.html.haml', type: :view do - let(:procedure) { create(:procedure, id: 1, procedure_expires_when_termine_enabled: expiration_enabled)} + let(:procedure) { create(:procedure, id: 1, procedure_expires_when_termine_enabled: expiration_enabled) } subject do render('instructeurs/procedures/list.html.haml', diff --git a/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb b/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb index 30d3bef90..8bf0c3d51 100644 --- a/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb +++ b/spec/views/users/dossiers/_expiration_banner.html.haml_spec.rb @@ -1,11 +1,12 @@ describe 'users/dossiers/expiration_banner.html.haml', type: :view do include DossierHelper - + let(:duree_conservation_dossiers_dans_ds) { 3 } let(:dossier) do create(:dossier, state, attributes.merge( id: 1, state: state, - procedure: create(:procedure, procedure_expires_when_termine_enabled: expiration_enabled) + conservation_extension: 1, + procedure: create(:procedure, procedure_expires_when_termine_enabled: expiration_enabled, duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds) )) end let(:i18n_key_state) { state } @@ -35,7 +36,8 @@ describe 'users/dossiers/expiration_banner.html.haml', type: :view do it 'render estimated expiration date' do expect(subject).to have_selector('.expires_at', text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}", - date: safe_expiration_date(dossier))) + date: safe_expiration_date(dossier), + duree_conservation_totale: duree_conservation_dossiers_dans_ds)) end end @@ -46,7 +48,8 @@ describe 'users/dossiers/expiration_banner.html.haml', type: :view do it 'render estimated expiration date' do expect(subject).to have_selector('.expires_at', text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}", - date: safe_expiration_date(dossier))) + date: safe_expiration_date(dossier), + duree_conservation_totale: duree_conservation_dossiers_dans_ds)) end end @@ -68,7 +71,8 @@ describe 'users/dossiers/expiration_banner.html.haml', type: :view do allow(dossier).to receive(:processed_at).and_return(6.months.ago) expect(subject).to have_selector('.expires_at', text: I18n.t("shared.dossiers.header.expires_at.#{i18n_key_state}", - date: safe_expiration_date(dossier))) + date: safe_expiration_date(dossier), + duree_conservation_totale: duree_conservation_dossiers_dans_ds)) end end end