2023-03-24 10:27:32 +01:00
|
|
|
module Administrateurs
|
|
|
|
class RoutingController < AdministrateurController
|
|
|
|
include Logic
|
|
|
|
|
|
|
|
before_action :retrieve_procedure
|
|
|
|
|
|
|
|
def update
|
|
|
|
left = champ_value(targeted_champ)
|
2023-03-27 15:14:01 +02:00
|
|
|
right = parsed_value
|
2023-03-24 10:27:32 +01:00
|
|
|
|
|
|
|
@procedure.groupe_instructeurs.find(groupe_instructeur_id).update!(routing_rule: ds_eq(left, right))
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def targeted_champ
|
|
|
|
routing_params[:targeted_champ].to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
|
|
|
routing_params[:value]
|
|
|
|
end
|
|
|
|
|
2023-03-27 15:14:01 +02:00
|
|
|
def parsed_value
|
|
|
|
term = Logic.from_json(value) rescue nil
|
|
|
|
|
|
|
|
term.presence || constant(value)
|
|
|
|
end
|
|
|
|
|
2023-03-24 10:27:32 +01:00
|
|
|
def groupe_instructeur_id
|
|
|
|
routing_params[:groupe_instructeur_id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def routing_params
|
|
|
|
params.permit(:targeted_champ, :value, :groupe_instructeur_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|