[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
|
def refuse
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
|
if params[:dossier] && params[:dossier][:motivation].present?
|
||||||
|
motivation = params[:dossier][:motivation]
|
||||||
|
end
|
||||||
|
|
||||||
dossier = @facade.dossier
|
dossier = @facade.dossier
|
||||||
|
|
||||||
dossier.next_step! 'gestionnaire', 'refuse'
|
dossier.next_step! 'gestionnaire', 'refuse', motivation
|
||||||
flash.notice = 'Dossier considéré comme refusé.'
|
flash.notice = 'Dossier considéré comme refusé.'
|
||||||
|
|
||||||
NotificationMailer.send_notification(dossier, dossier.procedure.refused_mail_template).deliver_now!
|
NotificationMailer.send_notification(dossier, dossier.procedure.refused_mail_template).deliver_now!
|
||||||
|
@ -130,9 +134,13 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
def without_continuation
|
def without_continuation
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
|
if params[:dossier] && params[:dossier][:motivation].present?
|
||||||
|
motivation = params[:dossier][:motivation]
|
||||||
|
end
|
||||||
|
|
||||||
dossier = @facade.dossier
|
dossier = @facade.dossier
|
||||||
|
|
||||||
dossier.next_step! 'gestionnaire', 'without_continuation'
|
dossier.next_step! 'gestionnaire', 'without_continuation', motivation
|
||||||
flash.notice = 'Dossier considéré comme sans suite.'
|
flash.notice = 'Dossier considéré comme sans suite.'
|
||||||
|
|
||||||
NotificationMailer.send_notification(dossier, dossier.procedure.without_continuation_mail_template).deliver_now!
|
NotificationMailer.send_notification(dossier, dossier.procedure.without_continuation_mail_template).deliver_now!
|
||||||
|
@ -143,9 +151,13 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
def close
|
def close
|
||||||
create_dossier_facade params[:dossier_id]
|
create_dossier_facade params[:dossier_id]
|
||||||
|
|
||||||
|
if params[:dossier] && params[:dossier][:motivation].present?
|
||||||
|
motivation = params[:dossier][:motivation]
|
||||||
|
end
|
||||||
|
|
||||||
dossier = @facade.dossier
|
dossier = @facade.dossier
|
||||||
|
|
||||||
dossier.next_step! 'gestionnaire', 'close'
|
dossier.next_step! 'gestionnaire', 'close', motivation
|
||||||
flash.notice = 'Dossier traité avec succès.'
|
flash.notice = 'Dossier traité avec succès.'
|
||||||
|
|
||||||
NotificationMailer.send_notification(dossier, dossier.procedure.closed_mail_template).deliver_now!
|
NotificationMailer.send_notification(dossier, dossier.procedure.closed_mail_template).deliver_now!
|
||||||
|
|
|
@ -130,7 +130,7 @@ class Dossier < ActiveRecord::Base
|
||||||
commentaires.order(created_at: :desc)
|
commentaires.order(created_at: :desc)
|
||||||
end
|
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)
|
unless %w(initiate follow update comment receive refuse without_continuation close).include?(action)
|
||||||
fail 'action is not valid'
|
fail 'action is not valid'
|
||||||
end
|
end
|
||||||
|
@ -170,14 +170,29 @@ class Dossier < ActiveRecord::Base
|
||||||
when 'close'
|
when 'close'
|
||||||
if received?
|
if received?
|
||||||
closed!
|
closed!
|
||||||
|
|
||||||
|
if motivation
|
||||||
|
self.motivation = motivation
|
||||||
|
save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when 'refuse'
|
when 'refuse'
|
||||||
if received?
|
if received?
|
||||||
refused!
|
refused!
|
||||||
|
|
||||||
|
if motivation
|
||||||
|
self.motivation = motivation
|
||||||
|
save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when 'without_continuation'
|
when 'without_continuation'
|
||||||
if received?
|
if received?
|
||||||
without_continuation!
|
without_continuation!
|
||||||
|
|
||||||
|
if motivation
|
||||||
|
self.motivation = motivation
|
||||||
|
save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
- elsif @facade.dossier.received?
|
- elsif @facade.dossier.received?
|
||||||
= form_tag(backoffice_dossier_process_dossier_url(@facade.dossier.id), method: :post) do
|
= 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
|
%ul.list-inline
|
||||||
%li
|
%li
|
||||||
= button_tag name: :process_action, value: "close", class: 'btn btn-success', title: 'Accepter', data: { toggle: :tooltip, confirm: "Accepter ce dossier ?" } do
|
= 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