feat(instructeurs/procedure/dossiers#extend_conservation): add extends duree conservation in action button list, also rewire this action for user [extend by procedure.duree_conservation_dans_ds by default] but force 1.month for instructeur. add new icon for standby based on https://en.wikipedia.org/wiki/Power_symbol
This commit is contained in:
parent
d8a8d1fdab
commit
081d5094a9
21 changed files with 106 additions and 27 deletions
1
app/assets/images/icons/standby.svg
Normal file
1
app/assets/images/icons/standby.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg height="202" viewBox="-.8 -.5 177 202" width="177" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="30"><path d="m33.7 64.3c-11.6 12.9-18.7 30-18.7 48.7 0 40.1 32.5 72.7 72.7 72.7 40.1 0 72.7-32.5 72.7-72.7 0-18.7-7.1-35.8-18.7-48.7"/><path d="m87.8 15v98"/></g></svg>
|
After Width: | Height: | Size: 334 B |
|
@ -19,6 +19,10 @@
|
|||
background-image: image-url("icons/unfollow-folder.svg");
|
||||
}
|
||||
|
||||
&.standby {
|
||||
background-image: image-url("icons/standby.svg");
|
||||
}
|
||||
|
||||
&.archive {
|
||||
background-image: image-url("icons/archive.svg");
|
||||
}
|
||||
|
|
|
@ -19,6 +19,12 @@ module Instructeurs
|
|||
end
|
||||
end
|
||||
|
||||
def extend_conservation
|
||||
dossier.update(conservation_extension: dossier.conservation_extension + 1.month)
|
||||
flash[:notice] = t('views.instructeurs.dossiers.archived_dossier')
|
||||
redirect_back(fallback_location: instructeur_dossier_path(@dossier.procedure, @dossier))
|
||||
end
|
||||
|
||||
def geo_data
|
||||
send_data dossier.to_feature_collection.to_json,
|
||||
type: 'application/json',
|
||||
|
|
|
@ -168,9 +168,9 @@ module Users
|
|||
end
|
||||
|
||||
def extend_conservation
|
||||
dossier.update(conservation_extension: dossier.conservation_extension + 1.month)
|
||||
flash[:notice] = t('.archived_dossier')
|
||||
redirect_to dossier_path(@dossier)
|
||||
dossier.update(conservation_extension: dossier.conservation_extension + dossier.procedure.duree_conservation_dossiers_dans_ds.months)
|
||||
flash[:notice] = t('views.users.dossiers.archived_dossier', duree_conservation_dossiers_dans_ds: dossier.procedure.duree_conservation_dossiers_dans_ds)
|
||||
redirect_back(fallback_location: dossier_path(@dossier))
|
||||
end
|
||||
|
||||
def modifier
|
||||
|
|
|
@ -569,6 +569,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def close_to_expiration?
|
||||
return false if en_instruction?
|
||||
approximative_expiration_date < Time.zone.now
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
- 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)
|
||||
%small
|
||||
= t("shared.dossiers.header.expires_at.#{dossier.state}", date: safe_expiration_date(dossier), duree_conservation_totale: dossier.duree_totale_conservation_in_months)
|
||||
- if dossier.conservation_extension.positive?
|
||||
= t('instructeurs.dossiers.header.banner.expiration_date_extended')
|
||||
-# big banner warning
|
||||
- if dossier.close_to_expiration?
|
||||
.card.warning.mb-3
|
||||
|
@ -17,7 +20,9 @@
|
|||
|
||||
- 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'
|
||||
= button_to repousser_expiration_instructeur_dossier_path(dossier.procedure, dossier), class: 'button mt-2', id: 'test-instructeur-repousser-expiration' do
|
||||
%span.icon.standby
|
||||
= t('instructeurs.dossiers.header.banner.button_delay_expiration')
|
||||
|
||||
|
||||
- else
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
dossier_id: dossier.id,
|
||||
state: dossier.state,
|
||||
archived: dossier.archived,
|
||||
dossier_is_followed: current_instructeur&.follow?(dossier) }
|
||||
dossier_is_followed: current_instructeur&.follow?(dossier),
|
||||
close_to_expiration: dossier.close_to_expiration? }
|
||||
|
||||
|
||||
.state-button
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
- if Dossier::TERMINE.include?(state)
|
||||
- if close_to_expiration || Dossier::TERMINE.include?(state)
|
||||
.dropdown.user-dossier-actions
|
||||
%button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'actions-menu' }
|
||||
Actions
|
||||
#actions-menu.dropdown-content.fade-in-down
|
||||
%ul.dropdown-items
|
||||
- if close_to_expiration
|
||||
%li
|
||||
= link_to repousser_expiration_instructeur_dossier_path(procedure_id, dossier_id), method: :post do
|
||||
%span.icon.standby
|
||||
.dropdown-description= t('instructeurs.dossiers.header.banner.button_delay_expiration')
|
||||
- if archived
|
||||
%li
|
||||
= link_to unarchive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch do
|
||||
|
|
|
@ -123,11 +123,12 @@
|
|||
%a.cell-link{ href: path }= status_badge(p.state)
|
||||
|
||||
%td.action-col.follow-col= render partial: 'dossier_actions',
|
||||
locals: { procedure_id: @procedure.id,
|
||||
dossier_id: p.dossier_id,
|
||||
state: p.state,
|
||||
archived: p.archived,
|
||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id) }
|
||||
locals: { procedure_id: @procedure.id,
|
||||
dossier_id: p.dossier_id,
|
||||
state: p.state,
|
||||
archived: p.archived,
|
||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
|
||||
close_to_expiration: @statut == 'expirant' }
|
||||
|
||||
= pagination
|
||||
- else
|
||||
|
|
|
@ -81,7 +81,8 @@
|
|||
dossier_id: p.dossier_id,
|
||||
state: p.state,
|
||||
archived: p.archived,
|
||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id) }
|
||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
|
||||
close_to_expiration: nil }
|
||||
|
||||
- else
|
||||
%td
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
- if dossier.expiration_can_be_extended?
|
||||
%br
|
||||
= button_to t('users.dossiers.header.banner.button_delay_expiration'), users_dossier_repousser_expiration_path(dossier), class: 'button secondary mt-2'
|
||||
= button_to users_dossier_repousser_expiration_path(dossier), class: 'button mt-2', id: 'test-user-repousser-expiration' do
|
||||
%span.icon.standby
|
||||
= t('users.dossiers.header.banner.button_delay_expiration', duree_conservation_dossiers_dans_ds: dossier.procedure.duree_conservation_dossiers_dans_ds)
|
||||
|
||||
|
||||
- else
|
||||
|
|
|
@ -136,6 +136,7 @@ fr:
|
|||
introduction_file_explaination: "Fichier joint à la demande d’avis"
|
||||
users:
|
||||
dossiers:
|
||||
archived_dossier: "Votre dossier sera conservé %{duree_conservation_dossiers_dans_ds} mois supplémentaire"
|
||||
autosave:
|
||||
autosave_draft: Votre brouillon est automatiquement enregistré.
|
||||
more_infos: En savoir plus
|
||||
|
@ -390,7 +391,7 @@ 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:
|
||||
|
|
|
@ -18,6 +18,8 @@ fr:
|
|||
archive_pending_html: Archive en cours de création<br>(demandée il y a %{created_period})
|
||||
archive_ready_html: Télécharger l’archive<br>(demandée il y a %{generated_period})
|
||||
dossiers:
|
||||
extend_conservation:
|
||||
archived_dossier: "Le dossier sera conservé 1 mois supplémentaire"
|
||||
decisions_rendues_block:
|
||||
without_email:
|
||||
en_construction: Le %{processed_at} ce dossier a été passé en construction
|
||||
|
|
|
@ -3,9 +3,10 @@ en:
|
|||
dossiers:
|
||||
header:
|
||||
banner:
|
||||
expiration_date_extended: " – la date de conservation a déjà été etendue"
|
||||
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"
|
||||
button_delay_expiration: "Keep for one more month"
|
||||
|
|
|
@ -3,9 +3,10 @@ fr:
|
|||
dossiers:
|
||||
header:
|
||||
banner:
|
||||
expiration_date_extended: " – la date de conservation a déjà été etendue"
|
||||
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"
|
||||
button_delay_expiration: "Conserver un mois de plus"
|
||||
|
|
|
@ -8,4 +8,4 @@ en:
|
|||
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"
|
||||
button_delay_expiration: "Keep for %{duree_conservation_dossiers_dans_ds} more months"
|
||||
|
|
|
@ -8,4 +8,4 @@ fr:
|
|||
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"
|
||||
button_delay_expiration: "Conserver %{duree_conservation_dossiers_dans_ds} mois supplémentaires "
|
||||
|
|
|
@ -361,7 +361,7 @@ Rails.application.routes.draw do
|
|||
resources :dossiers, only: [:show], param: :dossier_id do
|
||||
member do
|
||||
resources :commentaires, only: [:destroy]
|
||||
|
||||
post '/repousser-expiration' => 'dossiers#extend_conservation'
|
||||
get 'attestation'
|
||||
get 'geo_data'
|
||||
get 'apercu_attestation'
|
||||
|
|
|
@ -804,4 +804,23 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#extend_conservation' do
|
||||
subject { post :extend_conservation, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
|
||||
context 'when user logged in' do
|
||||
it 'works' do
|
||||
expect(subject).to redirect_to(instructeur_dossier_path(procedure, dossier))
|
||||
end
|
||||
|
||||
it 'extends conservation_extension by 1 month' do
|
||||
subject
|
||||
expect(dossier.reload.conservation_extension).to eq(1.month)
|
||||
end
|
||||
|
||||
it 'flashed notice success' do
|
||||
subject
|
||||
expect(flash[:notice]).to eq(I18n.t('views.instructeurs.dossiers.archived_dossier'))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1161,4 +1161,33 @@ describe Users::DossiersController, type: :controller do
|
|||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#extend_conservation' do
|
||||
let(:procedure) { create(:procedure, duree_conservation_dossiers_dans_ds: 3) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
|
||||
subject { post :extend_conservation, params: { dossier_id: dossier.id } }
|
||||
context 'when user logged in' do
|
||||
before { sign_in(user) }
|
||||
it 'works' do
|
||||
expect(subject).to redirect_to(dossier_path(dossier))
|
||||
end
|
||||
|
||||
it 'extends conservation_extension by duree_conservation_dossiers_dans_ds' do
|
||||
subject
|
||||
expect(dossier.reload.conservation_extension).to eq(procedure.duree_conservation_dossiers_dans_ds.months)
|
||||
end
|
||||
|
||||
it 'flashed notice success' do
|
||||
subject
|
||||
expect(flash[:notice]).to eq(I18n.t('views.users.dossiers.archived_dossier', duree_conservation_dossiers_dans_ds: procedure.duree_conservation_dossiers_dans_ds))
|
||||
end
|
||||
end
|
||||
|
||||
context 'when not logged in' do
|
||||
it 'fails' do
|
||||
subject
|
||||
expect { expect(response).to redirect_to(new_user_session_path) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -166,7 +166,7 @@ describe 'The user' do
|
|||
end
|
||||
|
||||
scenario 'extends dossier experation date more than one time, ', js: true do
|
||||
Flipper.enable(:procedure_process_expired_dossiers_termine)
|
||||
simple_procedure.update(procedure_expires_when_termine_enabled: true)
|
||||
allow(simple_procedure).to receive(:feature_enabled?).with(:procedure_process_expired_dossiers_termine).and_return(true)
|
||||
user_old_dossier = create(:dossier,
|
||||
procedure: simple_procedure,
|
||||
|
@ -176,15 +176,14 @@ describe 'The user' do
|
|||
visit brouillon_dossier_path(user_old_dossier)
|
||||
|
||||
expect(page).to have_css('.card-title', text: 'Votre dossier va expirer', visible: true)
|
||||
click_on "Repousser sa suppression"
|
||||
expect(page).not_to have_button("Repousser sa suppression")
|
||||
find('#test-user-repousser-expiration').click
|
||||
expect(page).not_to have_selector('#test-user-repousser-expiration')
|
||||
|
||||
Timecop.freeze(1.month.from_now) do
|
||||
Timecop.freeze(simple_procedure.duree_conservation_dossiers_dans_ds.month.from_now) do
|
||||
visit brouillon_dossier_path(user_old_dossier)
|
||||
|
||||
expect(page).to have_css('.card-title', text: 'Votre dossier va expirer', visible: true)
|
||||
click_on "Repousser sa suppression"
|
||||
expect(page).not_to have_button("Repousser sa suppression")
|
||||
find('#test-user-repousser-expiration').click
|
||||
expect(page).not_to have_selector('#test-user-repousser-expiration')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue