diff --git a/app/components/dossiers/accuse_lecture_component.rb b/app/components/dossiers/accuse_lecture_component.rb new file mode 100644 index 000000000..78fe76f7f --- /dev/null +++ b/app/components/dossiers/accuse_lecture_component.rb @@ -0,0 +1,5 @@ +class Dossiers::AccuseLectureComponent < ApplicationComponent + def initialize(dossier:) + @dossier = dossier + end +end diff --git a/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.en.yml b/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.en.yml new file mode 100644 index 000000000..e7885eab3 --- /dev/null +++ b/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.en.yml @@ -0,0 +1,4 @@ +--- +en: + text_accuse_lecture: This procedure is subject to a reading acknowledgment. By requesting the display of the decision taken on your file, you accept the reading acknowledgment and thereby the triggering of the legal deadline in the event of an appeal. + btn_accuse_lecture: I would like to display the decision diff --git a/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.fr.yml b/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.fr.yml new file mode 100644 index 000000000..509404dbe --- /dev/null +++ b/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.fr.yml @@ -0,0 +1,4 @@ +--- +fr: + text_accuse_lecture: Cette procédure est soumise à un accusé de lecture. En demandant l'affichage de la décision prise sur votre dossier, vous acceptez l'accusé de lecture et par là même le démarrage du délai légal en cas de recours. + btn_accuse_lecture: Je souhaite afficher la décision diff --git a/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.html.haml b/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.html.haml new file mode 100644 index 000000000..d8722f95f --- /dev/null +++ b/app/components/dossiers/accuse_lecture_component/accuse_lecture_component.html.haml @@ -0,0 +1,10 @@ += render Dsfr::CalloutComponent.new(title: nil) do |c| + - c.with_body do + = t('.text_accuse_lecture') + + = form_for @dossier, + method: :get, + url: set_accuse_lecture_agreement_at_dossier_path(@dossier), + data: { controller: 'autosubmit', turbo: 'true' } do |f| + + = f.submit t('.btn_accuse_lecture'), class: "fr-btn fr-mt-2w" diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 7c9be0b1f..4885127d5 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1180,6 +1180,10 @@ class Dossier < ApplicationRecord end end + def hide_info_with_accuse_lecture + procedure.accuse_lecture? && termine? && accuse_lecture_agreement_at.blank? + end + private def champs_by_public_id diff --git a/app/views/shared/dossiers/_demande.html.haml b/app/views/shared/dossiers/_demande.html.haml index edaa7d4f5..2948c57d8 100644 --- a/app/views/shared/dossiers/_demande.html.haml +++ b/app/views/shared/dossiers/_demande.html.haml @@ -9,7 +9,7 @@ .flex-grow.fr-py-3v.fr-px-2w= t('views.shared.dossiers.demande.en_construction') - if dossier.depose_at.present? - = render partial: "shared/dossiers/infos_generales", locals: { dossier: dossier } + = render partial: "shared/dossiers/infos_generales", locals: { dossier: dossier, profile: profile } - if dossier.for_tiers? diff --git a/app/views/shared/dossiers/_infos_generales.html.haml b/app/views/shared/dossiers/_infos_generales.html.haml index d9f54812b..854516574 100644 --- a/app/views/shared/dossiers/_infos_generales.html.haml +++ b/app/views/shared/dossiers/_infos_generales.html.haml @@ -9,18 +9,22 @@ .fr-highlight %p.fr-text--sm.fr-text-mention--grey Sauf mention contraire, les champs ont été saisis à la date du dépôt du dossier. - - if dossier.justificatif_motivation.attached? - = render Dossiers::RowShowComponent.new(label: "Justificatif") do |c| - - c.with_value do - .action - = render Attachment::ShowComponent.new(attachment: dossier.justificatif_motivation.attachment) + - if profile == 'usager' && dossier.hide_info_with_accuse_lecture + = render Dossiers::AccuseLectureComponent.new(dossier: dossier) - - if dossier.motivation.present? - = render Dossiers::RowShowComponent.new(label: "Motivation") do |c| - - c.with_value do - = simple_format dossier.motivation + - else + - if dossier.justificatif_motivation.attached? + = render Dossiers::RowShowComponent.new(label: "Justificatif") do |c| + - c.with_value do + .action + = render Attachment::ShowComponent.new(attachment: dossier.justificatif_motivation.attachment) - - if dossier.attestation.present? && dossier.attestation.pdf.attached? - = render Dossiers::RowShowComponent.new(label: "Attestation") do |c| - - c.with_value do - = render Dsfr::DownloadComponent.new(attachment: dossier.attestation.pdf, name: t(:download_attestation, scope: [:views, :shared, :dossiers, :form])) + - if dossier.motivation.present? + = render Dossiers::RowShowComponent.new(label: "Motivation") do |c| + - c.with_value do + = simple_format dossier.motivation + + - if dossier.attestation.present? && dossier.attestation.pdf.attached? + = render Dossiers::RowShowComponent.new(label: "Attestation") do |c| + - c.with_value do + = render Dsfr::DownloadComponent.new(attachment: dossier.attestation.pdf, name: t(:download_attestation, scope: [:views, :shared, :dossiers, :form])) diff --git a/app/views/users/dossiers/show/_status_overview.html.haml b/app/views/users/dossiers/show/_status_overview.html.haml index 21b7b8a8f..85210c734 100644 --- a/app/views/users/dossiers/show/_status_overview.html.haml +++ b/app/views/users/dossiers/show/_status_overview.html.haml @@ -55,17 +55,8 @@ = t('views.users.dossiers.show.status_overview.use_mailbox_for_questions_html', mailbox_url: messagerie_dossier_url(dossier)) - elsif dossier.termine? - - if dossier.procedure.accuse_lecture? && !dossier.accuse_lecture_agreement_at.present? - = render Dsfr::CalloutComponent.new(title: nil) do |c| - - c.with_body do - Cette procédure est soumise à un accusé de lecture. En demandant l'affichage de la décision prise sur votre dossier, vous acceptez l'accusé de lecture et par là même le démarrage du délai légal en cas de recours. - - = form_for dossier, - method: :get, - url: set_accuse_lecture_agreement_at_dossier_path(dossier), - data: { controller: 'autosubmit', turbo: 'true' } do |f| - - = f.submit "Je souhaite afficher la décision", class: "fr-btn fr-mt-2w" + - if dossier.hide_info_with_accuse_lecture + = render Dossiers::AccuseLectureComponent.new(dossier: dossier) - elsif dossier.accepte? .accepte diff --git a/spec/views/users/dossiers/demande.html.haml_spec.rb b/spec/views/users/dossiers/demande.html.haml_spec.rb index 55d185dff..b45a788b1 100644 --- a/spec/views/users/dossiers/demande.html.haml_spec.rb +++ b/spec/views/users/dossiers/demande.html.haml_spec.rb @@ -59,4 +59,22 @@ describe 'users/dossiers/demande', type: :view do expect(rendered).to have_text(dossier.individual.email.to_s) end end + + context 'when a dossier is accepte with motivation' do + let(:dossier) { create(:dossier, :accepte, :with_motivation) } + + it 'displays the motivation' do + expect(rendered).not_to have_text('Cette procédure est soumise à un accusé de lecture.') + expect(rendered).to have_text('Motivation') + end + end + + context 'when a dossier is accepte with motivation and with accuse de lecture' do + let(:dossier) { create(:dossier, :accepte, :with_motivation, procedure: create(:procedure, :accuse_lecture)) } + + it 'display information about accuse de lecture and not the motivation' do + expect(rendered).to have_text('Cette procédure est soumise à un accusé de lecture.') + expect(rendered).not_to have_text('Motivation') + end + end end