Instructeur : ne peut plus cliquer sur un dossier supprimé dans la recherche

This commit is contained in:
Kara Diaby 2022-02-02 19:34:00 +01:00
parent c63a8c83e9
commit 5d10158fa6
9 changed files with 57 additions and 30 deletions

View file

@ -4,8 +4,7 @@ class RechercheController < ApplicationController
PROJECTIONS = [
{ "table" => 'procedure', "column" => 'libelle' },
{ "table" => 'user', "column" => 'email' },
{ "table" => 'procedure', "column" => 'procedure_id' },
{ "table" => 'dossier', "column" => 'hidden_by_administration_at' }
{ "table" => 'procedure', "column" => 'procedure_id' }
]
def index

View file

@ -1,5 +1,5 @@
class DossierProjectionService
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :columns)
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :hidden_by_administration_at, :columns)
end
TABLE = 'table'
@ -21,8 +21,8 @@ class DossierProjectionService
state_field = { TABLE => 'self', COLUMN => 'state' }
archived_field = { TABLE => 'self', COLUMN => 'archived' }
hidden_by_user_at_field = { TABLE => 'self', COLUMN => 'hidden_by_user_at' }
([state_field, archived_field, hidden_by_user_at_field] + fields) # the view needs state and archived dossier attributes
hidden_by_administration_at_field = { TABLE => 'self', COLUMN => 'hidden_by_administration_at' }
([state_field, archived_field, hidden_by_user_at_field, hidden_by_administration_at_field] + fields) # the view needs state and archived dossier attributes
.each { |f| f[:id_value_h] = {} }
.group_by { |f| f[TABLE] } # one query per table
.each do |table, fields|
@ -46,7 +46,7 @@ class DossierProjectionService
.pluck(:id, *fields.map { |f| f[COLUMN].to_sym })
.each do |id, *columns|
fields.zip(columns).each do |field, value|
if [state_field, archived_field, hidden_by_user_at_field].include?(field)
if [state_field, archived_field, hidden_by_user_at_field, hidden_by_administration_at_field].include?(field)
field[:id_value_h][id] = value
else
field[:id_value_h][id] = value&.strftime('%d/%m/%Y') # other fields are datetime
@ -100,6 +100,7 @@ class DossierProjectionService
state_field[:id_value_h][dossier_id],
archived_field[:id_value_h][dossier_id],
hidden_by_user_at_field[:id_value_h][dossier_id],
hidden_by_administration_at_field[:id_value_h][dossier_id],
fields.map { |f| f[:id_value_h][dossier_id] }
)
end

View file

@ -28,8 +28,7 @@
state: dossier.state,
archived: dossier.archived,
dossier_is_followed: current_instructeur&.follow?(dossier),
close_to_expiration: dossier.close_to_expiration?,
recently_deleted: dossier.hidden_by_administration? }
close_to_expiration: dossier.close_to_expiration? }
.state-button

View file

@ -21,13 +21,7 @@
%span.icon.archive
.dropdown-description
Archiver le dossier
- if recently_deleted
%li.danger
= link_to restore_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, data: { confirm: "Voulez vous vraiment restaurer le dossier #{dossier_id}" } do
%span.icon.reply
.dropdown-description
= t('views.instructeurs.dossiers.restore')
- else
%li.danger
= link_to supprimer_dossier_instructeur_dossier_path(procedure_id, dossier_id), 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.delete

View file

@ -132,14 +132,19 @@
%td.status-col
%a.cell-link{ href: path }= status_badge(p.state)
- if @statut == 'supprimes_recemment'
%td.action-col.follow-col
= link_to restore_instructeur_dossier_path(@procedure, p.dossier_id), method: :patch, class: "button primary" do
= t('views.instructeurs.dossiers.restore')
- else
%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),
close_to_expiration: @statut == 'expirant',
recently_deleted: @statut == 'supprimes_recemment' }
close_to_expiration: @statut == 'expirant' }
= pagination
- else

View file

@ -0,0 +1,17 @@
%td.folder-col
%p.cell-link
%span.icon.folder
%td.number-col
%p.cell-link= p.dossier_id
%td
%p.cell-link= procedure_libelle
%td
%p.cell-link
= user_email
= "- #{t('views.instructeurs.dossiers.deleted_by_administration')}" if p.hidden_by_administration_at.present?
%td.status-col
%p.cell-link= status_badge(p.state)

View file

@ -20,13 +20,14 @@
%th.action-col.follow-col
%tbody
- @projected_dossiers.each do |p|
- procedure_libelle, user_email, procedure_id, hidden_by_administration = p.columns
- procedure_libelle, user_email, procedure_id = p.columns
- instructeur_dossier = @instructeur_dossiers_ids.include?(p.dossier_id)
- expert_dossier = @dossier_avis_ids_h[p.dossier_id].present?
- hidden_by_administration = p.hidden_by_administration_at.present?
- instructeur_and_expert_dossier = instructeur_dossier && expert_dossier
- path = instructeur_dossier ? instructeur_dossier_path(procedure_id, p.dossier_id) : expert_avis_path(procedure_id, @dossier_avis_ids_h[p.dossier_id])
%tr
%tr{ class: [p.hidden_by_administration_at.present? && "file-hidden-by-user"] }
- if instructeur_and_expert_dossier
%td.folder-col.cell-link
%span.icon.folder
@ -39,7 +40,11 @@
%td.status-col
.cell-link= status_badge(p.state)
- elsif hidden_by_administration
= render partial: "recherche/hidden_dossier", locals: {p: p, procedure_libelle: procedure_libelle, user_email: user_email}
- else
%td.folder-col
%a.cell-link{ href: path }
%span.icon.folder
@ -76,14 +81,19 @@
Donner mon avis
- elsif instructeur_dossier
- if hidden_by_administration
%td.action-col.follow-col
= link_to restore_instructeur_dossier_path(procedure_id, p.dossier_id), method: :patch, class: "button primary" do
= t('views.instructeurs.dossiers.restore')
- else
%td.action-col.follow-col= render partial: "instructeurs/procedures/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),
close_to_expiration: nil,
recently_deleted: hidden_by_administration.blank? }
close_to_expiration: nil }
- else
%td

View file

@ -140,7 +140,8 @@ en:
archived_dossier: "This file will be kept for an additional month"
delete_dossier: "Delete file"
deleted_by_user: "File deleted by user"
restore: "Restore the file"
deleted_by_administration: "File deleted by administration"
restore: "Restore"
avis:
introduction_file_explaination: "File attached to the request for advice"
users:

View file

@ -137,7 +137,8 @@ fr:
archived_dossier: "Le dossier sera conservé 1 mois supplémentaire"
delete_dossier: "Supprimer le dossier"
deleted_by_user: "Dossier supprimé par l'usager"
restore: "Restaurer le dossier"
deleted_by_administration: "Dossier supprimé par l'administration"
restore: "Restaurer"
avis:
introduction_file_explaination: "Fichier joint à la demande davis"
users: