Merge pull request #7417 from betagouv/feat/7414
ETQ Admin, lorsque j'archive une démarche, je souhaite indiquer s'il existe une nouvelle démarche
This commit is contained in:
commit
d140d8c263
7 changed files with 62 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
module Administrateurs
|
||||
class ProceduresController < AdministrateurController
|
||||
before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :allow_expert_review, :experts_require_administrateur_invitation]
|
||||
before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :close, :allow_expert_review, :experts_require_administrateur_invitation]
|
||||
before_action :procedure_revisable?, only: [:champs, :annotations, :modifications]
|
||||
|
||||
ITEMS_PER_PAGE = 25
|
||||
|
@ -146,6 +146,12 @@ module Administrateurs
|
|||
|
||||
def archive
|
||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||
|
||||
if params[:new_procedure].present?
|
||||
new_procedure = current_administrateur.procedures.find(params[:new_procedure])
|
||||
procedure.update!(replaced_by_procedure_id: new_procedure.id)
|
||||
end
|
||||
|
||||
procedure.close!
|
||||
|
||||
flash.notice = "Démarche close"
|
||||
|
@ -243,6 +249,9 @@ module Administrateurs
|
|||
def transfert
|
||||
end
|
||||
|
||||
def close
|
||||
end
|
||||
|
||||
def allow_expert_review
|
||||
@procedure.update!(allow_expert_review: !@procedure.allow_expert_review)
|
||||
flash.notice = @procedure.allow_expert_review? ? "Avis externes activés" : "Avis externes désactivés"
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
- if procedure.publiee?
|
||||
%li
|
||||
= link_to admin_procedure_archive_path(procedure_id: procedure.id), method: :put, data: { confirm: "Voulez-vous vraiment clore la démarche ? \nLes dossiers en cours pourront être instruits, mais aucun nouveau dossier ne pourra plus être déposé.", disable_with: "Archivage..."} do
|
||||
= link_to admin_procedure_close_path(procedure_id: procedure.id) do
|
||||
%span.icon.archive
|
||||
.dropdown-description
|
||||
%h4= t('administrateurs.dropdown_actions.to_close')
|
||||
|
|
13
app/views/administrateurs/procedures/close.html.haml
Normal file
13
app/views/administrateurs/procedures/close.html.haml
Normal file
|
@ -0,0 +1,13 @@
|
|||
= render partial: 'administrateurs/breadcrumbs',
|
||||
locals: { steps: [link_to('Démarches', admin_procedures_path),
|
||||
"#{@procedure.libelle}", 'archiver'],
|
||||
metadatas: ["Créée le #{@procedure.created_at.strftime('%d/%m/%Y')} - n° #{@procedure.id}", "#{@procedure.close? ? "Close le #{@procedure.closed_at.strftime('%d/%m/%Y')}" : @procedure.locked? ? "Publiée - #{procedure_lien(@procedure)}" : "Brouillon"}"] }
|
||||
|
||||
.container
|
||||
.card
|
||||
%h2.card-title
|
||||
= t('administrateurs.procedures.close.replacement_procedure_title')
|
||||
= form_tag admin_procedure_archive_path(@procedure), method: :put, class: "form" do
|
||||
- options_from_collection_for_select = current_administrateur.procedures.publiees.map { |p| ["#{p.libelle} (#{p.id})", p.id] }.to_h
|
||||
= select_tag :new_procedure, options_for_select(options_from_collection_for_select), include_blank: true
|
||||
= submit_tag t('administrateurs.procedures.close.actions.close_procedure'), { class: "button primary", id: 'publish', data: { confirm: "Voulez-vous vraiment clore la démarche ? \nLes dossiers en cours pourront être instruits, mais aucun nouveau dossier ne pourra plus être déposé.", disable_with: "Archivage..."} }
|
7
config/locales/views/administrateurs/procedures/en.yml
Normal file
7
config/locales/views/administrateurs/procedures/en.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
en:
|
||||
administrateurs:
|
||||
procedures:
|
||||
close:
|
||||
replacement_procedure_title: Is this procedure replaced by an existing one? If yes, please indicate the number of the new procedure
|
||||
actions:
|
||||
close_procedure: Close the procedure
|
7
config/locales/views/administrateurs/procedures/fr.yml
Normal file
7
config/locales/views/administrateurs/procedures/fr.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
fr:
|
||||
administrateurs:
|
||||
procedures:
|
||||
close:
|
||||
replacement_procedure_title: Cette démarche est-elle remplacée par une existante ? Si oui, veuillez indiquer le n° de la nouvelle démarche
|
||||
actions:
|
||||
close_procedure: Clore la démarche
|
|
@ -436,6 +436,7 @@ Rails.application.routes.draw do
|
|||
get 'publication' => 'procedures#publication', as: :publication
|
||||
put 'publish' => 'procedures#publish', as: :publish
|
||||
get 'transfert' => 'procedures#transfert', as: :transfert
|
||||
get 'close' => 'procedures#close', as: :close
|
||||
post 'transfer' => 'procedures#transfer', as: :transfer
|
||||
resources :mail_templates, only: [:edit, :update]
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
describe 'PUT #archive' do
|
||||
let(:procedure) { create(:procedure, :published, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
|
||||
context 'when the admin is an owner of the procedure' do
|
||||
context 'when the admin is an owner of the procedure without procedure replacement' do
|
||||
before do
|
||||
put :archive, params: { procedure_id: procedure.id }
|
||||
procedure.reload
|
||||
|
@ -362,6 +362,28 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
expect(response).to redirect_to :admin_procedures
|
||||
expect(flash[:notice]).to have_content 'Démarche close'
|
||||
end
|
||||
|
||||
it 'does not have any replacement procedure' do
|
||||
expect(procedure.replaced_by_procedure).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the admin is an owner of the procedure with procedure replacement' do
|
||||
let(:new_procedure) { create(:procedure, :published, administrateur: admin, lien_site_web: lien_site_web) }
|
||||
before do
|
||||
put :archive, params: { procedure_id: procedure.id, new_procedure: new_procedure }
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it 'archives the procedure' do
|
||||
expect(procedure.close?).to be_truthy
|
||||
expect(response).to redirect_to :admin_procedures
|
||||
expect(flash[:notice]).to have_content 'Démarche close'
|
||||
end
|
||||
|
||||
it 'does have a replacement procedure' do
|
||||
expect(procedure.replaced_by_procedure).to eq(new_procedure)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the admin is not an owner of the procedure' do
|
||||
|
|
Loading…
Reference in a new issue