add AR in user view - hide decision on first dossier tab

This commit is contained in:
Lisa Durand 2024-03-25 14:08:46 +01:00
parent ae08044ff2
commit 8eda069bfc
6 changed files with 71 additions and 36 deletions

View file

@ -124,6 +124,13 @@ module Users
@dossier = dossier
end
def set_accuse_lecture_agreement_at
@dossier = dossier
@dossier.update!(accuse_lecture_agreement_at: Time.zone.now)
flash.notice = 'Accusé de lecture accepté'
redirect_back(fallback_location: demande_dossier_path(@dossier))
end
def identite
@dossier = dossier
@user = current_user

View file

@ -54,46 +54,59 @@
%p
= t('views.users.dossiers.show.status_overview.use_mailbox_for_questions_html', mailbox_url: messagerie_dossier_url(dossier))
- elsif dossier.accepte?
.accepte
%p.decision{ role: 'status' }
= dsfr_icon('fr-icon-checkbox-circle-fill fr-text-default--success')
= t('views.users.dossiers.show.status_overview.acceptee_html')
- 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.
- if dossier.motivation.present?
%h3= t('views.users.dossiers.show.status_overview.accepte_motivation')
%blockquote= simple_format(dossier.motivation)
= form_for dossier,
method: :get,
url: set_accuse_lecture_agreement_at_dossier_path(dossier),
data: { controller: 'autosubmit', turbo: 'true' } do |f|
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
= f.submit "Je souhaite afficher la décision", class: "fr-btn fr-mt-2w"
- if dossier.attestation.present?
- elsif dossier.accepte?
.accepte
%p.decision{ role: 'status' }
= dsfr_icon('fr-icon-checkbox-circle-fill fr-text-default--success')
= t('views.users.dossiers.show.status_overview.acceptee_html')
- if dossier.motivation.present?
%h3= t('views.users.dossiers.show.status_overview.accepte_motivation')
%blockquote= simple_format(dossier.motivation)
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
- if dossier.attestation.present?
.action
= link_to attestation_dossier_path(dossier), class: "fr-btn fr-icon-download-line fr-btn--icon-left", target: '_blank', rel: 'noopener' do
= t('views.users.dossiers.show.status_overview.accepte_attestation')
- elsif dossier.refuse?
.refuse
%p.decision{ role: 'status' }
= dsfr_icon('fr-icon-close-circle-fill fr-text-default--error')
= t('views.users.dossiers.show.status_overview.refuse_html')
- if dossier.motivation.present?
%h3= t('views.users.dossiers.show.status_overview.refuse_motivation')
%blockquote= simple_format(dossier.motivation)
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
.action
= link_to attestation_dossier_path(dossier), class: "fr-btn fr-icon-download-line fr-btn--icon-left", target: '_blank', rel: 'noopener' do
= t('views.users.dossiers.show.status_overview.accepte_attestation')
= link_to t('views.users.dossiers.show.status_overview.refuse_reply'), messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'fr-link'
- elsif dossier.sans_suite?
.sans-suite
%p.decision{ role: 'status' }
= dsfr_icon('fr-icon-intermediate-circle-fill')
= t('views.users.dossiers.show.status_overview.sans_suite_html')
- elsif dossier.refuse?
.refuse
%p.decision{ role: 'status' }
= dsfr_icon('fr-icon-close-circle-fill fr-text-default--error')
= t('views.users.dossiers.show.status_overview.refuse_html')
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
- if dossier.motivation.present?
%h3= t('views.users.dossiers.show.status_overview.refuse_motivation')
%blockquote= simple_format(dossier.motivation)
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
.action
= link_to t('views.users.dossiers.show.status_overview.refuse_reply'), messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'fr-link'
- elsif dossier.sans_suite?
.sans-suite
%p.decision{ role: 'status' }
= dsfr_icon('fr-icon-intermediate-circle-fill')
= t('views.users.dossiers.show.status_overview.sans_suite_html')
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
- if dossier.motivation.present?
%h3= t('views.users.dossiers.show.status_overview.sans_suite_motivation')
%blockquote= simple_format(dossier.motivation)
- if dossier.motivation.present?
%h3= t('views.users.dossiers.show.status_overview.sans_suite_motivation')
%blockquote= simple_format(dossier.motivation)

View file

@ -369,6 +369,7 @@ Rails.application.routes.draw do
get 'attestation'
get 'transferer', to: 'dossiers#transferer'
get 'papertrail', format: :pdf
get 'set_accuse_lecture_agreement_at'
end
collection do

View file

@ -0,0 +1,5 @@
class AddAccuseLectureAgreementToDossiers < ActiveRecord::Migration[7.0]
def change
add_column :dossiers, :accuse_lecture_agreement_at, :date
end
end

View file

@ -441,6 +441,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_11_164502) do
end
create_table "dossiers", id: :serial, force: :cascade do |t|
t.date "accuse_lecture_agreement_at"
t.string "api_entreprise_job_exceptions", array: true
t.boolean "archived", default: false
t.datetime "archived_at", precision: nil

View file

@ -92,4 +92,12 @@ describe 'users/dossiers/show/_status_overview', type: :view do
it { is_expected.to have_selector('.status-explanation .sans-suite') }
it { is_expected.to have_text(dossier.motivation) }
end
context 'when terminé but the procedure has an accuse de lecture' do
let(:dossier) { create(:dossier, :sans_suite, :with_motivation, procedure: create(:procedure, :accuse_lecture)) }
it { is_expected.not_to have_selector('.status-explanation .sans-suite') }
it { is_expected.not_to have_text(dossier.motivation) }
it { is_expected.to have_text('Cette procédure est soumise à un accusé de lecture.') }
end
end