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
|
2018-03-02 16:27:03 +01:00
|
|
|
if @procedure.update(update_params)
|
2017-01-31 15:13:06 +01:00
|
|
|
flash.now.notice = 'Modifications sauvegardées'
|
|
|
|
else
|
|
|
|
flash.now.notice = 'Une erreur est survenue'
|
|
|
|
end
|
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)
|
2017-03-29 14:38:54 +02:00
|
|
|
.permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place, :mandatory, :lien_demarche])
|
2016-06-08 16:45:18 +02:00
|
|
|
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
|
2017-01-18 17:13:54 +01:00
|
|
|
end
|