Procedure: add new preview view
This commit is contained in:
parent
1da69a7730
commit
366ef2d2b5
8 changed files with 82 additions and 16 deletions
|
@ -0,0 +1,7 @@
|
||||||
|
module NewAdministrateur
|
||||||
|
class AdministrateurController < ApplicationController
|
||||||
|
layout 'new_application'
|
||||||
|
|
||||||
|
before_action :authenticate_administrateur!
|
||||||
|
end
|
||||||
|
end
|
13
app/controllers/new_administrateur/procedures_controller.rb
Normal file
13
app/controllers/new_administrateur/procedures_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module NewAdministrateur
|
||||||
|
class ProceduresController < AdministrateurController
|
||||||
|
def apercu
|
||||||
|
@dossier = procedure_without_control.new_dossier
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def procedure_without_control
|
||||||
|
Procedure.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
6
app/views/new_administrateur/procedures/apercu.html.haml
Normal file
6
app/views/new_administrateur/procedures/apercu.html.haml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.dossier-edit
|
||||||
|
.dossier-header
|
||||||
|
.container
|
||||||
|
%h1 Prévisualisation de la procédure #{@dossier.procedure.libelle}
|
||||||
|
|
||||||
|
= render partial: "shared/dossiers/edit", locals: { dossier: @dossier, apercu: true }
|
|
@ -3,4 +3,4 @@
|
||||||
.container
|
.container
|
||||||
%h1= @dossier.procedure.libelle
|
%h1= @dossier.procedure.libelle
|
||||||
|
|
||||||
= render partial: "shared/dossiers/edit", locals: { dossier: @dossier }
|
= render partial: "shared/dossiers/edit", locals: { dossier: @dossier, apercu: false }
|
||||||
|
|
|
@ -6,7 +6,12 @@
|
||||||
|
|
||||||
%p.thanks Les champs avec une asterisque (*) sont obligatoires.
|
%p.thanks Les champs avec une asterisque (*) sont obligatoires.
|
||||||
|
|
||||||
= form_for dossier, html: { class: 'form', multipart: true } do |f|
|
- if apercu
|
||||||
|
- form_options = { url: '', method: :get, html: { class: 'form', multipart: true } }
|
||||||
|
- else
|
||||||
|
- form_options = { html: { class: 'form', multipart: true } }
|
||||||
|
|
||||||
|
= form_for dossier, form_options do |f|
|
||||||
= f.fields_for :champs, dossier.champs do |champ_form|
|
= f.fields_for :champs, dossier.champs do |champ_form|
|
||||||
- champ = champ_form.object
|
- champ = champ_form.object
|
||||||
= render partial: "shared/dossiers/editable_champs/editable_champ",
|
= render partial: "shared/dossiers/editable_champs/editable_champ",
|
||||||
|
@ -43,21 +48,22 @@
|
||||||
max_file_size: 6.megabytes,
|
max_file_size: 6.megabytes,
|
||||||
required: (tpj.mandatory? && !dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id))
|
required: (tpj.mandatory? && !dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id))
|
||||||
|
|
||||||
.send-wrapper
|
- if !apercu
|
||||||
= hidden_field_tag 'submit_action', 'draft'
|
.send-wrapper
|
||||||
|
= hidden_field_tag 'submit_action', 'draft'
|
||||||
|
|
||||||
- if dossier.brouillon?
|
- if dossier.brouillon?
|
||||||
= f.button 'Enregistrer le brouillon',
|
= f.button 'Enregistrer le brouillon',
|
||||||
formnovalidate: true,
|
formnovalidate: true,
|
||||||
class: 'button send',
|
class: 'button send',
|
||||||
data: { action: 'draft', disable_with: 'Envoi...' }
|
data: { action: 'draft', disable_with: 'Envoi...' }
|
||||||
|
|
||||||
- if dossier.user == current_user
|
- if dossier.user == current_user
|
||||||
= f.button 'Soumettre le dossier',
|
= f.button 'Soumettre le dossier',
|
||||||
|
class: 'button send primary',
|
||||||
|
data: { action: 'submit', disable_with: 'Envoi...' }
|
||||||
|
|
||||||
|
- else
|
||||||
|
= f.button 'Modifier le dossier',
|
||||||
class: 'button send primary',
|
class: 'button send primary',
|
||||||
data: { action: 'submit', disable_with: 'Envoi...' }
|
data: { action: 'submit', disable_with: 'Envoi...' }
|
||||||
|
|
||||||
- else
|
|
||||||
= f.button 'Modifier le dossier',
|
|
||||||
class: 'button send primary',
|
|
||||||
data: { action: 'submit', disable_with: 'Envoi...' }
|
|
||||||
|
|
|
@ -274,6 +274,14 @@ Rails.application.routes.draw do
|
||||||
get "recherche" => "recherche#index"
|
get "recherche" => "recherche#index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scope module: 'new_administrateur' do
|
||||||
|
resources :procedures, only: [] do
|
||||||
|
member do
|
||||||
|
get 'apercu'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
apipie
|
apipie
|
||||||
|
|
||||||
# Legacy routes
|
# Legacy routes
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
describe NewAdministrateur::AdministrateurController, type: :controller do
|
||||||
|
describe 'before actions: authenticate_administrateur!' do
|
||||||
|
it 'is present' do
|
||||||
|
before_actions = NewAdministrateur::AdministrateurController
|
||||||
|
._process_action_callbacks
|
||||||
|
.find_all{ |process_action_callbacks| process_action_callbacks.kind == :before }
|
||||||
|
.map(&:filter)
|
||||||
|
|
||||||
|
expect(before_actions).to include(:authenticate_administrateur!)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
describe NewAdministrateur::ProceduresController, type: :controller do
|
||||||
|
let(:admin) { create(:administrateur) }
|
||||||
|
|
||||||
|
describe '#apercu' do
|
||||||
|
let(:procedure) { create(:procedure) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in admin
|
||||||
|
get :apercu, params: { id: procedure.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response).to have_http_status(:ok) }
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue