Add previsualization formulaire page for administrateur
This commit is contained in:
parent
d26feb4c72
commit
e6b5698008
11 changed files with 284 additions and 64 deletions
13
app/controllers/admin/previsualisations_controller.rb
Normal file
13
app/controllers/admin/previsualisations_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class Admin::PrevisualisationsController < AdminController
|
||||
before_action :retrieve_procedure
|
||||
|
||||
def show
|
||||
@procedure
|
||||
@dossier = Dossier.new(id: 0, procedure: @procedure)
|
||||
|
||||
Champ.where(dossier_id: @dossier.id).destroy_all
|
||||
@dossier.build_default_champs
|
||||
|
||||
@champs = @dossier.ordered_champs
|
||||
end
|
||||
end
|
9
app/views/admin/previsualisations/show.html.haml
Normal file
9
app/views/admin/previsualisations/show.html.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
%h2.text-info
|
||||
=@procedure.libelle
|
||||
%br
|
||||
|
||||
%ul.nav.nav-tabs
|
||||
= render partial: 'admin/procedures/navbar', locals: {active: 'Prévisualisation'}
|
||||
|
||||
#previsualisation
|
||||
=render 'users/description/show'
|
|
@ -14,4 +14,7 @@
|
|||
|
||||
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Pieces') }
|
||||
= link_to_unless(@procedure.locked?, 'Pièces justificatives', admin_procedure_pieces_justificatives_path(@procedure)) do
|
||||
= link_to('Pièces justificatives', '#')
|
||||
= link_to('Pièces justificatives', '#')
|
||||
|
||||
%li{ class: ('active' if active == 'Prévisualisation'), style: 'float:right' }
|
||||
= link_to('Prévisualisation', admin_procedure_previsualisation_path(@procedure), {style: 'font-style: italic;'})
|
|
@ -4,3 +4,6 @@
|
|||
= form_for @procedure, url: {controller: 'admin/procedures', action: :create}, multipart: true do |f|
|
||||
=render partial: 'informations', locals: {f: f}
|
||||
=f.submit 'Valider', class: 'btn btn-info', style: 'float:right'
|
||||
%br
|
||||
%br
|
||||
%br
|
|
@ -6,21 +6,20 @@
|
|||
%ul.nav.nav-tabs
|
||||
= render partial: 'navbar', locals: {active: 'Informations'}
|
||||
|
||||
%li{style:'float:right'}
|
||||
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put do
|
||||
%button#archive.btn.btn-nav.text-info{type: :button}
|
||||
%i.fa.fa-eraser
|
||||
- if @facade.procedure.archived
|
||||
= 'Réactiver'
|
||||
- else
|
||||
= 'Archiver'
|
||||
#confirm
|
||||
%button#valid.btn.btn-nav.text-success{type: :submit}
|
||||
%i.fa.fa-check
|
||||
Valider
|
||||
%button#cancel.btn.btn-nav.text-danger{type: :button}
|
||||
%i.fa.fa-remove
|
||||
Annuler
|
||||
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put, style:'float: right; margin-top: 10px' do
|
||||
%button#archive.btn.btn-small.btn-default.text-info{type: :button}
|
||||
%i.fa.fa-eraser
|
||||
- if @facade.procedure.archived
|
||||
= 'Réactiver'
|
||||
- else
|
||||
= 'Archiver'
|
||||
#confirm
|
||||
%button#valid.btn.btn-small.btn-success{type: :submit}
|
||||
%i.fa.fa-check
|
||||
Valider
|
||||
%button#cancel.btn.btn-small.btn-danger{type: :button}
|
||||
%i.fa.fa-remove
|
||||
Annuler
|
||||
|
||||
- if @facade.procedure.locked?
|
||||
#procedure_locked.center
|
||||
|
|
50
app/views/users/description/_show.html.haml
Normal file
50
app/views/users/description/_show.html.haml
Normal file
|
@ -0,0 +1,50 @@
|
|||
.container#description_page
|
||||
%h2
|
||||
= @dossier.procedure.libelle
|
||||
%h3 Votre dossier
|
||||
|
||||
%br
|
||||
|
||||
-#TODO use form_for
|
||||
= form_tag(url_for({controller: 'users/description', action: :create, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST', multipart: true) do
|
||||
%div
|
||||
.row
|
||||
.col-md-12
|
||||
%h4 Libellé pour votre dossier *
|
||||
= text_field_tag :nom_projet, @dossier.nom_projet, placeholder: 'Nom du projet', class: 'form-control'
|
||||
%br
|
||||
.row
|
||||
.col-md-12
|
||||
%h4 Description *
|
||||
= text_area_tag :description, @dossier.description, rows: '6', placeholder: 'Description du projet', class: 'form-control wysihtml5'
|
||||
|
||||
#liste_champs
|
||||
-unless @champs.nil?
|
||||
=render partial: 'users/description/champs'
|
||||
|
||||
-if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
|
||||
%br
|
||||
%h3 Documents administratifs
|
||||
|
||||
-unless @procedure.lien_demarche.blank?
|
||||
%p
|
||||
Formulaire / documentation de la démarche :
|
||||
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Accéder
|
||||
|
||||
|
||||
%br
|
||||
//TODO a refactorer
|
||||
= render partial: 'users/description/pieces_justificatives'
|
||||
|
||||
- if user_signed_in?
|
||||
|
||||
%div{style: 'text-align:right'}
|
||||
%h6 Tous les champs portant un * sont obligatoires.
|
||||
|
||||
-if !@dossier.draft?
|
||||
=render partial: '/layouts/modifications_terminees'
|
||||
-else
|
||||
= submit_tag 'Soumettre mon dossier', id: 'suivant', class: %w(btn btn btn-success), style: 'float:right', data: { disable_with: 'Soumettre votre dossier', submit: true}
|
||||
|
||||
%br
|
||||
%br
|
|
@ -1,48 +1 @@
|
|||
.container#description_page
|
||||
%h2
|
||||
= @dossier.procedure.libelle
|
||||
%h3 Votre dossier
|
||||
|
||||
%br
|
||||
|
||||
-#TODO use form_for
|
||||
= form_tag(url_for({controller: :description, action: :create, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST', multipart: true) do
|
||||
%div
|
||||
.row
|
||||
.col-md-12
|
||||
%h4 Libellé pour votre dossier *
|
||||
= text_field_tag :nom_projet, @dossier.nom_projet, placeholder: 'Nom du projet', class: 'form-control'
|
||||
%br
|
||||
.row
|
||||
.col-md-12
|
||||
%h4 Description *
|
||||
= text_area_tag :description, @dossier.description, rows: '6', placeholder: 'Description du projet', class: 'form-control wysihtml5'
|
||||
|
||||
#liste_champs
|
||||
-unless @champs.nil?
|
||||
=render partial: 'champs'
|
||||
|
||||
-if !@procedure.lien_demarche.blank? || @procedure.cerfa_flag || @dossier.pieces_justificatives.size > 1
|
||||
%br
|
||||
%h3 Documents administratifs
|
||||
|
||||
-unless @procedure.lien_demarche.blank?
|
||||
%p
|
||||
Formulaire / documentation de la démarche :
|
||||
%a{style:'font-size:0.9em; padding-left:3px', id: 'lien_cerfa' ,href: "#{@procedure.lien_demarche}", :target => '_blank'} Accéder
|
||||
|
||||
|
||||
%br
|
||||
//TODO a refactorer
|
||||
= render partial: 'pieces_justificatives'
|
||||
|
||||
%div{style: 'text-align:right'}
|
||||
%h6 Tous les champs portant un * sont obligatoires.
|
||||
|
||||
-if !@dossier.draft?
|
||||
=render partial: '/layouts/modifications_terminees'
|
||||
-else
|
||||
= submit_tag 'Soumettre mon dossier', id: 'suivant', class: %w(btn btn btn-success), style: 'float:right', data: { disable_with: 'Soumettre votre dossier', submit: true}
|
||||
|
||||
%br
|
||||
%br
|
||||
= render partial: 'show'
|
|
@ -94,6 +94,7 @@ Rails.application.routes.draw do
|
|||
|
||||
resource :accompagnateurs, only: [:show, :update]
|
||||
|
||||
resource :previsualisation, only: [:show]
|
||||
|
||||
resources :types_de_champ, only: [:destroy]
|
||||
resource :pieces_justificatives, only: [:show, :update]
|
||||
|
|
16
spec/controllers/admin/previsualisations_controller_spec.rb
Normal file
16
spec/controllers/admin/previsualisations_controller_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::PrevisualisationsController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:procedure) { create :procedure, administrateur: admin }
|
||||
|
||||
before do
|
||||
sign_in admin
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
subject { get :show, procedure_id: procedure.id }
|
||||
it { expect(subject.status).to eq(200) }
|
||||
end
|
||||
|
||||
end
|
172
spec/views/admin/previsualisations/show.html.haml_spec.rb
Normal file
172
spec/views/admin/previsualisations/show.html.haml_spec.rb
Normal file
|
@ -0,0 +1,172 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/previsualisations/show.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
let(:cerfa_flag) { true }
|
||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: cerfa_flag) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, user: user) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
assign(:dossier, dossier)
|
||||
assign(:procedure, dossier.procedure)
|
||||
assign(:champs, dossier.ordered_champs)
|
||||
end
|
||||
|
||||
context 'tous les attributs sont présents sur la page' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do
|
||||
expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]")
|
||||
end
|
||||
|
||||
it 'Nom du projet' do
|
||||
expect(rendered).to have_selector('input[id=nom_projet][name=nom_projet]')
|
||||
end
|
||||
|
||||
it 'Description du projet' do
|
||||
expect(rendered).to have_selector('textarea[id=description][name=description]')
|
||||
end
|
||||
|
||||
it 'Charger votre CERFA (PDF)' do
|
||||
expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]')
|
||||
end
|
||||
|
||||
it 'Lien CERFA' do
|
||||
expect(rendered).to have_selector('#lien_cerfa')
|
||||
end
|
||||
end
|
||||
|
||||
context 'si la page précédente n\'est pas recapitulatif' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
it 'le bouton "Terminer" n\'est pas présent' do
|
||||
expect(rendered).not_to have_selector('#suivant')
|
||||
end
|
||||
end
|
||||
|
||||
context 'si la page précédente est recapitularif' do
|
||||
before do
|
||||
dossier.initiated!
|
||||
dossier.reload
|
||||
render
|
||||
end
|
||||
|
||||
it 'le bouton "Terminer" n\'est pas présent' do
|
||||
expect(rendered).to_not have_selector('#suivant')
|
||||
end
|
||||
|
||||
it 'le bouton "Modification terminé" n\'est pas présent' do
|
||||
expect(rendered).not_to have_selector('#modification_terminee')
|
||||
end
|
||||
|
||||
it 'le lien de retour au récapitulatif n\'est pas présent' do
|
||||
expect(rendered).not_to have_selector("a[href='/users/dossiers/#{dossier_id}/recapitulatif']")
|
||||
end
|
||||
end
|
||||
|
||||
context 'les valeurs sont réaffichées si elles sont présentes dans la BDD' do
|
||||
let!(:dossier) do
|
||||
create(:dossier,
|
||||
nom_projet: 'Projet de test',
|
||||
description: 'Description de test',
|
||||
user: user)
|
||||
end
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it 'Nom du projet' do
|
||||
expect(rendered).to have_selector("input[id=nom_projet][value='#{dossier.nom_projet}']")
|
||||
end
|
||||
|
||||
it 'Description du projet' do
|
||||
expect(rendered).to have_content("#{dossier.description}")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Champs' do
|
||||
let(:champs) { dossier.champs }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
describe 'first champs' do
|
||||
subject { dossier.champs.first }
|
||||
it { expect(rendered).to have_css(".type_champ-#{subject.type_champ}") }
|
||||
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||
end
|
||||
|
||||
describe 'last champs' do
|
||||
subject { dossier.champs.last }
|
||||
it { expect(rendered).to have_css(".type_champ-#{subject.type_champ}") }
|
||||
it { expect(rendered).to have_css("#champs_#{subject.id}") }
|
||||
end
|
||||
end
|
||||
|
||||
context 'Pièces justificatives' do
|
||||
let(:all_type_pj_procedure_id) { dossier.procedure.type_de_piece_justificative_ids }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
context 'la liste des pièces justificatives a envoyé est affichée' do
|
||||
it 'RIB' do
|
||||
expect(rendered).to have_css("#piece_justificative_#{all_type_pj_procedure_id[0]}")
|
||||
end
|
||||
end
|
||||
|
||||
context 'la liste des pièces récupérées automatiquement est signaliée' do
|
||||
it 'Attestation MSA' do
|
||||
expect(rendered).to have_selector("#piece_justificative_#{all_type_pj_procedure_id[1]}", "Nous l'avons récupéré pour vous.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'Envoi des CERFA désactivé' do
|
||||
let!(:cerfa_flag) { false }
|
||||
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to_not have_css("#cerfa_flag") }
|
||||
it { expect(rendered).to_not have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') }
|
||||
end
|
||||
|
||||
describe 'display title Documents administratifs' do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
let(:procedure) { create :procedure, lien_demarche: '' }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
context 'when dossier not have cerfa, piece justificative and demarche link' do
|
||||
it { expect(rendered).not_to have_content 'Documents administratifs' }
|
||||
end
|
||||
|
||||
context 'when dossier have pj' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
||||
it { expect(rendered).to have_content 'Documents administratifs' }
|
||||
end
|
||||
|
||||
context 'when procedure have demarche link' do
|
||||
let(:procedure) { create :procedure }
|
||||
|
||||
it { expect(rendered).to have_content 'Documents administratifs' }
|
||||
end
|
||||
|
||||
context 'when procedure have cerfa flag true' do
|
||||
let(:procedure) {create(:procedure, cerfa_flag: true)}
|
||||
|
||||
it { expect(rendered).to have_content 'Documents administratifs' }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,6 +8,7 @@ describe 'users/description/show.html.haml', type: :view do
|
|||
let(:dossier_id) { dossier.id }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
assign(:dossier, dossier)
|
||||
assign(:procedure, dossier.procedure)
|
||||
assign(:champs, dossier.ordered_champs)
|
||||
|
|
Loading…
Reference in a new issue