Can change a piece_justificative_template on a type_de_champ
This commit is contained in:
parent
11f8e7a3f9
commit
1d051dc3ef
3 changed files with 28 additions and 0 deletions
|
@ -33,10 +33,27 @@ module Manager
|
|||
redirect_to manager_procedure_path(procedure)
|
||||
end
|
||||
|
||||
def change_piece_justificative_template
|
||||
if type_de_champ.update(type_de_champ_params)
|
||||
flash[:notice] = "Le modèle est mis à jour."
|
||||
else
|
||||
flash[:alert] = type_de_champ.errors.full_messages.join(', ')
|
||||
end
|
||||
redirect_to manager_procedure_path(procedure)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def procedure
|
||||
Procedure.find(params[:id])
|
||||
end
|
||||
|
||||
def type_de_champ
|
||||
TypeDeChamp.find(params[:type_de_champ][:id])
|
||||
end
|
||||
|
||||
def type_de_champ_params
|
||||
params.require(:type_de_champ).permit(:piece_justificative_template)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
%td.cell-label Libelle
|
||||
%td.cell-label Type de champ
|
||||
%td.cell-label Rempli
|
||||
%td.cell-label Modifier le modèle
|
||||
%tbody
|
||||
- field.data.order(:order_place).each do |f|
|
||||
%tr
|
||||
|
@ -20,5 +21,14 @@
|
|||
vide
|
||||
- else
|
||||
rempli
|
||||
|
||||
%td.cell-data
|
||||
- if f.type_champ == 'piece_justificative'
|
||||
= form_for f,
|
||||
url: change_piece_justificative_template_manager_procedure_path,
|
||||
method: :post do |form|
|
||||
= form.hidden_field :id
|
||||
= form.file_field :piece_justificative_template
|
||||
= form.submit 'modifier'
|
||||
- else
|
||||
Aucun
|
||||
|
|
|
@ -11,6 +11,7 @@ Rails.application.routes.draw do
|
|||
post 'draft', on: :member
|
||||
post 'hide', on: :member
|
||||
post 'add_administrateur', on: :member
|
||||
post 'change_piece_justificative_template', on: :member
|
||||
end
|
||||
|
||||
resources :dossiers, only: [:index, :show] do
|
||||
|
|
Loading…
Reference in a new issue