final optims after sim review
This commit is contained in:
parent
f3c4040d2d
commit
c7643154d1
12 changed files with 106 additions and 61 deletions
|
@ -18,8 +18,8 @@ module Users
|
||||||
def index
|
def index
|
||||||
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
||||||
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
|
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
|
||||||
@dossiers_supprimes = DeletedDossier.where(user_id: current_user.id).order_by_updated_at.page(page)
|
@dossiers_supprimes = current_user.deleted_dossiers.order_by_updated_at.page(page)
|
||||||
@statut = statut(@user_dossiers.count, @dossiers_invites.count, @dossiers_supprimes.count)
|
@statut = statut(@user_dossiers, @dossiers_invites, @dossiers_supprimes, params[:statut])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -275,15 +275,22 @@ module Users
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def statut(mes_dossiers_count, dossiers_invites_count, dossiers_supprimes_count)
|
# if the status tab is filled, then this tab
|
||||||
if dossiers_invites_count == 0 && dossiers_supprimes_count == 0
|
# else first filled tab
|
||||||
'mes-dossiers'
|
# else mes-dossiers
|
||||||
elsif mes_dossiers_count == 0 && dossiers_invites_count > 0
|
def statut(mes_dossiers, dossiers_invites, dossiers_supprimes, params_statut)
|
||||||
'dossiers-invites'
|
tabs = {
|
||||||
elsif dossiers_invites_count == 0 && mes_dossiers_count == 0 && dossiers_supprimes_count > 0
|
'mes-dossiers' => mes_dossiers.present?,
|
||||||
'dossiers-supprimes'
|
'dossiers-invites' => dossiers_invites.present?,
|
||||||
|
'dossiers-supprimes' => dossiers_supprimes.present?
|
||||||
|
}
|
||||||
|
if tabs[params_statut]
|
||||||
|
params_statut
|
||||||
else
|
else
|
||||||
@statut = params[:statut].presence || 'mes-dossiers'
|
tabs
|
||||||
|
.filter { |_tab, filled| filled }
|
||||||
|
.map { |tab, _| tab }
|
||||||
|
.first || 'mes-dossiers'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class DossierMailer < ApplicationMailer
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_instructeur_deletion_to_user(deleted_dossier, to_email)
|
def notify_instructeur_deletion_to_user(deleted_dossier, to_email)
|
||||||
@subject = default_i18n_subject(dossier_id: deleted_dossier.dossier_id)
|
@subject = default_i18n_subject(libelle_demarche: deleted_dossier.procedure.libelle)
|
||||||
@deleted_dossier = deleted_dossier
|
@deleted_dossier = deleted_dossier
|
||||||
|
|
||||||
mail(to: to_email, subject: @subject)
|
mail(to: to_email, subject: @subject)
|
||||||
|
|
|
@ -44,6 +44,7 @@ class User < ApplicationRecord
|
||||||
has_many :invites, dependent: :destroy
|
has_many :invites, dependent: :destroy
|
||||||
has_many :dossiers_invites, through: :invites, source: :dossier
|
has_many :dossiers_invites, through: :invites, source: :dossier
|
||||||
has_many :feedbacks, dependent: :destroy
|
has_many :feedbacks, dependent: :destroy
|
||||||
|
has_many :deleted_dossiers
|
||||||
has_one :france_connect_information, dependent: :destroy
|
has_one :france_connect_information, dependent: :destroy
|
||||||
belongs_to :instructeur, optional: true
|
belongs_to :instructeur, optional: true
|
||||||
belongs_to :administrateur, optional: true
|
belongs_to :administrateur, optional: true
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
Bonjour,
|
Bonjour,
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= t('.body', dossier_id: @deleted_dossier.dossier_id, procedure: @deleted_dossier.procedure.libelle)
|
= t('.body', dossier_id: @deleted_dossier.dossier_id, libelle_demarche: @deleted_dossier.procedure.libelle)
|
||||||
|
|
||||||
= render partial: "layouts/mailers/signature"
|
= render partial: "layouts/mailers/signature"
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
- if dossier.termine?
|
- if dossier.termine?
|
||||||
%li
|
%li
|
||||||
= link_to supprimer_dossier_instructeur_dossier_path(dossier.procedure, dossier), method: :patch, data: { confirm: "Voulez vous vraiment supprimer le dossier #{dossier.id} ? Cette action est irréversible. \nNous vous suggérons de télécharger le dossier au format PDF au préalable." } do
|
= link_to supprimer_dossier_instructeur_dossier_path(dossier.procedure, dossier), method: :patch, data: { confirm: "Voulez vous vraiment supprimer le dossier #{dossier.id} ? Cette action est irréversible. \nNous vous suggérons de télécharger le dossier au format PDF au préalable." } do
|
||||||
%span.icon.refuse
|
%span.icon.delete
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
%h4 Supprimer le dossier
|
%h4 Supprimer le dossier
|
||||||
L’usager sera notifié que son dossier sera supprimé.
|
L’usager sera notifié que son dossier sera supprimé.
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
%tr
|
%tr
|
||||||
%th.notification-col
|
%th.notification-col
|
||||||
%th.number-col N° dossier
|
%th.number-col N° dossier
|
||||||
%th.status-col Etat
|
|
||||||
%th.status-col Raison de suppression
|
%th.status-col Raison de suppression
|
||||||
%th.status-col Date de suppression
|
%th.status-col Date de suppression
|
||||||
%tbody
|
%tbody
|
||||||
|
@ -62,8 +61,6 @@
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
%td.number-col
|
%td.number-col
|
||||||
= deleted_dossier.dossier_id
|
= deleted_dossier.dossier_id
|
||||||
%td.status-col
|
|
||||||
= status_badge(deleted_dossier.state)
|
|
||||||
%td.reason-col
|
%td.reason-col
|
||||||
= deletion_reason_badge(deleted_dossier.reason)
|
= deletion_reason_badge(deleted_dossier.reason)
|
||||||
%td.date-col.deleted-cell
|
%td.date-col.deleted-cell
|
||||||
|
|
42
app/views/users/dossiers/_deleted_dossiers_list.html.haml
Normal file
42
app/views/users/dossiers/_deleted_dossiers_list.html.haml
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
- if deleted_dossiers.present?
|
||||||
|
%table.table.dossiers-table.hoverable
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th.number-col Nº dossier
|
||||||
|
%th Démarche
|
||||||
|
%th Raison de suppression
|
||||||
|
%th Date de suppression
|
||||||
|
%tbody
|
||||||
|
- deleted_dossiers.each do |dossier|
|
||||||
|
- libelle_demarche = Procedure.find(dossier.procedure_id).libelle
|
||||||
|
%tr{ data: { 'dossier-id': dossier.dossier_id } }
|
||||||
|
%td.number-col
|
||||||
|
= dossier.dossier_id
|
||||||
|
%td
|
||||||
|
= libelle_demarche
|
||||||
|
|
||||||
|
%td.cell-link
|
||||||
|
= deletion_reason_badge(dossier.reason)
|
||||||
|
%td
|
||||||
|
= dossier.updated_at.strftime('%d/%m/%Y')
|
||||||
|
|
||||||
|
= paginate(deleted_dossiers)
|
||||||
|
|
||||||
|
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||||
|
#user-satisfaction
|
||||||
|
%h3 Que pensez-vous de la facilité d'utilisation de ce service ?
|
||||||
|
.icons
|
||||||
|
= link_to feedback_path(rating: Feedback.ratings.fetch(:unhappy)), data: { remote: true, method: :post } do
|
||||||
|
%span.icon.frown
|
||||||
|
= link_to feedback_path(rating: Feedback.ratings.fetch(:neutral)), data: { remote: true, method: :post } do
|
||||||
|
%span.icon.meh
|
||||||
|
= link_to feedback_path(rating: Feedback.ratings.fetch(:happy)), data: { remote: true, method: :post } do
|
||||||
|
%span.icon.smile
|
||||||
|
|
||||||
|
- else
|
||||||
|
.blank-tab
|
||||||
|
%h2.empty-text Aucun dossier.
|
||||||
|
%p.empty-text-details
|
||||||
|
Pour remplir une démarche, contactez votre administration en lui demandant le lien de la démarche.
|
||||||
|
%br
|
||||||
|
Celui ci doit ressembler à #{APPLICATION_BASE_URL}/commencer/xxx.
|
|
@ -11,8 +11,6 @@
|
||||||
%th.sr-only Actions
|
%th.sr-only Actions
|
||||||
%tbody
|
%tbody
|
||||||
- dossiers.each do |dossier|
|
- dossiers.each do |dossier|
|
||||||
-# check if the dossier is deleted or not
|
|
||||||
- if dossier.try(:deleted_at).nil?
|
|
||||||
%tr{ data: { 'dossier-id': dossier.id } }
|
%tr{ data: { 'dossier-id': dossier.id } }
|
||||||
%td.number-col
|
%td.number-col
|
||||||
= link_to(url_for_dossier(dossier), class: 'cell-link', tabindex: -1) do
|
= link_to(url_for_dossier(dossier), class: 'cell-link', tabindex: -1) do
|
||||||
|
@ -30,20 +28,6 @@
|
||||||
= try_format_date(dossier.updated_at)
|
= try_format_date(dossier.updated_at)
|
||||||
%td.action-col
|
%td.action-col
|
||||||
= render partial: 'dossier_actions', locals: { dossier: dossier }
|
= render partial: 'dossier_actions', locals: { dossier: dossier }
|
||||||
- else
|
|
||||||
%tr{ data: { 'dossier-id': dossier.dossier_id } }
|
|
||||||
%td.number-col
|
|
||||||
= dossier.dossier_id
|
|
||||||
%td
|
|
||||||
= dossier.procedure_id
|
|
||||||
|
|
||||||
- if dossiers.present?
|
|
||||||
%td.cell-link
|
|
||||||
= dossier.reason
|
|
||||||
%td
|
|
||||||
= status_badge(dossier.state)
|
|
||||||
%td
|
|
||||||
= dossier.updated_at.strftime('%d/%m/%Y')
|
|
||||||
|
|
||||||
= paginate(dossiers)
|
= paginate(dossiers)
|
||||||
|
|
||||||
|
|
|
@ -16,30 +16,30 @@
|
||||||
%h1.page-title Dossiers
|
%h1.page-title Dossiers
|
||||||
%ul.tabs
|
%ul.tabs
|
||||||
- if @user_dossiers.count > 0
|
- if @user_dossiers.count > 0
|
||||||
= tab_item('mes dossiers',
|
= tab_item(t('pluralize.mes_dossiers', count: @user_dossiers.count),
|
||||||
dossiers_path(statut: 'mes-dossiers'),
|
dossiers_path(statut: 'mes-dossiers'),
|
||||||
active: @statut == 'mes-dossiers',
|
active: @statut == 'mes-dossiers',
|
||||||
badge: number_with_html_delimiter(@user_dossiers.count))
|
badge: number_with_html_delimiter(@user_dossiers.count))
|
||||||
|
|
||||||
- if @dossiers_invites.count > 0
|
- if @dossiers_invites.count > 0
|
||||||
= tab_item('dossiers invités',
|
= tab_item(t('pluralize.dossiers_invites', count: @dossiers_invites.count),
|
||||||
dossiers_path(statut: 'dossiers-invites'),
|
dossiers_path(statut: 'dossiers-invites'),
|
||||||
active: @statut == 'dossiers-invites',
|
active: @statut == 'dossiers-invites',
|
||||||
badge: number_with_html_delimiter(@dossiers_invites.count))
|
badge: number_with_html_delimiter(@dossiers_invites.count))
|
||||||
|
|
||||||
- if @dossiers_supprimes.count > 0
|
- if @dossiers_supprimes.count > 0
|
||||||
= tab_item('dossiers supprimés',
|
= tab_item(t('pluralize.dossiers_supprimes', count: @dossiers_supprimes.count),
|
||||||
dossiers_path(statut: 'dossiers-supprimes'),
|
dossiers_path(statut: 'dossiers-supprimes'),
|
||||||
active: @statut == 'dossiers-supprimes',
|
active: @statut == 'dossiers-supprimes',
|
||||||
badge: number_with_html_delimiter(@dossiers_supprimes.count))
|
badge: number_with_html_delimiter(@dossiers_supprimes.count))
|
||||||
|
|
||||||
|
|
||||||
.container
|
.container
|
||||||
- if @statut === "mes-dossiers"
|
- if @statut == "mes-dossiers"
|
||||||
= render partial: "dossiers_list", locals: { dossiers: @user_dossiers }
|
= render partial: "dossiers_list", locals: { dossiers: @user_dossiers }
|
||||||
|
|
||||||
- if @statut === "dossiers-invites"
|
- if @statut == "dossiers-invites"
|
||||||
= render partial: "dossiers_list", locals: { dossiers: @dossiers_invites }
|
= render partial: "dossiers_list", locals: { dossiers: @dossiers_invites }
|
||||||
|
|
||||||
- if @statut === "dossiers-supprimes"
|
- if @statut == "dossiers-supprimes"
|
||||||
= render partial: "dossiers_list", locals: { dossiers: @dossiers_supprimes }
|
= render partial: "deleted_dossiers_list", locals: { deleted_dossiers: @dossiers_supprimes }
|
||||||
|
|
|
@ -169,6 +169,18 @@ fr:
|
||||||
zero: archivé
|
zero: archivé
|
||||||
one: archivé
|
one: archivé
|
||||||
other: archivés
|
other: archivés
|
||||||
|
mes_dossiers:
|
||||||
|
zero: mon dossier
|
||||||
|
one: mon dossier
|
||||||
|
other: mes dossiers
|
||||||
|
dossiers_invites:
|
||||||
|
zero: dossier invité
|
||||||
|
one: dossier invité
|
||||||
|
other: dossiers invités
|
||||||
|
dossiers_supprimes:
|
||||||
|
zero: dossier supprimé
|
||||||
|
one: dossier supprimé
|
||||||
|
other: dossiers supprimés
|
||||||
dossier_trouve:
|
dossier_trouve:
|
||||||
zero: 0 dossier trouvé
|
zero: 0 dossier trouvé
|
||||||
one: 1 dossier trouvé
|
one: 1 dossier trouvé
|
||||||
|
|
|
@ -4,5 +4,8 @@ fr:
|
||||||
subject: Votre dossier nº %{dossier_id} a bien été supprimé
|
subject: Votre dossier nº %{dossier_id} a bien été supprimé
|
||||||
body: Votre dossier n° %{dossier_id} (%{procedure}) a bien été supprimé. Une trace de ce traitement sera conservée pour l’administration.
|
body: Votre dossier n° %{dossier_id} (%{procedure}) a bien été supprimé. Une trace de ce traitement sera conservée pour l’administration.
|
||||||
notify_instructeur_deletion_to_user:
|
notify_instructeur_deletion_to_user:
|
||||||
subject: Votre dossier nº %{dossier_id} a été supprimé par l'administration
|
subject: Votre dossier concernant %{libelle_demarche} est supprimé
|
||||||
body: Nous vous informons que votre dossier n° %{dossier_id} (%{procedure}) a été supprimé par l'administration en charge de la démarche. Une trace de ce traitement sera conservée pour l’administration.
|
body: |
|
||||||
|
Afin de limiter la conservation de vos données personnelles, votre dossier n° %{dossier_id} concernant %{libelle_demarche} a été supprimé.
|
||||||
|
Cette suppression ne modifie pas le statut final (accepté, refusé ou sans suite) de votre dossier.
|
||||||
|
Une trace de ce dossier restera cependant visible dans votre interface demarches-simplifiees.fr.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
RSpec.describe DiscardedDossiersDeletionJob, type: :job do
|
RSpec.describe Cron::DiscardedDossiersDeletionJob, type: :job do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
|
|
||||||
let(:instructeur) { create(:instructeur) }
|
let(:instructeur) { create(:instructeur) }
|
||||||
|
@ -14,7 +14,6 @@ RSpec.describe DiscardedDossiersDeletionJob, type: :job do
|
||||||
discarded_dossier_en_construction.send(:log_dossier_operation, instructeur, :passer_en_instruction, discarded_dossier_en_construction)
|
discarded_dossier_en_construction.send(:log_dossier_operation, instructeur, :passer_en_instruction, discarded_dossier_en_construction)
|
||||||
discarded_dossier_termine.send(:log_dossier_operation, instructeur, :passer_en_instruction, discarded_dossier_termine)
|
discarded_dossier_termine.send(:log_dossier_operation, instructeur, :passer_en_instruction, discarded_dossier_termine)
|
||||||
discarded_dossier_termine_today.send(:log_dossier_operation, instructeur, :passer_en_instruction, discarded_dossier_termine_today)
|
discarded_dossier_termine_today.send(:log_dossier_operation, instructeur, :passer_en_instruction, discarded_dossier_termine_today)
|
||||||
|
|
||||||
discarded_dossier_en_construction.send(:log_dossier_operation, instructeur, :supprimer, discarded_dossier_en_construction)
|
discarded_dossier_en_construction.send(:log_dossier_operation, instructeur, :supprimer, discarded_dossier_en_construction)
|
||||||
discarded_dossier_termine.send(:log_dossier_operation, instructeur, :supprimer, discarded_dossier_termine)
|
discarded_dossier_termine.send(:log_dossier_operation, instructeur, :supprimer, discarded_dossier_termine)
|
||||||
discarded_dossier_termine_today.send(:log_dossier_operation, instructeur, :supprimer, discarded_dossier_termine_today)
|
discarded_dossier_termine_today.send(:log_dossier_operation, instructeur, :supprimer, discarded_dossier_termine_today)
|
||||||
|
@ -25,7 +24,7 @@ RSpec.describe DiscardedDossiersDeletionJob, type: :job do
|
||||||
expect(Dossier.with_discarded.count).to eq(6)
|
expect(Dossier.with_discarded.count).to eq(6)
|
||||||
expect(DossierOperationLog.count).to eq(6)
|
expect(DossierOperationLog.count).to eq(6)
|
||||||
|
|
||||||
DiscardedDossiersDeletionJob.perform_now
|
Cron::DiscardedDossiersDeletionJob.perform_now
|
||||||
|
|
||||||
expect(Dossier.with_discarded.count).to eq(3)
|
expect(Dossier.with_discarded.count).to eq(3)
|
||||||
expect(DossierOperationLog.count).to eq(4)
|
expect(DossierOperationLog.count).to eq(4)
|
Loading…
Reference in a new issue