From 0695ea322a46f517012c075c9672c546b959bb7c Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Fri, 11 Mar 2022 13:57:53 +0100 Subject: [PATCH] refactor(instructeur): improuve dossiers list view --- .../instructeurs/procedures_controller.rb | 9 ++- app/models/instructeur.rb | 5 +- .../dossiers/_header_actions.html.haml | 3 +- .../procedures/_dossier_actions.html.haml | 5 +- .../procedures/deleted_dossiers.html.haml | 10 +++- .../instructeurs/procedures/show.html.haml | 55 +++++++++++-------- app/views/recherche/index.html.haml | 3 +- 7 files changed, 59 insertions(+), 31 deletions(-) diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 52d2e44ce..6105efc5a 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -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 diff --git a/app/models/instructeur.rb b/app/models/instructeur.rb index 6ab359dae..77682fe5c 100644 --- a/app/models/instructeur.rb +++ b/app/models/instructeur.rb @@ -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 } diff --git a/app/views/instructeurs/dossiers/_header_actions.html.haml b/app/views/instructeurs/dossiers/_header_actions.html.haml index 47f7b4893..671340d53 100644 --- a/app/views/instructeurs/dossiers/_header_actions.html.haml +++ b/app/views/instructeurs/dossiers/_header_actions.html.haml @@ -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 diff --git a/app/views/instructeurs/procedures/_dossier_actions.html.haml b/app/views/instructeurs/procedures/_dossier_actions.html.haml index ef18a2556..76d90c6b5 100644 --- a/app/views/instructeurs/procedures/_dossier_actions.html.haml +++ b/app/views/instructeurs/procedures/_dossier_actions.html.haml @@ -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 diff --git a/app/views/instructeurs/procedures/deleted_dossiers.html.haml b/app/views/instructeurs/procedures/deleted_dossiers.html.haml index be960eb77..f702298b2 100644 --- a/app/views/instructeurs/procedures/deleted_dossiers.html.haml +++ b/app/views/instructeurs/procedures/deleted_dossiers.html.haml @@ -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 } diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index 334d0b4bb..e9d171bb5 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -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 diff --git a/app/views/recherche/index.html.haml b/app/views/recherche/index.html.haml index 72c91916e..1c5609d4f 100644 --- a/app/views/recherche/index.html.haml +++ b/app/views/recherche/index.html.haml @@ -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