Instructeur : ne peut plus cliquer sur un dossier supprimé dans la recherche
This commit is contained in:
parent
c63a8c83e9
commit
5d10158fa6
9 changed files with 57 additions and 30 deletions
|
@ -4,8 +4,7 @@ class RechercheController < ApplicationController
|
||||||
PROJECTIONS = [
|
PROJECTIONS = [
|
||||||
{ "table" => 'procedure', "column" => 'libelle' },
|
{ "table" => 'procedure', "column" => 'libelle' },
|
||||||
{ "table" => 'user', "column" => 'email' },
|
{ "table" => 'user', "column" => 'email' },
|
||||||
{ "table" => 'procedure', "column" => 'procedure_id' },
|
{ "table" => 'procedure', "column" => 'procedure_id' }
|
||||||
{ "table" => 'dossier', "column" => 'hidden_by_administration_at' }
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class DossierProjectionService
|
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
|
end
|
||||||
|
|
||||||
TABLE = 'table'
|
TABLE = 'table'
|
||||||
|
@ -21,8 +21,8 @@ class DossierProjectionService
|
||||||
state_field = { TABLE => 'self', COLUMN => 'state' }
|
state_field = { TABLE => 'self', COLUMN => 'state' }
|
||||||
archived_field = { TABLE => 'self', COLUMN => 'archived' }
|
archived_field = { TABLE => 'self', COLUMN => 'archived' }
|
||||||
hidden_by_user_at_field = { TABLE => 'self', COLUMN => 'hidden_by_user_at' }
|
hidden_by_user_at_field = { TABLE => 'self', COLUMN => 'hidden_by_user_at' }
|
||||||
|
hidden_by_administration_at_field = { TABLE => 'self', COLUMN => 'hidden_by_administration_at' }
|
||||||
([state_field, archived_field, hidden_by_user_at_field] + fields) # the view needs state and archived dossier attributes
|
([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] = {} }
|
.each { |f| f[:id_value_h] = {} }
|
||||||
.group_by { |f| f[TABLE] } # one query per table
|
.group_by { |f| f[TABLE] } # one query per table
|
||||||
.each do |table, fields|
|
.each do |table, fields|
|
||||||
|
@ -46,7 +46,7 @@ class DossierProjectionService
|
||||||
.pluck(:id, *fields.map { |f| f[COLUMN].to_sym })
|
.pluck(:id, *fields.map { |f| f[COLUMN].to_sym })
|
||||||
.each do |id, *columns|
|
.each do |id, *columns|
|
||||||
fields.zip(columns).each do |field, value|
|
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
|
field[:id_value_h][id] = value
|
||||||
else
|
else
|
||||||
field[:id_value_h][id] = value&.strftime('%d/%m/%Y') # other fields are datetime
|
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],
|
state_field[:id_value_h][dossier_id],
|
||||||
archived_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_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] }
|
fields.map { |f| f[:id_value_h][dossier_id] }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,8 +28,7 @@
|
||||||
state: dossier.state,
|
state: dossier.state,
|
||||||
archived: dossier.archived,
|
archived: dossier.archived,
|
||||||
dossier_is_followed: current_instructeur&.follow?(dossier),
|
dossier_is_followed: current_instructeur&.follow?(dossier),
|
||||||
close_to_expiration: dossier.close_to_expiration?,
|
close_to_expiration: dossier.close_to_expiration? }
|
||||||
recently_deleted: dossier.hidden_by_administration? }
|
|
||||||
|
|
||||||
|
|
||||||
.state-button
|
.state-button
|
||||||
|
|
|
@ -21,13 +21,7 @@
|
||||||
%span.icon.archive
|
%span.icon.archive
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
Archiver le dossier
|
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
|
%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
|
= 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
|
%span.icon.delete
|
||||||
|
|
|
@ -132,14 +132,19 @@
|
||||||
%td.status-col
|
%td.status-col
|
||||||
%a.cell-link{ href: path }= status_badge(p.state)
|
%a.cell-link{ href: path }= status_badge(p.state)
|
||||||
|
|
||||||
%td.action-col.follow-col= render partial: 'dossier_actions',
|
- if @statut == 'supprimes_recemment'
|
||||||
locals: { procedure_id: @procedure.id,
|
%td.action-col.follow-col
|
||||||
dossier_id: p.dossier_id,
|
= link_to restore_instructeur_dossier_path(@procedure, p.dossier_id), method: :patch, class: "button primary" do
|
||||||
state: p.state,
|
= t('views.instructeurs.dossiers.restore')
|
||||||
archived: p.archived,
|
|
||||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
|
- else
|
||||||
close_to_expiration: @statut == 'expirant',
|
%td.action-col.follow-col= render partial: 'dossier_actions',
|
||||||
recently_deleted: @statut == 'supprimes_recemment' }
|
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
|
= pagination
|
||||||
- else
|
- else
|
||||||
|
|
17
app/views/recherche/_hidden_dossier.html.haml
Normal file
17
app/views/recherche/_hidden_dossier.html.haml
Normal 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)
|
|
@ -20,13 +20,14 @@
|
||||||
%th.action-col.follow-col
|
%th.action-col.follow-col
|
||||||
%tbody
|
%tbody
|
||||||
- @projected_dossiers.each do |p|
|
- @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)
|
- instructeur_dossier = @instructeur_dossiers_ids.include?(p.dossier_id)
|
||||||
- expert_dossier = @dossier_avis_ids_h[p.dossier_id].present?
|
- 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
|
- 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])
|
- 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
|
- if instructeur_and_expert_dossier
|
||||||
%td.folder-col.cell-link
|
%td.folder-col.cell-link
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
|
@ -39,7 +40,11 @@
|
||||||
%td.status-col
|
%td.status-col
|
||||||
.cell-link= status_badge(p.state)
|
.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
|
- else
|
||||||
|
|
||||||
%td.folder-col
|
%td.folder-col
|
||||||
%a.cell-link{ href: path }
|
%a.cell-link{ href: path }
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
|
@ -76,14 +81,19 @@
|
||||||
Donner mon avis
|
Donner mon avis
|
||||||
|
|
||||||
- elsif instructeur_dossier
|
- elsif instructeur_dossier
|
||||||
%td.action-col.follow-col= render partial: "instructeurs/procedures/dossier_actions",
|
- 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,
|
locals: { procedure_id: procedure_id,
|
||||||
dossier_id: p.dossier_id,
|
dossier_id: p.dossier_id,
|
||||||
state: p.state,
|
state: p.state,
|
||||||
archived: p.archived,
|
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,
|
close_to_expiration: nil }
|
||||||
recently_deleted: hidden_by_administration.blank? }
|
|
||||||
|
|
||||||
- else
|
- else
|
||||||
%td
|
%td
|
||||||
|
|
|
@ -140,7 +140,8 @@ en:
|
||||||
archived_dossier: "This file will be kept for an additional month"
|
archived_dossier: "This file will be kept for an additional month"
|
||||||
delete_dossier: "Delete file"
|
delete_dossier: "Delete file"
|
||||||
deleted_by_user: "File deleted by user"
|
deleted_by_user: "File deleted by user"
|
||||||
restore: "Restore the file"
|
deleted_by_administration: "File deleted by administration"
|
||||||
|
restore: "Restore"
|
||||||
avis:
|
avis:
|
||||||
introduction_file_explaination: "File attached to the request for advice"
|
introduction_file_explaination: "File attached to the request for advice"
|
||||||
users:
|
users:
|
||||||
|
|
|
@ -137,7 +137,8 @@ fr:
|
||||||
archived_dossier: "Le dossier sera conservé 1 mois supplémentaire"
|
archived_dossier: "Le dossier sera conservé 1 mois supplémentaire"
|
||||||
delete_dossier: "Supprimer le dossier"
|
delete_dossier: "Supprimer le dossier"
|
||||||
deleted_by_user: "Dossier supprimé par l'usager"
|
deleted_by_user: "Dossier supprimé par l'usager"
|
||||||
restore: "Restaurer le dossier"
|
deleted_by_administration: "Dossier supprimé par l'administration"
|
||||||
|
restore: "Restaurer"
|
||||||
avis:
|
avis:
|
||||||
introduction_file_explaination: "Fichier joint à la demande d’avis"
|
introduction_file_explaination: "Fichier joint à la demande d’avis"
|
||||||
users:
|
users:
|
||||||
|
|
Loading…
Reference in a new issue