2015-11-16 16:16:08 +01:00
|
|
|
class Admin::PiecesJustificativesController < AdminController
|
2015-11-20 13:54:08 +01:00
|
|
|
before_action :retrieve_procedure
|
2015-12-24 15:57:03 +01:00
|
|
|
before_action :procedure_locked?
|
2015-11-16 16:16:08 +01:00
|
|
|
|
2015-11-20 13:54:08 +01:00
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@procedure.update_attributes(update_params)
|
2015-11-20 17:12:36 +01:00
|
|
|
flash.now.notice = 'Modifications sauvegardées'
|
2015-11-20 13:54:08 +01:00
|
|
|
render 'show', format: :js
|
|
|
|
end
|
|
|
|
|
2015-11-20 15:12:47 +01:00
|
|
|
def destroy
|
|
|
|
@procedure.types_de_piece_justificative.find(params[:id]).destroy
|
|
|
|
|
|
|
|
render 'show', format: :js
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
render json: { message: 'Type de piece justificative not found' }, status: 404
|
|
|
|
end
|
|
|
|
|
2015-11-20 13:54:08 +01:00
|
|
|
def update_params
|
|
|
|
params
|
|
|
|
.require(:procedure)
|
2016-06-08 16:45:18 +02:00
|
|
|
.permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place])
|
|
|
|
end
|
|
|
|
|
|
|
|
def move_up
|
|
|
|
index = params[:index].to_i - 1
|
|
|
|
if @procedure.switch_types_de_piece_justificative index
|
|
|
|
render 'show', format: :js
|
|
|
|
else
|
|
|
|
render json: {}, status: 400
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def move_down
|
|
|
|
if @procedure.switch_types_de_piece_justificative params[:index].to_i
|
|
|
|
render 'show', format: :js
|
|
|
|
else
|
|
|
|
render json: {}, status: 400
|
|
|
|
end
|
2015-11-20 13:54:08 +01:00
|
|
|
end
|
2015-11-16 16:16:08 +01:00
|
|
|
end
|