From 627d30191fa56f09994a1849a3a240b3984773c3 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 31 Oct 2019 16:30:39 +0100 Subject: [PATCH] manager: allow hidden procedures to be searched The Manager::DossiersController already allow hidden dossiers to be searched and displayed. Give the same behavior to Procedures. --- .../manager/procedures_controller.rb | 20 +++++++++++++++++++ app/views/manager/procedures/show.html.erb | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/controllers/manager/procedures_controller.rb b/app/controllers/manager/procedures_controller.rb index b3241429f..846e103de 100644 --- a/app/controllers/manager/procedures_controller.rb +++ b/app/controllers/manager/procedures_controller.rb @@ -1,5 +1,21 @@ module Manager class ProceduresController < Manager::ApplicationController + # + # Administrate overrides + # + + # Override this if you have certain roles that require a subset + # this will be used to set the records shown on the `index` action. + def scoped_resource + if unfiltered_list? + # Don't display deleted dossiers in the unfiltered list… + Procedure + else + # … but allow them to be searched and displayed. + Procedure.unscope(:where) + end + end + def whitelist procedure.whitelist! flash[:notice] = "Démarche whitelistée." @@ -55,5 +71,9 @@ module Manager def type_de_champ_params params.require(:type_de_champ).permit(:piece_justificative_template) end + + def unfiltered_list? + action_name == "index" && !params[:search] + end end end diff --git a/app/views/manager/procedures/show.html.erb b/app/views/manager/procedures/show.html.erb index be61830b1..95216c8d4 100644 --- a/app/views/manager/procedures/show.html.erb +++ b/app/views/manager/procedures/show.html.erb @@ -43,7 +43,9 @@ as well as a link to its edit page. <%= link_to 'repasser en test', draft_manager_procedure_path(procedure), method: :post, class: 'button' %> <% end %> - <%= link_to 'supprimer la démarche', hide_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la suppression de la démarche ?" } %> + <% if !procedure.hidden? %> + <%= link_to 'supprimer la démarche', hide_manager_procedure_path(procedure), method: :post, class: 'button', data: { confirm: "Confirmez-vous la suppression de la démarche ?" } %> + <% end %>