Procedure: add new preview view

This commit is contained in:
simon lehericey 2018-04-13 16:56:00 +02:00
parent 1da69a7730
commit 366ef2d2b5
8 changed files with 82 additions and 16 deletions

View file

@ -0,0 +1,7 @@
module NewAdministrateur
class AdministrateurController < ApplicationController
layout 'new_application'
before_action :authenticate_administrateur!
end
end

View 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

View 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 }

View file

@ -3,4 +3,4 @@
.container
%h1= @dossier.procedure.libelle
= render partial: "shared/dossiers/edit", locals: { dossier: @dossier }
= render partial: "shared/dossiers/edit", locals: { dossier: @dossier, apercu: false }

View file

@ -6,7 +6,12 @@
%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|
- champ = champ_form.object
= render partial: "shared/dossiers/editable_champs/editable_champ",
@ -43,21 +48,22 @@
max_file_size: 6.megabytes,
required: (tpj.mandatory? && !dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id))
.send-wrapper
= hidden_field_tag 'submit_action', 'draft'
- if !apercu
.send-wrapper
= hidden_field_tag 'submit_action', 'draft'
- if dossier.brouillon?
= f.button 'Enregistrer le brouillon',
formnovalidate: true,
class: 'button send',
data: { action: 'draft', disable_with: 'Envoi...' }
- if dossier.brouillon?
= f.button 'Enregistrer le brouillon',
formnovalidate: true,
class: 'button send',
data: { action: 'draft', disable_with: 'Envoi...' }
- if dossier.user == current_user
= f.button 'Soumettre le dossier',
- if dossier.user == current_user
= 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',
data: { action: 'submit', disable_with: 'Envoi...' }
- else
= f.button 'Modifier le dossier',
class: 'button send primary',
data: { action: 'submit', disable_with: 'Envoi...' }

View file

@ -274,6 +274,14 @@ Rails.application.routes.draw do
get "recherche" => "recherche#index"
end
scope module: 'new_administrateur' do
resources :procedures, only: [] do
member do
get 'apercu'
end
end
end
apipie
# Legacy routes

View file

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

View file

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