Skip to content

Commit

Permalink
Merge pull request #10627 from demarches-simplifiees/simplify-tabs-su…
Browse files Browse the repository at this point in the history
…pprimes-ldu

[UX] Simplifier l'interface avec un onglet unique pour les dossiers supprimés
  • Loading branch information
lisa-durand authored Aug 20, 2024
2 parents f50d494 + 16864cc commit 49e9d4a
Show file tree
Hide file tree
Showing 40 changed files with 205 additions and 204 deletions.
4 changes: 2 additions & 2 deletions app/components/dossiers/batch_operation_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(statut:, procedure:)
end

def render?
['a-suivre', 'traites', 'suivis', 'archives', 'supprimes_recemment', 'expirant'].include?(@statut)
['a-suivre', 'traites', 'suivis', 'archives', 'supprimes', 'expirant'].include?(@statut)
end

def operations_for_dossier(dossier)
Expand Down Expand Up @@ -81,7 +81,7 @@ def available_operations
}
]
}
when 'supprimes_recemment' then
when 'supprimes' then
{
options:
[
Expand Down
11 changes: 11 additions & 0 deletions app/components/dossiers/deleted_dossiers_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Dossiers::DeletedDossiersComponent < ApplicationComponent
include DossierHelper

def initialize(deleted_dossiers:)
@deleted_dossiers = deleted_dossiers
end

def role
controller.try(:nav_bar_profile)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
en:
deleted_explanation: "The folders have been deleted. You can no longer recover them for the following reasons:"
deleted_explanation_first_instructor: The user intentionally deleted their folder.
deleted_explanation_second_instructor: The maximum retention period has expired. In accordance with GDPR regulations, the application cannot continue to host them.
deleted_explanation_first_user: You have deleted your folder.
deleted_explanation_second_user: The maximum retention period has expired. In accordance with GDPR regulations, the application cannot continue to host them.
no_deleted_folders: You have no permanently deleted folders.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fr:
deleted_explanation: "Les dossiers ont été supprimés. Vous ne pouvez plus les récupérer pour les raisons suivantes :"
deleted_explanation_first_instructeur: L’utilisateur a intentionnellement supprimé son dossier.
deleted_explanation_second_instructeur: Le délai de conservation maximal a expiré. Conformément au règlement RGPD, l'application ne peut continuer à les héberger.
deleted_explanation_first_user: Vous avez supprimé votre dossier.
deleted_explanation_second_user: Le délai de conservation maximal a expiré. Conformément au règlement RGPD, l'application ne peut continuer à les héberger.
no_deleted_dossiers: Vous n'avez pas de dossiers supprimés définitivement.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

.fr-container
%h1.fr-h2
Historique des dossiers supprimés

.fr-container
- if @deleted_dossiers.present?
= render Dsfr::CalloutComponent.new(title: nil) do |c|
- c.with_body do
%p
= t('.deleted_explanation')

%ul
%li
= t(".deleted_explanation_first_#{role}")
%li
= t(".deleted_explanation_second_#{role}")

.fr-table.fr-table--layout-fixed.fr-mt-3w
%table
%thead
%tr
%th.number-col N° dossier
%th Libellé de la démarche
%th Raison de suppression
%th Date de suppression
%tbody
- @deleted_dossiers.each do |deleted_dossier|
%tr
%td.number-col
= deleted_dossier.dossier_id

%td.number-col
= deleted_dossier.procedure.libelle.truncate_words(10)

%td
= deletion_reason_badge(deleted_dossier.reason)
-# .fr-badge
-# = t("activerecord.attributes.deleted_dossier.reason.#{deleted_dossier.reason}")
%td.deleted-cell
= l(deleted_dossier.deleted_at, format: '%d/%m/%y')

= paginate @deleted_dossiers, views_prefix: 'shared'

- else
%p
= t('.no_deleted_dossiers')
8 changes: 4 additions & 4 deletions app/controllers/instructeurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def index
@dossiers_archived_count_per_procedure = dossiers.by_statut('archives').group('groupe_instructeurs.procedure_id').count
@dossiers_termines_count_per_procedure = dossiers.by_statut('traites').group('groupe_instructeurs.procedure_id').reorder(nil).count
@dossiers_expirant_count_per_procedure = dossiers.by_statut('expirant').group('groupe_instructeurs.procedure_id').count
@dossiers_supprimes_recemment_count_per_procedure = dossiers.by_statut('supprimes_recemment').group('groupe_instructeurs.procedure_id').reorder(nil).count
@dossiers_supprimes_count_per_procedure = dossiers.by_statut('supprimes').group('groupe_instructeurs.procedure_id').reorder(nil).count

groupe_ids = current_instructeur.groupe_instructeurs.pluck(:id)
@followed_dossiers_count_per_procedure = current_instructeur
Expand All @@ -56,7 +56,7 @@ def index
t('.all') => @dossiers_count_per_procedure.sum { |_, v| v },
t('.dossiers_close_to_expiration') => @dossiers_expirant_count_per_procedure.sum { |_, v| v },
t('.archived') => @dossiers_archived_count_per_procedure.sum { |_, v| v },
t('.dossiers_supprimes_recemment') => @dossiers_supprimes_recemment_count_per_procedure.sum { |_, v| v }
t('.dossiers_supprimes') => @dossiers_supprimes_count_per_procedure.sum { |_, v| v }
}

@procedure_ids_en_cours_with_notifications = current_instructeur.procedure_ids_with_notifications(:en_cours)
Expand Down Expand Up @@ -120,9 +120,9 @@ def deleted_dossiers
.order(:dossier_id)
.page params[:page]

@a_suivre_count, @suivis_count, @traites_count, @tous_count, @archives_count, @supprimes_recemment_count, @expirant_count = current_instructeur
@a_suivre_count, @suivis_count, @traites_count, @tous_count, @archives_count, @supprimes_count, @expirant_count = current_instructeur
.dossiers_count_summary(groupe_instructeur_ids)
.fetch_values('a_suivre', 'suivis', 'traites', 'tous', 'archives', 'supprimes_recemment', 'expirant')
.fetch_values('a_suivre', 'suivis', 'traites', 'tous', 'archives', 'supprimes', 'expirant')
@can_download_dossiers = (@tous_count + @archives_count) > 0 && !instructeur_as_manager?

notifications = current_instructeur.notifications_for_groupe_instructeurs(groupe_instructeur_ids)
Expand Down
27 changes: 11 additions & 16 deletions app/controllers/users/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DossiersController < UserController

layout 'procedure_context', only: [:identite, :update_identite, :siret, :update_siret]

ACTIONS_ALLOWED_TO_ANY_USER = [:index, :new, :transferer_all]
ACTIONS_ALLOWED_TO_ANY_USER = [:index, :new, :transferer_all, :deleted_dossiers]
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :destroy, :demande, :messagerie, :brouillon, :submit_brouillon, :submit_en_construction, :modifier, :modifier_legacy, :update, :create_commentaire, :papertrail, :restore, :champ]

before_action :ensure_ownership!, except: ACTIONS_ALLOWED_TO_ANY_USER + ACTIONS_ALLOWED_TO_OWNER_OR_INVITE
Expand All @@ -26,43 +26,37 @@ class DossiersController < UserController

def index
ordered_dossiers = Dossier.includes(:procedure).order_by_updated_at
deleted_dossiers = current_user.deleted_dossiers.includes(:procedure).order_by_updated_at

user_revisions = ProcedureRevision.where(dossiers: current_user.dossiers.visible_by_user)
invite_revisions = ProcedureRevision.where(dossiers: current_user.dossiers_invites.visible_by_user)
deleted_dossier_procedures = Procedure.where(id: deleted_dossiers.pluck(:procedure_id))
all_dossier_procedures = Procedure.where(revisions: user_revisions.or(invite_revisions))

@procedures_for_select = all_dossier_procedures
.or(deleted_dossier_procedures)
.distinct(:procedure_id)
.order(:libelle)
.pluck(:libelle, :id)

@procedure_id = params[:procedure_id]
if @procedure_id.present?
ordered_dossiers = ordered_dossiers.where(procedures: { id: @procedure_id })
deleted_dossiers = deleted_dossiers.where(procedures: { id: @procedure_id })
end

@search_terms = params[:q]
if @search_terms.present?
dossiers_filter_by_search = DossierSearchService.matching_dossiers_for_user(@search_terms, current_user).page
ordered_dossiers = ordered_dossiers.merge(dossiers_filter_by_search)
deleted_dossiers = nil
end

@dossiers_visibles = ordered_dossiers.visible_by_user.preload(:etablissement, :individual, :invites)

@user_dossiers = current_user.dossiers.state_not_termine.merge(@dossiers_visibles)
@dossiers_traites = current_user.dossiers.state_termine.merge(@dossiers_visibles)
@dossiers_invites = current_user.dossiers_invites.merge(@dossiers_visibles)
@dossiers_supprimes_recemment = (current_user.dossiers.hidden_by_user.or(current_user.dossiers.hidden_by_expired)).merge(ordered_dossiers)
@dossiers_supprimes = (current_user.dossiers.hidden_by_user.or(current_user.dossiers.hidden_by_expired)).merge(ordered_dossiers)
@dossier_transferes = @dossiers_visibles.where(dossier_transfer_id: DossierTransfer.for_email(current_user.email))
@dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.merge(@dossiers_visibles)
@dossiers_supprimes_definitivement = deleted_dossiers

@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transferes, @dossiers_close_to_expiration, params[:statut])
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes, @dossier_transferes, @dossiers_close_to_expiration, params[:statut])

@dossiers = case @statut
when 'en-cours'
Expand All @@ -71,10 +65,8 @@ def index
@dossiers_traites
when 'dossiers-invites'
@dossiers_invites
when 'dossiers-supprimes-recemment'
@dossiers_supprimes_recemment
when 'dossiers-supprimes-definitivement'
@dossiers_supprimes_definitivement
when 'dossiers-supprimes'
@dossiers_supprimes
when 'dossiers-transferes'
@dossier_transferes
when 'dossiers-expirant'
Expand Down Expand Up @@ -431,18 +423,21 @@ def clone
redirect_to dossier_path(@dossier)
end

def deleted_dossiers
@deleted_dossiers = current_user.deleted_dossiers.includes(:procedure).order_by_updated_at.page(page)
end

private

# if the status tab is filled, then this tab
# else first filled tab
# else en-cours
def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes_recemment, dossiers_supprimes_definitivement, dossier_transferes, dossiers_close_to_expiration, params_statut)
def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes, dossier_transferes, dossiers_close_to_expiration, params_statut)
tabs = {
'en-cours' => mes_dossiers,
'traites' => dossiers_traites,
'dossiers-invites' => dossiers_invites,
'dossiers-supprimes-recemment' => dossiers_supprimes_recemment,
'dossiers-supprimes-definitivement' => dossiers_supprimes_definitivement,
'dossiers-supprimes' => dossiers_supprimes,
'dossiers-transferes' => dossier_transferes,
'dossiers-expirant' => dossiers_close_to_expiration
}
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/dossier_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deletion_reason_badge(reason)
status_class = 'unknown'
end

tag.span(status_text, class: "label #{status_class} ")
tag.span(status_text, class: "fr-badge #{status_class} ")
end

def pending_correction_badge(for_profile, html_class: nil)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/tabs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def tab_i18n_key_from_status(status)
'pluralize.processed'
when 'tous'
'views.instructeurs.dossiers.tab_steps.total' # i18n-tasks-use t('views.instructeurs.dossiers.tab_steps.total')
when 'supprimes_recemment'
'pluralize.dossiers_supprimes_recemment'
when 'supprimes'
'pluralize.dossiers_supprimes'
when 'expirant'
'pluralize.dossiers_close_to_expiration'
when 'archives'
Expand Down
2 changes: 1 addition & 1 deletion app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def classer_sans_suite(motivation: nil, instructeur: nil, processed_at: Time.zon
visible_by_administration.termine
when 'tous'
visible_by_administration.all_state
when 'supprimes_recemment'
when 'supprimes'
hidden_by_administration.state_termine.or(hidden_by_expired)
when 'archives'
visible_by_administration.archived
Expand Down
2 changes: 1 addition & 1 deletion app/models/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Export < ApplicationRecord
suivis: 'suivis',
traites: 'traites',
tous: 'tous',
supprimes_recemment: 'supprimes_recemment',
supprimes: 'supprimes',
archives: 'archives',
expirant: 'expirant'
}
Expand Down
2 changes: 1 addition & 1 deletion app/models/instructeur.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def dossiers_count_summary(groupe_instructeur_ids)
COUNT(DISTINCT dossiers.id) FILTER (where dossiers.hidden_by_administration_at IS NULL AND dossiers.hidden_by_expired_at IS NULL AND not archived AND dossiers.state in ('accepte', 'refuse', 'sans_suite')) AS traites,
COUNT(DISTINCT dossiers.id) FILTER (where dossiers.hidden_by_administration_at IS NULL AND dossiers.hidden_by_expired_at IS NULL AND not archived) AS tous,
COUNT(DISTINCT dossiers.id) FILTER (where dossiers.hidden_by_administration_at IS NULL AND dossiers.hidden_by_expired_at IS NULL AND archived) AS archives,
COUNT(DISTINCT dossiers.id) FILTER (where dossiers.hidden_by_administration_at IS NOT NULL AND not archived OR dossiers.hidden_by_expired_at IS NOT NULL) AS supprimes_recemment,
COUNT(DISTINCT dossiers.id) FILTER (where dossiers.hidden_by_administration_at IS NOT NULL AND not archived OR dossiers.hidden_by_expired_at IS NOT NULL) AS supprimes,
COUNT(DISTINCT dossiers.id) FILTER (where dossiers.hidden_by_administration_at IS NULL AND dossiers.hidden_by_expired_at IS NULL AND procedures.procedure_expires_when_termine_enabled
AND (
dossiers.state in ('accepte', 'refuse', 'sans_suite')
Expand Down
4 changes: 4 additions & 0 deletions app/views/instructeurs/procedures/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
|
= link_to t('instructeurs.dossiers.header.banner.administrators_list'), administrateurs_instructeur_procedure_path(procedure), class: 'header-link'
|
= link_to t('views.instructeurs.dossiers.show_deleted_dossiers'), deleted_dossiers_instructeur_procedure_path(@procedure), class: "header-link"
|
= link_to t('instructeurs.dossiers.header.banner.exports_list'), exports_instructeur_procedure_path(procedure), class: 'header-link'
- if @has_export_notification
%span.notifications{ 'aria-label': t('instructeurs.dossiers.header.banner.exports_notification_label') }



#last-export-alert
= render partial: "last_export_alert", locals: { export: @last_export, statut: @statut }
6 changes: 3 additions & 3 deletions app/views/instructeurs/procedures/_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@

%li
%object
= link_to(instructeur_procedure_path(p, statut: 'supprimes_recemment')) do
- dossier_count = dossiers_supprimes_recemment_count_per_procedure[p.id] || 0
= link_to(instructeur_procedure_path(p, statut: 'supprimes')) do
- dossier_count = dossiers_supprimes_count_per_procedure[p.id] || 0
.stats-number
= number_with_html_delimiter(dossier_count)
.stats-legend
= t('pluralize.dossiers_supprimes_recemment', count: dossier_count)
= t('pluralize.dossiers_supprimes', count: dossier_count)

- if p.procedure_expires_when_termine_enabled
%li
Expand Down
8 changes: 4 additions & 4 deletions app/views/instructeurs/procedures/_tabs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
active: statut == 'tous',
badge: number_with_html_delimiter(tous_count))

= tab_item(t(tab_i18n_key_from_status('supprimes_recemment'), count: supprimes_recemment_count),
instructeur_procedure_path(procedure, statut: 'supprimes_recemment'),
active: statut == 'supprimes_recemment',
badge: number_with_html_delimiter(supprimes_recemment_count))
= tab_item(t(tab_i18n_key_from_status('supprimes'), count: supprimes_count),
instructeur_procedure_path(procedure, statut: 'supprimes'),
active: statut == 'supprimes',
badge: number_with_html_delimiter(supprimes_count))

- if procedure.procedure_expires_when_termine_enabled
= tab_item(t(tab_i18n_key_from_status('expirant'), count: expirant_count),
Expand Down
58 changes: 7 additions & 51 deletions app/views/instructeurs/procedures/deleted_dossiers.html.haml
Original file line number Diff line number Diff line change
@@ -1,55 +1,11 @@
- content_for(:title, "#{@procedure.libelle}")

#procedure-show
.sub-header
.fr-container.flex
= render partial: 'administrateurs/breadcrumbs',
locals: { steps: [[@procedure.libelle.truncate_words(10), instructeur_procedure_path(@procedure)],
['Historique des dossiers supprimés']] }

.procedure-logo{ style: "background-image: url(#{@procedure.logo_url})",
role: 'img', 'aria-label': "logo de la démarche #{@procedure.libelle}" }
.fr-container
.fr-mb-3w
= link_to "Retour à la démarche", instructeur_procedure_path(@procedure), class: "fr-link fr-icon-arrow-left-line fr-link--icon-left"

= render partial: 'header', locals: { procedure: @procedure, statut: @statut }

.procedure-actions
- if @can_download_dossiers
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates_for(@procedure), export_url: method(:download_export_instructeur_procedure_path))

.fr-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 }

.fr-container
%h1.titre-dossiers Dossiers supprimés
%details
%summary Les dossiers ont été supprimés. Vous ne pouvez plus les récupérer depuis Démarches Simplifiées.
Ceci s'explique pour les raisons suivantes :
%ul
%li L’utilisateur a intentionnellement supprimé son dossier.
%li Le délai de conservation maximal de #{@procedure.duree_conservation_dossiers_dans_ds} mois a expiré. Conformément au règlement RGPD, DS ne peut continuer à les héberger.
- if @deleted_dossiers.any?
= paginate @deleted_dossiers, views_prefix: 'shared'
%table.table.dossiers-table.hoverable
%thead
%tr
%th.number-col N° dossier
%th Raison de suppression
%th Date de suppression
%tbody
- @deleted_dossiers.each do |deleted_dossier|
%tr
%td.number-col
= deleted_dossier.dossier_id
%td
= deletion_reason_badge(deleted_dossier.reason)
%td.deleted-cell
= l(deleted_dossier.deleted_at, format: '%d/%m/%y')
= paginate @deleted_dossiers, views_prefix: 'shared'
- else
Aucun dossier supprimé
= render Dossiers::DeletedDossiersComponent.new(deleted_dossiers: @deleted_dossiers)
2 changes: 1 addition & 1 deletion app/views/instructeurs/procedures/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
dossiers_archived_count_per_procedure: @dossiers_archived_count_per_procedure,
dossiers_termines_count_per_procedure: @dossiers_termines_count_per_procedure,
dossiers_expirant_count_per_procedure: @dossiers_expirant_count_per_procedure,
dossiers_supprimes_recemment_count_per_procedure: @dossiers_supprimes_recemment_count_per_procedure,
dossiers_supprimes_count_per_procedure: @dossiers_supprimes_count_per_procedure,
followed_dossiers_count_per_procedure: @followed_dossiers_count_per_procedure,
procedure_ids_en_cours_with_notifications: @procedure_ids_en_cours_with_notifications,
procedure_ids_termines_with_notifications: @procedure_ids_termines_with_notifications }
Expand Down
Loading

0 comments on commit 49e9d4a

Please sign in to comment.