From 217793c5c89aef90699f6fad8faa68c4d2ad02b7 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Tue, 22 Mar 2022 15:00:17 +0100 Subject: [PATCH 1/4] modify model --- app/models/dossier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 095b47c07..2602fee6d 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -504,7 +504,7 @@ class Dossier < ApplicationRecord end def read_only? - en_instruction? || accepte? || refuse? || sans_suite? + en_instruction? || accepte? || refuse? || sans_suite? || procedure.discarded? || procedure.close? && brouillon? end def can_transition_to_en_construction? From b08011cff70cf785878960a310b0b1aa36658218 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Tue, 22 Mar 2022 15:00:26 +0100 Subject: [PATCH 2/4] layout --- app/assets/stylesheets/card.scss | 6 +++++ app/views/shared/dossiers/_header.html.haml | 7 +++--- .../_procedure_removed_banner.html.haml | 22 +++++++++++++++++++ .../users/dossiers/show/_header.html.haml | 12 ++++------ .../dossiers/show/_print_dossier.html.haml | 6 +++++ 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 app/views/users/dossiers/_procedure_removed_banner.html.haml create mode 100644 app/views/users/dossiers/show/_print_dossier.html.haml diff --git a/app/assets/stylesheets/card.scss b/app/assets/stylesheets/card.scss index ff90ff483..0a772dc09 100644 --- a/app/assets/stylesheets/card.scss +++ b/app/assets/stylesheets/card.scss @@ -53,6 +53,12 @@ } } + &.no-list { + ul { + list-style: none !important; + } + } + ul { list-style-type: disc; list-style-position: inside; diff --git a/app/views/shared/dossiers/_header.html.haml b/app/views/shared/dossiers/_header.html.haml index dbffd3434..ce1a700dc 100644 --- a/app/views/shared/dossiers/_header.html.haml +++ b/app/views/shared/dossiers/_header.html.haml @@ -8,7 +8,8 @@ = render(partial: 'users/dossiers/expiration_banner', locals: {dossier: dossier}) - .header-actions - - if current_user.owns?(dossier) + - if current_user.owns?(dossier) && !dossier.procedure.discarded? && !dossier.procedure.close? + .header-actions = render partial: 'invites/dropdown', locals: { dossier: dossier } - + - else + = render(partial: 'users/dossiers/procedure_removed_banner', locals: { dossier: dossier }) diff --git a/app/views/users/dossiers/_procedure_removed_banner.html.haml b/app/views/users/dossiers/_procedure_removed_banner.html.haml new file mode 100644 index 000000000..db410b2b7 --- /dev/null +++ b/app/views/users/dossiers/_procedure_removed_banner.html.haml @@ -0,0 +1,22 @@ +.card.warning.mb-3.no-list + - if dossier.procedure.discarded? + .flex.justify-between + .card-title= t('users.dossiers.header.banner.procedure_deleted_title') + = render(partial: 'users/dossiers/show/print_dossier', locals: { dossier: dossier}) if !dossier.brouillon? + - if dossier.termine? + %p + = t('users.dossiers.header.banner.procedure_deleted_dossier_termine_content') + - elsif dossier.brouillon? + %p + = t('users.dossiers.header.banner.procedure_close_content') + - else + %p + = t('users.dossiers.header.banner.procedure_deleted_dossier_en_cours_content') + + - else + .flex.justify-between + .card-title= t('users.dossiers.header.banner.procedure_close_title') + = render(partial: 'users/dossiers/show/print_dossier', locals: { dossier: dossier }) if !dossier.brouillon? + %p + = t('users.dossiers.header.banner.procedure_close_content') + diff --git a/app/views/users/dossiers/show/_header.html.haml b/app/views/users/dossiers/show/_header.html.haml index 4670a9811..19b2b0e39 100644 --- a/app/views/users/dossiers/show/_header.html.haml +++ b/app/views/users/dossiers/show/_header.html.haml @@ -12,19 +12,15 @@ = render(partial: 'users/dossiers/expiration_banner', locals: {dossier: dossier}) - - - if current_user.owns?(dossier) + - if (current_user.owns?(dossier) && !dossier.procedure.discarded?) || (!dossier.procedure.discarded? && !dossier.procedure.close? && !dossier.en_construction?) .header-actions = render partial: 'invites/dropdown', locals: { dossier: dossier } - if dossier.can_be_updated_by_user? && !current_page?(modifier_dossier_path(dossier)) = link_to t('views.users.dossiers.show.header.edit_dossier'), modifier_dossier_path(dossier), class: 'button accepted edit-form', 'title'=> "Vous pouvez modifier votre dossier tant qu'il n'est passé en instruction" - %span.dropdown.print-menu-opener - %button.button.dropdown-button.icon-only{ title: t('views.users.dossiers.show.header.print'), 'aria-label': 'imprimer', 'aria-expanded' => 'false', 'aria-controls' => 'print-menu' } - %span.icon.printer - %ul#print-menu.print-menu.dropdown-content - %li - = link_to t('views.users.dossiers.show.header.print_dossier'), dossier_path(dossier, format: :pdf), target: "_blank", rel: "noopener", class: "menu-item menu-link" + = render(partial: 'users/dossiers/show/print_dossier', locals: { dossier: dossier }) + - else + = render(partial: 'users/dossiers/procedure_removed_banner', locals: { dossier: dossier }) %nav.tabs %ul diff --git a/app/views/users/dossiers/show/_print_dossier.html.haml b/app/views/users/dossiers/show/_print_dossier.html.haml new file mode 100644 index 000000000..8f1aa0904 --- /dev/null +++ b/app/views/users/dossiers/show/_print_dossier.html.haml @@ -0,0 +1,6 @@ +%span.dropdown.print-menu-opener + %button.button.dropdown-button.icon-only{ title: t('views.users.dossiers.show.header.print'), 'aria-label': 'imprimer', 'aria-expanded' => 'false', 'aria-controls' => 'print-menu' } + %span.icon.printer + %ul#print-menu.print-menu.dropdown-content + %li + = link_to t('views.users.dossiers.show.header.print_dossier'), dossier_path(dossier, format: :pdf), target: "_blank", rel: "noopener", class: "menu-item menu-link" From 516bfa86cf2d41dbf5af82ddca1625e2bc30a355 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Tue, 22 Mar 2022 15:00:33 +0100 Subject: [PATCH 3/4] locale --- config/locales/views/users/header/fr.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/locales/views/users/header/fr.yml b/config/locales/views/users/header/fr.yml index 5d2af1fad..1ebab82d7 100644 --- a/config/locales/views/users/header/fr.yml +++ b/config/locales/views/users/header/fr.yml @@ -3,6 +3,11 @@ fr: dossiers: header: banner: + procedure_deleted_title: "La démarche liée à votre dossier est supprimée" + procedure_close_title: "La démarche liée à votre dossier est close" + procedure_deleted_dossier_en_cours_content: "Vous pouvez toujours consulter votre dossier, mais il n’est plus possible de le modifier." + procedure_deleted_dossier_termine_content: "Votre dossier a été traité par l'administration, aucune action n'est possible" + procedure_close_content: "Vous pouvez toujours consulter votre dossier, mais il ne sera pas traité par l'administration" 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. From 71614d4ba370d1467f50c39371ae2dc0109c4856 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Wed, 23 Mar 2022 08:03:08 +0100 Subject: [PATCH 4/4] tests --- .../shared/dossiers/_header.html.haml.spec.rb | 34 +++++++++++++++ .../dossiers/show/_header.html.haml_spec.rb | 41 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 spec/views/shared/dossiers/_header.html.haml.spec.rb diff --git a/spec/views/shared/dossiers/_header.html.haml.spec.rb b/spec/views/shared/dossiers/_header.html.haml.spec.rb new file mode 100644 index 000000000..648fdb365 --- /dev/null +++ b/spec/views/shared/dossiers/_header.html.haml.spec.rb @@ -0,0 +1,34 @@ +describe 'dossiers/show/header.html.haml', type: :view do + let(:procedure) { create(:procedure, :discarded) } + let(:dossier) { create(:dossier, state: "brouillon", procedure: procedure) } + + before do + sign_in dossier.user + end + + subject! { render 'shared/dossiers/header.html.haml', dossier: dossier } + + context "when the procedure is discarded with a dossier en brouillon" do + it 'affiche que la démarche est supprimée' do + expect(rendered).to have_text("La démarche liée à votre dossier est supprimée") + expect(rendered).to have_text("Vous pouvez toujours consulter votre dossier, mais il ne sera pas traité par l'administration") + end + + it 'cannot download the dossier' do + expect(rendered).not_to have_text("Tout le dossier") + end + end + + context "when the procedure is closed with a dossier en brouillon" do + let(:procedure) { create(:procedure, :closed) } + + it 'affiche que la démarche est close' do + expect(rendered).to have_text("La démarche liée à votre dossier est close") + expect(rendered).to have_text("Vous pouvez toujours consulter votre dossier, mais il ne sera pas traité par l'administration") + end + + it 'cannot download the dossier' do + expect(rendered).not_to have_text("Tout le dossier") + end + end +end diff --git a/spec/views/users/dossiers/show/_header.html.haml_spec.rb b/spec/views/users/dossiers/show/_header.html.haml_spec.rb index 69cc5b371..660a09a3c 100644 --- a/spec/views/users/dossiers/show/_header.html.haml_spec.rb +++ b/spec/views/users/dossiers/show/_header.html.haml_spec.rb @@ -16,4 +16,45 @@ describe 'users/dossiers/show/header.html.haml', type: :view do expect(rendered).to have_link("Résumé", href: dossier_path(dossier)) expect(rendered).to have_link("Demande", href: demande_dossier_path(dossier)) end + + context "when the procedure is closed with a dossier en construction" do + let(:procedure) { create(:procedure, :closed) } + let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } + + it "n'affiche pas de banner" do + expect(rendered).not_to have_text("La démarche liée à votre dossier est close") + end + + it 'can download the dossier' do + expect(rendered).to have_text("Tout le dossier") + end + end + + context "when the procedure is discarded with a dossier en construction" do + let(:procedure) { create(:procedure, :discarded) } + let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } + + it 'affiche que la démarche est supprimée' do + expect(rendered).to have_text("La démarche liée à votre dossier est supprimée") + expect(rendered).to have_text("Vous pouvez toujours consulter votre dossier, mais il n’est plus possible de le modifier") + end + + it 'can download the dossier' do + expect(rendered).to have_text("Tout le dossier") + end + end + + context "when the procedure is discarded with a dossier terminé" do + let(:procedure) { create(:procedure, :discarded) } + let(:dossier) { create(:dossier, state: "accepte", procedure: procedure) } + + it 'affiche que la démarche est supprimée' do + expect(rendered).to have_text("La démarche liée à votre dossier est supprimée") + expect(rendered).to have_text("Votre dossier a été traité par l'administration, aucune action n'est possible") + end + + it 'can download the dossier' do + expect(rendered).to have_text("Tout le dossier") + end + end end