From b4b92accf15e64f5f3da8d4d6829e83e5c480fee Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Fri, 20 Mar 2020 17:59:16 +0100 Subject: [PATCH] instructeur: show deleted dossiers for a procedure --- app/assets/stylesheets/new_design/labels.scss | 20 ++++++ .../new_design/procedure_show.scss | 5 ++ .../instructeurs/procedures_controller.rb | 5 ++ app/helpers/dossier_helper.rb | 6 ++ .../procedures/deleted_dossiers.html.haml | 61 +++++++++++++++++++ .../instructeurs/procedures/show.html.haml | 4 ++ config/routes.rb | 1 + .../procedures_controller_spec.rb | 14 +++++ 8 files changed, 116 insertions(+) create mode 100644 app/views/instructeurs/procedures/deleted_dossiers.html.haml diff --git a/app/assets/stylesheets/new_design/labels.scss b/app/assets/stylesheets/new_design/labels.scss index 4a4cedf5f..9b0e797b3 100644 --- a/app/assets/stylesheets/new_design/labels.scss +++ b/app/assets/stylesheets/new_design/labels.scss @@ -17,21 +17,41 @@ border: 1px solid $blue; } + &.en-instruction { + @extend .instruction; + } + &.construction { background-color: #FFFFFF; color: $black; border: 1px solid $black; } + &.en-construction { + @extend .construction; + } + &.accepted { background-color: $green; } + &.accepte { + @extend .accepted; + } + &.refused { background-color: $dark-red; } + &.refuse { + @extend .refused; + } + &.without-continuation { background-color: $black; } + + &.sans-suite { + @extend .without-continuation; + } } diff --git a/app/assets/stylesheets/new_design/procedure_show.scss b/app/assets/stylesheets/new_design/procedure_show.scss index 5f9c31bb9..cb39939c1 100644 --- a/app/assets/stylesheets/new_design/procedure_show.scss +++ b/app/assets/stylesheets/new_design/procedure_show.scss @@ -30,6 +30,11 @@ } } + .afficher-dossiers-supprimes { + display: flex; + justify-content: flex-end; + } + .filter { display: inline-block; padding-left: 10px; diff --git a/app/controllers/instructeurs/procedures_controller.rb b/app/controllers/instructeurs/procedures_controller.rb index 4726bd12b..98d0015ea 100644 --- a/app/controllers/instructeurs/procedures_controller.rb +++ b/app/controllers/instructeurs/procedures_controller.rb @@ -113,6 +113,11 @@ module Instructeurs assign_exports end + def deleted_dossiers + @procedure = procedure + @deleted_dossiers = @procedure.deleted_dossiers.where.not(state: :brouillon) + end + def update_displayed_fields values = params[:values] diff --git a/app/helpers/dossier_helper.rb b/app/helpers/dossier_helper.rb index 50a24a464..30eeaf61c 100644 --- a/app/helpers/dossier_helper.rb +++ b/app/helpers/dossier_helper.rb @@ -83,6 +83,12 @@ module DossierHelper end end + def status_badge(state) + status_text = state.tr('_', ' ') + status_class = state.tr('_', '-') + content_tag(:span, status_text, class: "label #{status_class} ") + end + private def dinum_instance? diff --git a/app/views/instructeurs/procedures/deleted_dossiers.html.haml b/app/views/instructeurs/procedures/deleted_dossiers.html.haml new file mode 100644 index 000000000..216c4d48a --- /dev/null +++ b/app/views/instructeurs/procedures/deleted_dossiers.html.haml @@ -0,0 +1,61 @@ +- content_for(:title, "#{@procedure.libelle}") + +#procedure-show + .sub-header + .container.flex + + .procedure-logo{ style: "background-image: url(#{@procedure.logo_url})", + role: 'img', 'aria-label': "logo de la démarche #{@procedure.libelle}" } + + .procedure-header + %h1= procedure_libelle @procedure + = link_to 'gestion des notifications', email_notifications_instructeur_procedure_path(@procedure), class: 'header-link' + | + = link_to 'statistiques', stats_instructeur_procedure_path(@procedure), class: 'header-link', data: { turbolinks: false } # Turbolinks disabled for Chartkick. See Issue #350 + + - if @procedure.routee? + | + - if current_administrateur.present? && current_administrateur.owns?(@procedure) + = link_to 'instructeurs', procedure_groupe_instructeurs_path(@procedure), class: 'header-link' + - else + = link_to 'instructeurs', instructeur_groupes_path(@procedure), class: 'header-link' + + %ul.tabs + = tab_item('à suivre', + instructeur_procedure_path(@procedure, statut: 'a-suivre')) + = tab_item(t('pluralize.followed', count: 1), + instructeur_procedure_path(@procedure, statut: 'suivis'), + active: @statut == 'suivis') + + = tab_item(t('pluralize.processed', count: 1), + instructeur_procedure_path(@procedure, statut: 'traites')) + + = tab_item('tous les dossiers', + instructeur_procedure_path(@procedure, statut: 'tous')) + + = tab_item(t('pluralize.archived', count: 1), + instructeur_procedure_path(@procedure, statut: 'archives'), + active: true) + + .container + %p.explication-onglet Les dossiers ont été supprimés. Vous ne pouvez plus les récupérer depuis Démarches Simplifiées. + - if @deleted_dossiers.any? + %table.table.dossiers-table.hoverable + %thead + %tr + %th.notification-col + %th.number-col N° dossier + %th.status-col Etat + %th.status-col Date de suppression + %tbody + - @deleted_dossiers.each do |deleted_dossier| + %tr + %td.folder-col + %span.icon.folder + %td.number-col= deleted_dossier.dossier_id + %td.status-col + = status_badge(deleted_dossier.state) + %td.date-col= l(deleted_dossier.deleted_at, format: '%d/%m/%y') + - else + Aucun dossier supprimé + diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index a93ef3493..30893d513 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -63,6 +63,10 @@ %p.explication-onglet Tous les dossiers qui ont été déposés sur cette démarche, sans aucun filtre. - if @statut == 'archives' %p.explication-onglet Les dossiers de cet onglet sont archivés : vous ne pouvez plus y répondre, et les demandeurs ne peuvent plus les modifier. + .afficher-dossiers-supprimes + = link_to deleted_dossiers_instructeur_procedure_path(@procedure) do + %span.icon.delete + Afficher les dossiers supprimés - if @dossiers.present? || @current_filters.count > 0 = paginate @dossiers diff --git a/config/routes.rb b/config/routes.rb index 27144a8f5..e3c7f3552 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -307,6 +307,7 @@ Rails.application.routes.draw do get 'stats' get 'email_notifications' patch 'update_email_notifications' + get 'deleted_dossiers' resources :dossiers, only: [:show], param: :dossier_id do member do diff --git a/spec/controllers/instructeurs/procedures_controller_spec.rb b/spec/controllers/instructeurs/procedures_controller_spec.rb index 4fde099fa..638d4313b 100644 --- a/spec/controllers/instructeurs/procedures_controller_spec.rb +++ b/spec/controllers/instructeurs/procedures_controller_spec.rb @@ -411,6 +411,20 @@ describe Instructeurs::ProceduresController, type: :controller do end end + describe '#deleted_dossiers' do + let(:instructeur) { create(:instructeur) } + let(:procedure) { create(:procedure, instructeurs: [instructeur]) } + let(:deleted_dossier) { create(:deleted_dossier, procedure: procedure, state: :en_construction) } + let!(:deleted_dossier_brouillon) { create(:deleted_dossier, procedure: procedure, state: :brouillon) } + + before do + sign_in(instructeur.user) + get :deleted_dossiers, params: { procedure_id: procedure.id } + end + + it { expect(assigns(:deleted_dossiers)).to match_array([deleted_dossier]) } + end + describe '#update_email_notifications' do let(:instructeur) { create(:instructeur) } let!(:procedure) { create(:procedure, instructeurs: [instructeur]) }