Merge pull request #4464 from betagouv/manager-improve-procedure

manager: allow hidden procedures to be searched
This commit is contained in:
Paul Chavard 2019-10-31 17:10:41 +01:00 committed by GitHub
commit 77cdd522bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -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

View file

@ -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 %>
<div>
</header>