Merge branch 'develop' into staging
This commit is contained in:
commit
dbbb2ef6aa
28 changed files with 437 additions and 135 deletions
37
app/assets/javascripts/description.js
Normal file
37
app/assets/javascripts/description.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
$(document).on('page:load', action_type_de_champs);
|
||||||
|
$(document).ready(action_type_de_champs);
|
||||||
|
|
||||||
|
|
||||||
|
function action_type_de_champs() {
|
||||||
|
$("input[type='email']").on('change', function () {
|
||||||
|
toggleErrorClass(this, validateEmail($(this).val()));
|
||||||
|
});
|
||||||
|
|
||||||
|
$("input[type='phone']").on('change', function () {
|
||||||
|
val = $(this).val();
|
||||||
|
val = val.replace(/[ ]/g, '');
|
||||||
|
|
||||||
|
toggleErrorClass(this, validatePhone(val));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleErrorClass(node, boolean) {
|
||||||
|
if (boolean)
|
||||||
|
$(node).removeClass('input-error');
|
||||||
|
else
|
||||||
|
$(node).addClass('input-error');
|
||||||
|
}
|
||||||
|
|
||||||
|
function validatePhone(phone) {
|
||||||
|
var re = /^(0|(\+[1-9]{2})|(00[1-9]{2}))[1-9][0-9]{8}$/;
|
||||||
|
return validateInput(phone, re)
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateEmail(email) {
|
||||||
|
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
|
return validateInput(email, re)
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateInput(input, regex) {
|
||||||
|
return regex.test(input);
|
||||||
|
}
|
|
@ -7,6 +7,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-error {
|
||||||
|
color: darkred !important;
|
||||||
|
border-color: darkred !important
|
||||||
|
}
|
||||||
|
|
||||||
.type_champ-text {
|
.type_champ-text {
|
||||||
@extend .col-md-6;
|
@extend .col-md-6;
|
||||||
@extend .col-lg-6;
|
@extend .col-lg-6;
|
||||||
|
@ -16,6 +21,34 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.type_champ-email {
|
||||||
|
@extend .col-md-4;
|
||||||
|
@extend .col-lg-4;
|
||||||
|
|
||||||
|
input[type='email'] {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.type_champ-civilite {
|
||||||
|
@extend .col-md-3;
|
||||||
|
@extend .col-lg-3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type_champ-phone {
|
||||||
|
@extend .col-md-2;
|
||||||
|
@extend .col-lg-2;
|
||||||
|
|
||||||
|
input[type='phone'] {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.datepicker-switch {
|
||||||
|
color: #0086b3;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
.type_champ-textarea {
|
.type_champ-textarea {
|
||||||
@extend .col-md-8;
|
@extend .col-md-8;
|
||||||
@extend .col-lg-8;
|
@extend .col-lg-8;
|
||||||
|
|
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
|
|
@ -60,7 +60,7 @@ class Admin::ProceduresController < AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
flash.notice = 'Préocédure modifiée'
|
flash.notice = 'Préocédure modifiée'
|
||||||
redirect_to admin_procedures_path
|
redirect_to edit_admin_procedure_path(id: @procedure.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def archive
|
def archive
|
||||||
|
|
|
@ -38,7 +38,9 @@ class PieceJustificative < ActiveRecord::Base
|
||||||
application/vnd.openxmlformats-officedocument.presentationml.presentation,
|
application/vnd.openxmlformats-officedocument.presentationml.presentation,
|
||||||
application/vnd.oasis.opendocument.text,
|
application/vnd.oasis.opendocument.text,
|
||||||
application/vnd.oasis.opendocument.presentation,
|
application/vnd.oasis.opendocument.presentation,
|
||||||
application/vnd.oasis.opendocument.spreadsheet
|
application/vnd.oasis.opendocument.spreadsheet,
|
||||||
|
image/png,
|
||||||
|
image/jpeg
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
class TypeDeChamp < ActiveRecord::Base
|
class TypeDeChamp < ActiveRecord::Base
|
||||||
enum type_champs: {text: 'text',
|
enum type_champs: {text: 'text',
|
||||||
|
email: 'email',
|
||||||
|
phone: 'phone',
|
||||||
|
civilite: 'civilite',
|
||||||
textarea: 'textarea',
|
textarea: 'textarea',
|
||||||
datetime: 'datetime',
|
datetime: 'datetime',
|
||||||
number: 'number',
|
number: 'number',
|
||||||
|
|
|
@ -25,7 +25,7 @@ class CerfaUploader < CarrierWave::Uploader::Base
|
||||||
# Add a white list of extensions which are allowed to be uploaded.
|
# Add a white list of extensions which are allowed to be uploaded.
|
||||||
# For images you might use something like this:
|
# For images you might use something like this:
|
||||||
def extension_white_list
|
def extension_white_list
|
||||||
%w(pdf doc docx xls xlsx ppt pptx odt ods odp)
|
%w(pdf doc docx xls xlsx ppt pptx odt ods odp jpg jpeg png)
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename
|
def filename
|
||||||
|
|
|
@ -25,7 +25,7 @@ class PieceJustificativeUploader < CarrierWave::Uploader::Base
|
||||||
# Add a white list of extensions which are allowed to be uploaded.
|
# Add a white list of extensions which are allowed to be uploaded.
|
||||||
# For images you might use something like this:
|
# For images you might use something like this:
|
||||||
def extension_white_list
|
def extension_white_list
|
||||||
%w(pdf doc docx xls xlsx ppt pptx odt ods odp)
|
%w(pdf doc docx xls xlsx ppt pptx odt ods odp jpg jpeg png)
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename
|
def filename
|
||||||
|
|
|
@ -36,7 +36,7 @@ class ProcedureLogoUploader < CarrierWave::Uploader::Base
|
||||||
if Features.remote_storage
|
if Features.remote_storage
|
||||||
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}"
|
||||||
else
|
else
|
||||||
filename = "logo.#{file.extension.downcase}"
|
filename = "logo-#{secure_token}.#{file.extension.downcase}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
filename
|
filename
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
%h2.text-info
|
=render partial: 'admin/procedures/head', locals: {active: 'Accompagnateurs'}
|
||||||
=@procedure.libelle
|
|
||||||
%br
|
|
||||||
|
|
||||||
%ul.nav.nav-tabs
|
|
||||||
= render partial: 'admin/procedures/navbar', locals: {active: 'Accompagnateurs'}
|
|
||||||
|
|
||||||
#accompagnateur_form
|
#accompagnateur_form
|
||||||
.row
|
.row
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
%h2.text-info
|
=render partial: 'admin/procedures/head', locals: {active: 'Pieces'}
|
||||||
=@procedure.libelle
|
|
||||||
%br
|
|
||||||
|
|
||||||
%ul.nav.nav-tabs
|
|
||||||
= render partial: 'admin/procedures/navbar', locals: {active: 'Pieces'}
|
|
||||||
|
|
||||||
#piece_justificative_form
|
#piece_justificative_form
|
||||||
= render 'form'
|
= render 'form'
|
4
app/views/admin/previsualisations/show.html.haml
Normal file
4
app/views/admin/previsualisations/show.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
=render partial: 'admin/procedures/head', locals: {active: 'Prévisualisation'}
|
||||||
|
|
||||||
|
#previsualisation
|
||||||
|
=render 'users/description/show'
|
8
app/views/admin/procedures/_head.html.haml
Normal file
8
app/views/admin/procedures/_head.html.haml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
%h2.text-info
|
||||||
|
-unless @procedure.logo.blank?
|
||||||
|
= image_tag @procedure.logo, style: 'width: 30px'
|
||||||
|
=@procedure.libelle
|
||||||
|
%br
|
||||||
|
|
||||||
|
%ul.nav.nav-tabs
|
||||||
|
= render partial: 'admin/procedures/navbar', locals: {active: active}
|
|
@ -14,7 +14,9 @@
|
||||||
.row
|
.row
|
||||||
.col-md-6.col-lg-6
|
.col-md-6.col-lg-6
|
||||||
%h4 Logo de la procédure
|
%h4 Logo de la procédure
|
||||||
= f.file_field(:logo, accept: 'image/png, image/jpg,image/jpeg')
|
- unless @procedure.logo.blank?
|
||||||
|
= image_tag @procedure.logo, {style: 'height: 40px; display: inline; margin-right: 6px', id: 'preview_procedure_logo'}
|
||||||
|
= f.file_field(:logo, accept: 'image/png, image/jpg, image/jpeg', style: 'display:inline')
|
||||||
|
|
||||||
%div{style:'margin-top:5px'}
|
%div{style:'margin-top:5px'}
|
||||||
%i
|
%i
|
||||||
|
|
|
@ -15,3 +15,6 @@
|
||||||
%li{ class: ('disabled' if @procedure.locked?) || ('active' if active == 'Pieces') }
|
%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_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;'})
|
|
@ -1,9 +1,4 @@
|
||||||
%h2.text-info
|
= render partial: 'head', locals: {active: 'Description'}
|
||||||
=@procedure.libelle
|
|
||||||
%br
|
|
||||||
|
|
||||||
%ul.nav.nav-tabs
|
|
||||||
= render partial: 'navbar', locals: {active: 'Description'}
|
|
||||||
|
|
||||||
#procedure_new.section.section-label
|
#procedure_new.section.section-label
|
||||||
= form_for @procedure, url: url_for({controller: 'admin/procedures', action: :update, id: @procedure.id}), multipart: true do |f|
|
= form_for @procedure, url: url_for({controller: 'admin/procedures', action: :update, id: @procedure.id}), multipart: true do |f|
|
||||||
|
|
|
@ -4,3 +4,6 @@
|
||||||
= form_for @procedure, url: {controller: 'admin/procedures', action: :create}, multipart: true do |f|
|
= form_for @procedure, url: {controller: 'admin/procedures', action: :create}, multipart: true do |f|
|
||||||
=render partial: 'informations', locals: {f: f}
|
=render partial: 'informations', locals: {f: f}
|
||||||
=f.submit 'Valider', class: 'btn btn-info', style: 'float:right'
|
=f.submit 'Valider', class: 'btn btn-info', style: 'float:right'
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
|
@ -1,24 +1,18 @@
|
||||||
#procedure_show
|
#procedure_show
|
||||||
%h2.text-info
|
=render partial: 'head', locals: {active: 'Informations'}
|
||||||
=@facade.procedure.libelle
|
|
||||||
%br
|
|
||||||
|
|
||||||
%ul.nav.nav-tabs
|
= form_tag admin_procedure_archive_path(procedure_id: @facade.procedure.id, archive: !@facade.procedure.archived?), method: :put, style:'float: right; margin-top: 10px' do
|
||||||
= render partial: 'navbar', locals: {active: 'Informations'}
|
%button#archive.btn.btn-small.btn-default.text-info{type: :button}
|
||||||
|
|
||||||
%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
|
%i.fa.fa-eraser
|
||||||
- if @facade.procedure.archived
|
- if @facade.procedure.archived
|
||||||
= 'Réactiver'
|
= 'Réactiver'
|
||||||
- else
|
- else
|
||||||
= 'Archiver'
|
= 'Archiver'
|
||||||
#confirm
|
#confirm
|
||||||
%button#valid.btn.btn-nav.text-success{type: :submit}
|
%button#valid.btn.btn-small.btn-success{type: :submit}
|
||||||
%i.fa.fa-check
|
%i.fa.fa-check
|
||||||
Valider
|
Valider
|
||||||
%button#cancel.btn.btn-nav.text-danger{type: :button}
|
%button#cancel.btn.btn-small.btn-danger{type: :button}
|
||||||
%i.fa.fa-remove
|
%i.fa.fa-remove
|
||||||
Annuler
|
Annuler
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
%h2.text-info
|
=render partial: 'admin/procedures/head', locals: {active: 'Champs'}
|
||||||
=@procedure.libelle
|
|
||||||
%br
|
|
||||||
|
|
||||||
%ul.nav.nav-tabs
|
|
||||||
= render partial: 'admin/procedures/navbar', locals: {active: 'Champs'}
|
|
||||||
|
|
||||||
#liste_champ
|
#liste_champ
|
||||||
= render partial: 'form'
|
= render partial: 'form'
|
38
app/views/users/description/_champs.html.haml
Normal file
38
app/views/users/description/_champs.html.haml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
-@champs.each do |champ|
|
||||||
|
.row
|
||||||
|
%div{class: "type_champ-#{champ.type_champ}"}
|
||||||
|
-if champ.type_champ == 'checkbox'
|
||||||
|
%h4{style:'margin-left:15px;'}
|
||||||
|
= champ.libelle
|
||||||
|
- if champ.mandatory?
|
||||||
|
= '*'
|
||||||
|
%input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''}
|
||||||
|
%input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')}
|
||||||
|
-else
|
||||||
|
%h4
|
||||||
|
= champ.libelle
|
||||||
|
- if champ.mandatory?
|
||||||
|
= '*'
|
||||||
|
|
||||||
|
-if champ.type_champ == 'textarea'
|
||||||
|
%textarea.form-control{name:"champs['#{champ.id}']",
|
||||||
|
placeholder: champ.libelle,
|
||||||
|
id: "champs_#{champ.id}"}
|
||||||
|
=champ.value
|
||||||
|
-elsif champ.type_champ == 'civilite'
|
||||||
|
%label.radio-inline
|
||||||
|
= radio_button_tag "champs['#{champ.id}']", "M.", champ.value == 'Mme' ? false : true
|
||||||
|
Monsieur
|
||||||
|
|
||||||
|
%label.radio-inline
|
||||||
|
= radio_button_tag "champs['#{champ.id}']", "Mme", champ.value == 'Mme'
|
||||||
|
Madame
|
||||||
|
|
||||||
|
-else
|
||||||
|
%input.form-control{name:"champs['#{champ.id}']",
|
||||||
|
placeholder: champ.libelle,
|
||||||
|
id: "champs_#{champ.id}",
|
||||||
|
value: champ.value,
|
||||||
|
type: champ.type_champ,
|
||||||
|
'data-provide' => ('datepicker' if champ.type_champ == 'datetime'),
|
||||||
|
'data-date-format' => ('dd/mm/yyyy' if champ.type_champ == 'datetime')}
|
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,76 +1 @@
|
||||||
.container#description_page
|
= render partial: 'show'
|
||||||
%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?
|
|
||||||
-@champs.each do |champ|
|
|
||||||
.row
|
|
||||||
%div{class: "type_champ-#{champ.type_champ}"}
|
|
||||||
-if champ.type_champ == 'checkbox'
|
|
||||||
%h4{style:'margin-left:15px;'}
|
|
||||||
= champ.libelle
|
|
||||||
- if champ.mandatory?
|
|
||||||
= '*'
|
|
||||||
%input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''}
|
|
||||||
%input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')}
|
|
||||||
-else
|
|
||||||
%h4
|
|
||||||
= champ.libelle
|
|
||||||
- if champ.mandatory?
|
|
||||||
= '*'
|
|
||||||
|
|
||||||
-if champ.type_champ == 'textarea'
|
|
||||||
%textarea.form-control{name:"champs['#{champ.id}']",
|
|
||||||
placeholder: champ.libelle,
|
|
||||||
id: "champs_#{champ.id}"}
|
|
||||||
=champ.value
|
|
||||||
-else
|
|
||||||
%input.form-control{name:"champs['#{champ.id}']",
|
|
||||||
placeholder: champ.libelle,
|
|
||||||
id: "champs_#{champ.id}",
|
|
||||||
value: champ.value,
|
|
||||||
type:"#{champ.type_champ}",
|
|
||||||
'data-provide' => ('datepicker' if champ.type_champ == 'datetime'),
|
|
||||||
'data-date-format' => ('dd/mm/yyyy' if champ.type_champ == 'datetime')}
|
|
||||||
|
|
||||||
-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
|
|
|
@ -94,6 +94,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resource :accompagnateurs, only: [:show, :update]
|
resource :accompagnateurs, only: [:show, :update]
|
||||||
|
|
||||||
|
resource :previsualisation, only: [:show]
|
||||||
|
|
||||||
resources :types_de_champ, only: [:destroy]
|
resources :types_de_champ, only: [:destroy]
|
||||||
resource :pieces_justificatives, only: [:show, :update]
|
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
|
|
@ -192,7 +192,7 @@ describe Admin::ProceduresController, type: :controller do
|
||||||
it { expect(subject.cadastre).to be_truthy }
|
it { expect(subject.cadastre).to be_truthy }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(subject).to redirect_to(admin_procedures_path) }
|
it { expect(subject).to redirect_to(edit_admin_procedure_path id: procedure.id) }
|
||||||
it { expect(flash[:notice]).to be_present }
|
it { expect(flash[:notice]).to be_present }
|
||||||
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
|
17
spec/views/admin/procedures/edit.html.haml_spec.rb
Normal file
17
spec/views/admin/procedures/edit.html.haml_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'admin/procedures/edit.html.haml', type: :view do
|
||||||
|
let(:logo) { Rack::Test::UploadedFile.new("./spec/support/files/logo_test_procedure.png", 'image/png') }
|
||||||
|
let(:procedure) { create(:procedure, logo: logo) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
assign(:procedure, procedure)
|
||||||
|
render
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when procedure logo is present' do
|
||||||
|
it 'display on the page' do
|
||||||
|
expect(rendered).to have_selector('#preview_procedure_logo')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,6 +8,7 @@ describe 'users/description/show.html.haml', type: :view do
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
sign_in user
|
||||||
assign(:dossier, dossier)
|
assign(:dossier, dossier)
|
||||||
assign(:procedure, dossier.procedure)
|
assign(:procedure, dossier.procedure)
|
||||||
assign(:champs, dossier.ordered_champs)
|
assign(:champs, dossier.ordered_champs)
|
||||||
|
|
Loading…
Reference in a new issue