[Fix #197] Allow a gestionnaire to add a motivation
This commit is contained in:
parent
88267a990d
commit
b58c02180c
4 changed files with 38 additions and 4 deletions
|
@ -281,3 +281,8 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.motivation-text-area {
|
||||
color: #000000;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
|
|
@ -117,9 +117,13 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
def refuse
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
if params[:dossier] && params[:dossier][:motivation].present?
|
||||
motivation = params[:dossier][:motivation]
|
||||
end
|
||||
|
||||
dossier = @facade.dossier
|
||||
|
||||
dossier.next_step! 'gestionnaire', 'refuse'
|
||||
dossier.next_step! 'gestionnaire', 'refuse', motivation
|
||||
flash.notice = 'Dossier considéré comme refusé.'
|
||||
|
||||
NotificationMailer.send_notification(dossier, dossier.procedure.refused_mail_template).deliver_now!
|
||||
|
@ -130,9 +134,13 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
def without_continuation
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
if params[:dossier] && params[:dossier][:motivation].present?
|
||||
motivation = params[:dossier][:motivation]
|
||||
end
|
||||
|
||||
dossier = @facade.dossier
|
||||
|
||||
dossier.next_step! 'gestionnaire', 'without_continuation'
|
||||
dossier.next_step! 'gestionnaire', 'without_continuation', motivation
|
||||
flash.notice = 'Dossier considéré comme sans suite.'
|
||||
|
||||
NotificationMailer.send_notification(dossier, dossier.procedure.without_continuation_mail_template).deliver_now!
|
||||
|
@ -143,9 +151,13 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
|||
def close
|
||||
create_dossier_facade params[:dossier_id]
|
||||
|
||||
if params[:dossier] && params[:dossier][:motivation].present?
|
||||
motivation = params[:dossier][:motivation]
|
||||
end
|
||||
|
||||
dossier = @facade.dossier
|
||||
|
||||
dossier.next_step! 'gestionnaire', 'close'
|
||||
dossier.next_step! 'gestionnaire', 'close', motivation
|
||||
flash.notice = 'Dossier traité avec succès.'
|
||||
|
||||
NotificationMailer.send_notification(dossier, dossier.procedure.closed_mail_template).deliver_now!
|
||||
|
|
|
@ -130,7 +130,7 @@ class Dossier < ActiveRecord::Base
|
|||
commentaires.order(created_at: :desc)
|
||||
end
|
||||
|
||||
def next_step! role, action
|
||||
def next_step! role, action, motivation = nil
|
||||
unless %w(initiate follow update comment receive refuse without_continuation close).include?(action)
|
||||
fail 'action is not valid'
|
||||
end
|
||||
|
@ -170,14 +170,29 @@ class Dossier < ActiveRecord::Base
|
|||
when 'close'
|
||||
if received?
|
||||
closed!
|
||||
|
||||
if motivation
|
||||
self.motivation = motivation
|
||||
save
|
||||
end
|
||||
end
|
||||
when 'refuse'
|
||||
if received?
|
||||
refused!
|
||||
|
||||
if motivation
|
||||
self.motivation = motivation
|
||||
save
|
||||
end
|
||||
end
|
||||
when 'without_continuation'
|
||||
if received?
|
||||
without_continuation!
|
||||
|
||||
if motivation
|
||||
self.motivation = motivation
|
||||
save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
- elsif @facade.dossier.received?
|
||||
= form_tag(backoffice_dossier_process_dossier_url(@facade.dossier.id), method: :post) do
|
||||
= text_area :dossier, :motivation, class: "motivation-text-area", placeholder: "Motivation (facultative)"
|
||||
|
||||
%ul.list-inline
|
||||
%li
|
||||
= button_tag name: :process_action, value: "close", class: 'btn btn-success', title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do
|
||||
|
|
Loading…
Reference in a new issue