Merge pull request #2780 from tchak/manager-downgrade-to-brouillon-button
Add button in manager to transition démarche in brouillon state
This commit is contained in:
commit
94061ec0ce
4 changed files with 24 additions and 0 deletions
|
@ -6,5 +6,16 @@ module Manager
|
||||||
flash[:notice] = "Démarche whitelistée."
|
flash[:notice] = "Démarche whitelistée."
|
||||||
redirect_to manager_procedure_path(procedure)
|
redirect_to manager_procedure_path(procedure)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def draft
|
||||||
|
procedure = Procedure.find(params[:id])
|
||||||
|
if procedure.dossiers.empty?
|
||||||
|
procedure.draft!
|
||||||
|
flash[:notice] = "La démarche a bien été passée en brouillon."
|
||||||
|
else
|
||||||
|
flash[:alert] = "Impossible de repasser en brouillon une démarche à laquelle sont rattachés des dossiers."
|
||||||
|
end
|
||||||
|
redirect_to manager_procedure_path(procedure)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -86,6 +86,10 @@ class Procedure < ApplicationRecord
|
||||||
transitions from: :publiee, to: :hidden
|
transitions from: :publiee, to: :hidden
|
||||||
transitions from: :archivee, to: :hidden
|
transitions from: :archivee, to: :hidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
event :draft, after: :after_draft do
|
||||||
|
transitions from: :publiee, to: :brouillon
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish_or_reopen!(path)
|
def publish_or_reopen!(path)
|
||||||
|
@ -372,6 +376,10 @@ class Procedure < ApplicationRecord
|
||||||
publish_with_path!(path)
|
publish_with_path!(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def after_draft
|
||||||
|
update!(published_at: nil)
|
||||||
|
end
|
||||||
|
|
||||||
def update_juridique_required
|
def update_juridique_required
|
||||||
self.juridique_required ||= (cadre_juridique.present? || deliberation.attached?)
|
self.juridique_required ||= (cadre_juridique.present? || deliberation.attached?)
|
||||||
true
|
true
|
||||||
|
|
|
@ -36,6 +36,10 @@ as well as a link to its edit page.
|
||||||
<% if !procedure.whitelisted? %>
|
<% if !procedure.whitelisted? %>
|
||||||
<%= link_to 'whitelister', whitelist_manager_procedure_path(procedure), method: :post, class: 'button' %>
|
<%= link_to 'whitelister', whitelist_manager_procedure_path(procedure), method: :post, class: 'button' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if procedure.publiee? && procedure.dossiers.empty? %>
|
||||||
|
<%= link_to 'passer en brouillon', draft_manager_procedure_path(procedure), method: :post, class: 'button' %>
|
||||||
|
<% end %>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -8,6 +8,7 @@ Rails.application.routes.draw do
|
||||||
namespace :manager do
|
namespace :manager do
|
||||||
resources :procedures, only: [:index, :show] do
|
resources :procedures, only: [:index, :show] do
|
||||||
post 'whitelist', on: :member
|
post 'whitelist', on: :member
|
||||||
|
post 'draft', on: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :dossiers, only: [:index, :show] do
|
resources :dossiers, only: [:index, :show] do
|
||||||
|
|
Loading…
Reference in a new issue