Handle "réactiver" feature with permanent procedure url
This commit is contained in:
parent
e5002dbb11
commit
92a5100a09
4 changed files with 23 additions and 17 deletions
|
@ -73,7 +73,7 @@ class Procedure < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def publish(path)
|
||||
self.update_attributes!({ published: true })
|
||||
self.update_attributes!({ published: true, archived: false })
|
||||
ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,12 +6,16 @@
|
|||
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
|
||||
%span{"aria-hidden" => "true"} ×
|
||||
%h4#myModalLabel.modal-title
|
||||
Publier la procédure
|
||||
=@procedure.archived?? 'Réactiver' : 'Publier'
|
||||
la procédure
|
||||
%span#publishModal_title
|
||||
.modal-body
|
||||
Vous vous apprêtez à publier votre procédure au public.
|
||||
%b
|
||||
Elle ne pourra plus être modifiée à l'issue de cette publication.
|
||||
Vous vous apprêtez à
|
||||
=@procedure.archived?? 'republier' : 'publier'
|
||||
votre procédure au public.
|
||||
- unless @procedure.archived?
|
||||
%b
|
||||
Elle ne pourra plus être modifiée à l'issue de cette publication.
|
||||
%br
|
||||
Afin de faciliter l'accès à la procédure, vous êtes invité à personnaliser l'adresse d'accès si vous le souhaitez.
|
||||
%br
|
||||
|
@ -39,7 +43,7 @@
|
|||
Ce lien n'est pas valide. Seuls les caractères a-z, 0-9 et '_' sont autorisés.
|
||||
.modal-footer
|
||||
= submit_tag 'Annuler', class: %w(btn btn btn-default), id: 'cancel', data: { dismiss: 'modal' }
|
||||
= submit_tag 'Publier', class: %w(btn btn btn-success),
|
||||
= submit_tag "#{@procedure.archived?? 'Réactiver' : 'Publier'}", class: %w(btn btn btn-success),
|
||||
id: 'publish',
|
||||
data: { disable_with: 'Publication en cours', submit: true},
|
||||
disabled: :disabled
|
||||
|
|
|
@ -8,14 +8,17 @@
|
|||
%br
|
||||
=render partial: '/admin/procedures/modal_publish'
|
||||
|
||||
-if @facade.procedure.archived?
|
||||
%a.btn.btn-small.btn-default.text-info{"data-target" => "#publishModal", "data-toggle" => "modal", :type => "button", style:'float: right; margin-top: 10px'}
|
||||
%i.fa.fa-eraser
|
||||
Réactiver
|
||||
%br
|
||||
=render partial: '/admin/procedures/modal_publish'
|
||||
-else
|
||||
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put, style:'float: right; margin-top: 10px' do
|
||||
%button#archive.btn.btn-small.btn-default.text-info{type: :button}
|
||||
%i.fa.fa-eraser
|
||||
- if @facade.procedure.archived
|
||||
= 'Réactiver'
|
||||
- else
|
||||
= 'Archiver'
|
||||
= 'Archiver'
|
||||
#confirm
|
||||
%button#valid.btn.btn-small.btn-success{type: :submit}
|
||||
%i.fa.fa-check
|
||||
|
|
|
@ -355,26 +355,25 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
context 'when admin is the owner of the procedure' do
|
||||
before do
|
||||
put :archive, procedure_id: procedure.id, archive: archive
|
||||
put :archive, procedure_id: procedure.id
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
context 'when owner want archive procedure' do
|
||||
|
||||
let(:archive) { true }
|
||||
|
||||
it { expect(procedure.archived).to be_truthy }
|
||||
it { expect(response).to redirect_to :admin_procedures }
|
||||
it { expect(flash[:notice]).to have_content 'Procédure archivée' }
|
||||
end
|
||||
|
||||
context 'when owner want reactive procedure' do
|
||||
|
||||
let(:archive) { false }
|
||||
before do
|
||||
put :publish, procedure_id: procedure.id, procedure_path: 'fake_path'
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.archived).to be_falsey }
|
||||
it { expect(response).to redirect_to :admin_procedures }
|
||||
it { expect(flash[:notice]).to have_content 'Procédure éditée' }
|
||||
it { expect(flash[:notice]).to have_content 'Procédure publiée' }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue