refactor(instructeur): improuve dossiers list view

This commit is contained in:
Paul Chavard 2022-03-11 13:57:53 +01:00
parent a50d07400e
commit 0695ea322a
7 changed files with 59 additions and 31 deletions

View file

@ -39,7 +39,7 @@ module Instructeurs
'dossiers' => @dossiers_count_per_procedure.sum { |_, v| v },
'expirant' => @dossiers_expirant_count_per_procedure.sum { |_, v| v },
'archivés' => @dossiers_archived_count_per_procedure.sum { |_, v| v },
'supprimes_recemment' => @dossiers_supprimes_recemment_count_per_procedure.sum { |_, v| v }
'supprimés récemment' => @dossiers_supprimes_recemment_count_per_procedure.sum { |_, v| v }
}
@procedure_ids_en_cours_with_notifications = current_instructeur.procedure_ids_with_notifications(:en_cours)
@ -137,15 +137,18 @@ module Instructeurs
.order(:dossier_id)
.page params[:page]
@a_suivre_count, @suivis_count, @traites_count, @tous_count, @archives_count = current_instructeur
@a_suivre_count, @suivis_count, @traites_count, @tous_count, @archives_count, @supprimes_recemment_count, @expirant_count = current_instructeur
.dossiers_count_summary(groupe_instructeur_ids)
.fetch_values('a_suivre', 'suivis', 'traites', 'tous', 'archives')
.fetch_values('a_suivre', 'suivis', 'traites', 'tous', 'archives', 'supprimes_recemment', 'expirant')
@can_download_dossiers = (@tous_count + @archives_count) > 0
notifications = current_instructeur.notifications_for_groupe_instructeurs(groupe_instructeur_ids)
@has_en_cours_notifications = notifications[:en_cours].present?
@has_termine_notifications = notifications[:termines].present?
@statut = 'supprime'
assign_exports
end
def update_displayed_fields

View file

@ -140,6 +140,7 @@ class Instructeur < ApplicationRecord
def notifications_for_groupe_instructeurs(groupe_instructeurs)
Dossier
.visible_by_administration
.not_archived
.where(groupe_instructeur: groupe_instructeurs)
.merge(followed_dossiers)
@ -180,8 +181,8 @@ class Instructeur < ApplicationRecord
nb_notification = notifications[:en_cours].count + notifications[:termines].count
h = {
nb_en_construction: groupe.dossiers.en_construction.count,
nb_en_instruction: groupe.dossiers.en_instruction.count,
nb_en_construction: groupe.dossiers.visible_by_administration.en_construction.count,
nb_en_instruction: groupe.dossiers.visible_by_administration.en_instruction.count,
nb_accepted: Traitement.where(dossier: groupe.dossiers.accepte, processed_at: Time.zone.yesterday.beginning_of_day..Time.zone.yesterday.end_of_day).count,
nb_notification: nb_notification
}

View file

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

View file

@ -1,4 +1,7 @@
- if close_to_expiration || Dossier::TERMINE.include?(state)
- if hidden_by_administration
= link_to restore_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "button" do
= t('views.instructeurs.dossiers.restore')
- elsif close_to_expiration || Dossier::TERMINE.include?(state)
.dropdown.user-dossier-actions
%button.button.dropdown-button{ 'aria-expanded' => 'false', 'aria-controls' => 'actions-menu' }
Actions

View file

@ -7,13 +7,21 @@
.procedure-logo{ style: "background-image: url(#{@procedure.logo_url})",
role: 'img', 'aria-label': "logo de la démarche #{@procedure.libelle}" }
= render partial: 'header', locals: { procedure: @procedure,
= render partial: 'header', locals: { procedure: @procedure, statut: @statut }
.procedure-actions
- if @can_download_dossiers
= render partial: "download_dossiers", locals: { procedure: @procedure, exports: @exports }
.container.flex= render partial: "tabs", locals: { procedure: @procedure,
statut: @statut,
a_suivre_count: @a_suivre_count,
suivis_count: @suivis_count,
traites_count: @traites_count,
tous_count: @tous_count,
supprimes_recemment_count: @supprimes_recemment_count,
archives_count: @archives_count,
expirant_count: @expirant_count,
has_en_cours_notifications: @has_en_cours_notifications,
has_termine_notifications: @has_termine_notifications }

View file

@ -12,6 +12,7 @@
.procedure-actions
- if @can_download_dossiers
= render partial: "download_dossiers", locals: { procedure: @procedure, exports: @exports }
.container.flex= render partial: "tabs", locals: { procedure: @procedure,
statut: @statut,
a_suivre_count: @a_suivre_count,
@ -116,36 +117,46 @@
- path = instructeur_dossier_path(@procedure, p.dossier_id)
%tr{ class: [p.hidden_by_user_at.present? && "file-hidden-by-user"] }
%td.folder-col
%a.cell-link{ href: path }
%span.icon.folder
- if @not_archived_notifications_dossier_ids.include?(p.dossier_id)
%span.notifications{ 'aria-label': 'notifications' }
- if p.hidden_by_administration_at.present?
%span.cell-link
%span.icon.folder
- else
%a.cell-link{ href: path }
%span.icon.folder
- if @not_archived_notifications_dossier_ids.include?(p.dossier_id)
%span.notifications{ 'aria-label': 'notifications' }
%td.number-col
%a.cell-link{ href: path }= p.dossier_id
- if p.hidden_by_administration_at.present?
%span.cell-link= p.dossier_id
- else
%a.cell-link{ href: path }= p.dossier_id
- p.columns.each do |column|
%td
%a.cell-link{ href: path }
= column
= "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present?
- if p.hidden_by_administration_at.present?
%span.cell-link
= column
= "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present?
- else
%a.cell-link{ href: path }
= column
= "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present?
%td.status-col
%a.cell-link{ href: path }= status_badge(p.state)
- if p.hidden_by_administration_at.present?
%span.cell-link= status_badge(p.state)
- else
%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' }
%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',
hidden_by_administration: @statut == 'supprimes_recemment' }
= pagination
- else

View file

@ -93,7 +93,8 @@
state: p.state,
archived: p.archived,
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
close_to_expiration: nil }
close_to_expiration: nil,
hidden_by_administration: nil }
- else
%td