2016-05-20 15:36:38 +02:00
|
|
|
class Admin::AccompagnateursController < AdminController
|
2016-05-24 16:39:39 +02:00
|
|
|
include SmartListing::Helper::ControllerExtensions
|
|
|
|
helper SmartListing::Helper
|
|
|
|
|
2016-05-20 15:36:38 +02:00
|
|
|
before_action :retrieve_procedure
|
|
|
|
|
|
|
|
def show
|
2016-05-24 16:39:39 +02:00
|
|
|
assign_scope = @procedure.gestionnaires
|
2018-01-30 14:43:56 +01:00
|
|
|
|
|
|
|
# FIXME: remove this comment (no code to remove) when
|
|
|
|
# https://github.com/Sology/smart_listing/issues/134
|
|
|
|
# is fixed.
|
|
|
|
#
|
|
|
|
# No need to permit parameters for smart_listing, because
|
|
|
|
# there are no sortable columns
|
|
|
|
#
|
|
|
|
# END OF FIXME
|
|
|
|
|
2016-05-24 16:39:39 +02:00
|
|
|
@accompagnateurs_assign = smart_listing_create :accompagnateurs_assign,
|
2017-06-12 13:49:51 +02:00
|
|
|
assign_scope,
|
|
|
|
partial: "admin/accompagnateurs/list_assign",
|
|
|
|
array: true
|
2016-05-24 16:39:39 +02:00
|
|
|
|
|
|
|
not_assign_scope = current_administrateur.gestionnaires.where.not(id: assign_scope.ids)
|
2017-07-20 14:51:57 +02:00
|
|
|
not_assign_scope = not_assign_scope.where("email LIKE ?", "%#{params[:filter]}%") if params[:filter]
|
2016-05-24 16:39:39 +02:00
|
|
|
|
2018-01-30 14:43:56 +01:00
|
|
|
# FIXME: remove this comment (no code to remove) when
|
|
|
|
# https://github.com/Sology/smart_listing/issues/134
|
|
|
|
# is fixed.
|
|
|
|
#
|
|
|
|
# No need to permit parameters for smart_listing, because
|
|
|
|
# there are no sortable columns
|
|
|
|
#
|
|
|
|
# END OF FIXME
|
|
|
|
|
2016-05-24 16:39:39 +02:00
|
|
|
@accompagnateurs_not_assign = smart_listing_create :accompagnateurs_not_assign,
|
2017-06-12 13:49:51 +02:00
|
|
|
not_assign_scope,
|
|
|
|
partial: "admin/accompagnateurs/list_not_assign",
|
|
|
|
array: true
|
2016-05-20 15:36:38 +02:00
|
|
|
|
2016-05-26 16:44:10 +02:00
|
|
|
@gestionnaire ||= Gestionnaire.new
|
2016-05-20 15:36:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2016-09-08 16:21:54 +02:00
|
|
|
gestionnaire = Gestionnaire.find(params[:accompagnateur_id])
|
|
|
|
procedure = Procedure.find(params[:procedure_id])
|
|
|
|
to = params[:to]
|
|
|
|
|
2016-10-07 12:10:58 +02:00
|
|
|
accompagnateur_service = AccompagnateurService.new gestionnaire, procedure, to
|
2016-09-08 16:21:54 +02:00
|
|
|
|
2016-10-07 12:10:58 +02:00
|
|
|
accompagnateur_service.change_assignement!
|
2016-05-20 15:36:38 +02:00
|
|
|
|
2016-05-24 16:39:39 +02:00
|
|
|
flash.notice = "Assignement effectué"
|
|
|
|
redirect_to admin_procedure_accompagnateurs_path, procedure_id: params[:procedure_id]
|
2016-05-20 15:36:38 +02:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|