Merge pull request #3797 from betagouv/change_pj_in_manager

Change pj in manager
This commit is contained in:
LeSim 2019-04-18 11:20:11 +02:00 committed by GitHub
commit b83ef3cbb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 4 deletions

View file

@ -1,14 +1,12 @@
module Manager
class ProceduresController < Manager::ApplicationController
def whitelist
procedure = Procedure.find(params[:id])
procedure.whitelist!
flash[:notice] = "Démarche whitelistée."
redirect_to manager_procedure_path(procedure)
end
def draft
procedure = Procedure.find(params[:id])
if procedure.dossiers.empty?
procedure.draft!
flash[:notice] = "La démarche a bien été passée en brouillon."
@ -19,14 +17,12 @@ module Manager
end
def hide
procedure = Procedure.find(params[:id])
procedure.hide!
flash[:notice] = "La démarche a bien été supprimée, en cas d'erreur contactez un développeur."
redirect_to manager_procedures_path
end
def add_administrateur
procedure = Procedure.find(params[:id])
administrateur = Administrateur.find_by(email: params[:email])
if administrateur
procedure.administrateurs << administrateur
@ -36,5 +32,28 @@ module Manager
end
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

View file

@ -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

View file

@ -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