diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index c636d5344..31d0f67fb 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -6,7 +6,7 @@ module Users 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 @@ -60,7 +60,7 @@ module Users @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_historique = deleted_dossiers + @dossiers_supprimes_historique = deleted_dossiers @statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes, @dossier_transferes, @dossiers_close_to_expiration, params[:statut]) @@ -429,6 +429,10 @@ module Users 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 diff --git a/app/views/users/dossiers/_deleted_dossiers_list.html.haml b/app/views/users/dossiers/_deleted_dossiers_list.html.haml deleted file mode 100644 index 55846eba4..000000000 --- a/app/views/users/dossiers/_deleted_dossiers_list.html.haml +++ /dev/null @@ -1,30 +0,0 @@ -- if deleted_dossiers.present? - %h2.fr-h6.fr-mb-2w - = page_entries_info deleted_dossiers - - - deleted_dossiers.each do |dossier| - .card - .flex.justify-between - %div - %h3.card-title - = dossier.procedure.libelle - - %p.fr-icon--sm.fr-icon-delete-line.fr-mb-0 - = t('views.users.dossiers.dossiers_list.deleted', date: l(dossier.updated_at.to_date)) - = "-" - = t("activerecord.attributes.deleted_dossier.reason.#{dossier.reason}") - - .text-right - %p.fr-mb-0 - = t('views.users.dossiers.dossiers_list.n_dossier') - = dossier.dossier_id - - = status_badge(dossier.state, 'fr-mb-1w') - - = paginate deleted_dossiers, views_prefix: 'shared' - -- else - .blank-tab - %h2.empty-text= t('views.users.dossiers.dossiers_list.no_result_title') - %p.empty-text-details - = t('views.users.dossiers.dossiers_list.no_result_text_html', app_base: Current.application_base_url) diff --git a/app/views/users/dossiers/deleted_dossiers.html.haml b/app/views/users/dossiers/deleted_dossiers.html.haml new file mode 100644 index 000000000..9d30962cf --- /dev/null +++ b/app/views/users/dossiers/deleted_dossiers.html.haml @@ -0,0 +1,41 @@ +- content_for(:title, "Historique des dossiers supprimés") + += render partial: 'administrateurs/breadcrumbs', + locals: { steps: [['Historique des dossiers supprimés']] } + + +.fr-container + .fr-mb-3w + = link_to "Retour à la liste des dossiers", dossiers_path(), class: "fr-link fr-icon-arrow-left-line fr-link--icon-left" + %h1.fr-h2 + Historique des dossiers supprimés + +.fr-container + - if @deleted_dossiers.present? + %h2.fr-h6.fr-mb-2w + = page_entries_info @deleted_dossiers + + - @deleted_dossiers.each do |dossier| + .card + .flex.justify-between + %div + %h3.card-title + = dossier.procedure.libelle + + %p.fr-icon--sm.fr-icon-delete-line.fr-mb-0 + = t('views.users.dossiers.dossiers_list.deleted', date: l(dossier.updated_at.to_date)) + = "-" + = t("activerecord.attributes.deleted_dossier.reason.#{dossier.reason}") + + .text-right + %p.fr-mb-0 + = t('views.users.dossiers.dossiers_list.n_dossier') + = dossier.dossier_id + + = paginate @deleted_dossiers, views_prefix: 'shared' + + - else + .blank-tab + %h2.empty-text= t('views.users.dossiers.dossiers_list.no_result_title') + %p.empty-text-details + = t('views.users.dossiers.dossiers_list.no_result_text_html', app_base: Current.application_base_url) diff --git a/app/views/users/dossiers/index.html.haml b/app/views/users/dossiers/index.html.haml index 721679518..b2ce5dcb9 100644 --- a/app/views/users/dossiers/index.html.haml +++ b/app/views/users/dossiers/index.html.haml @@ -5,7 +5,11 @@ .dossiers-headers.sub-header .fr-container - %h1.page-title.fr-h2= t('views.users.dossiers.index.dossiers') + .flex.align-center + %h1.page-title.fr-h2= t('views.users.dossiers.index.dossiers') + - if @dossiers_supprimes_historique.present? + %p.ml-auto + = link_to('Historique des dossiers supprimés', deleted_dossiers_path(), class: 'fr-link') .fr-grid-row.fr-grid-row--gutters - if current_user.dossiers.count > 2 || current_user.dossiers_invites.count > 2 @@ -82,9 +86,4 @@ - else = render Dossiers::UserFilterComponent.new(statut: @statut, filter: @filter, procedure_id: @procedure_id ) - - - if @statut == "dossiers-supprimes-definitivement" - -# /!\ in this context, @dossiers is a collection of DeletedDossier not Dossier - = render partial: "deleted_dossiers_list", locals: { deleted_dossiers: @dossiers } - - else - = render partial: "dossiers_list", locals: { dossiers: @dossiers, filter: @filter, statut: @statut, search: false } + = render partial: "dossiers_list", locals: { dossiers: @dossiers, filter: @filter, statut: @statut, search: false } diff --git a/config/routes.rb b/config/routes.rb index 1fddada7d..76c043c26 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -389,6 +389,7 @@ Rails.application.routes.draw do resource :feedback, only: [:create] get 'demarches' => 'demarches#index' + get 'deleted_dossiers' => 'dossiers#deleted_dossiers' get 'profil' => 'profil#show' patch 'update_email' => 'profil#update_email'