Merge pull request #2114 from betagouv/frederic/fix_1568-nouvel_apercu_procedure
fix #1568 nouvel aperçu procédure
This commit is contained in:
commit
69ae3fc341
12 changed files with 71 additions and 276 deletions
|
@ -29,10 +29,6 @@
|
|||
|
||||
.white-back {
|
||||
margin: 20px !important;
|
||||
|
||||
#previsualisation {
|
||||
margin-top: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.white-back,
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
class Admin::PrevisualisationsController < AdminController
|
||||
before_action :retrieve_procedure
|
||||
|
||||
def show
|
||||
@procedure
|
||||
@dossier = Dossier.new(id: 0, procedure: @procedure)
|
||||
|
||||
PrevisualisationService.delete_all_champs @dossier
|
||||
@dossier.build_default_champs
|
||||
|
||||
@champs = @dossier.ordered_champs
|
||||
|
||||
@headers = @champs.select { |champ| champ.type_champ == 'header_section' }
|
||||
end
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
class PrevisualisationService
|
||||
def self.delete_all_champs(dossier)
|
||||
Champ.where(dossier_id: dossier.id, type_de_champ_id: dossier.procedure.types_de_champ.ids).delete_all
|
||||
end
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
.row.white-back
|
||||
#previsualisation
|
||||
= render partial: 'users/description/show', locals: { previsualisation: true }
|
|
@ -45,7 +45,7 @@
|
|||
.procedure-list-element{ class: ('active' if active == 'E-mails') }
|
||||
E-mails
|
||||
|
||||
%a#onglet-preview{ href: url_for(admin_procedure_previsualisation_path(@procedure)) }
|
||||
%a#onglet-preview{ href: url_for(apercu_procedure_path(@procedure)), target: "_blank" }
|
||||
.procedure-list-element{ class: ('active' if active == 'Prévisualisation') }
|
||||
Prévisualisation
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
.container#description-page
|
||||
- if notice_url(@dossier.procedure).present?
|
||||
#lien_notice_panel.row{ style: 'width: 280px; position: fixed; background-color: white; right: 5%; top: 80px; z-index: 200;' }
|
||||
.panel.panel-info{ style: 'margin-bottom: 0;' }
|
||||
.panel-body.center
|
||||
.row
|
||||
.col-xs-1
|
||||
.fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' }
|
||||
.col-xs-10{ style: 'padding-right: 0px;' }
|
||||
%b
|
||||
= link_to 'Accéder au guide', notice_url(@dossier.procedure), { target: '_blank' }
|
||||
pour remplir pour votre dossier
|
||||
|
||||
%h2.text-info
|
||||
= @dossier.procedure.libelle
|
||||
|
||||
-# TODO use form_for
|
||||
= form_tag(url_for({ controller: 'users/description', action: :update, dossier_id: @dossier.id }), class: 'form', method: 'POST', multipart: true) do
|
||||
- if @champs.present?
|
||||
#liste-champs
|
||||
= render partial: 'users/description/champs', locals: { private: false }
|
||||
|
||||
- if @procedure.lien_demarche.present? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
|
||||
%br
|
||||
%h3 Pièces jointes
|
||||
|
||||
|
||||
-# TODO a refactorer
|
||||
.row
|
||||
.col-lg-8
|
||||
= render partial: 'users/description/pieces_justificatives', locals: { dossier: @dossier }
|
||||
|
||||
- if !previsualisation
|
||||
%div{ style: 'text-align: right;' }
|
||||
%h6 Tous les champs portant un * sont obligatoires.
|
||||
|
||||
- if !@dossier.can_be_en_construction?
|
||||
.alert.alert-danger
|
||||
= t('errors.messages.procedure_archived')
|
||||
- elsif !@dossier.brouillon?
|
||||
= render partial: '/layouts/modifications_terminees'
|
||||
- else
|
||||
= hidden_field_tag 'submit_action', 'brouillon'
|
||||
= submit_tag 'Bonjour Active Storage !', style: 'display: none;'
|
||||
= button_tag 'Soumettre mon dossier',
|
||||
id: 'suivant',
|
||||
type: 'submit',
|
||||
class: 'btn btn btn-success',
|
||||
style: 'float: right;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'nouveaux' }
|
||||
= button_tag 'Enregistrer un brouillon',
|
||||
id: 'brouillon',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon' }
|
||||
= button_tag "Enregistrer et voir mes dossiers",
|
||||
id: 'brouillon_then_dashboard',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon_then_dashboard' }
|
|
@ -1 +1,64 @@
|
|||
= render partial: 'show', locals: { previsualisation: false }
|
||||
.container#description-page
|
||||
- if notice_url(@dossier.procedure).present?
|
||||
#lien_notice_panel.row{ style: 'width: 280px; position: fixed; background-color: white; right: 5%; top: 80px; z-index: 200;' }
|
||||
.panel.panel-info{ style: 'margin-bottom: 0;' }
|
||||
.panel-body.center
|
||||
.row
|
||||
.col-xs-1
|
||||
.fa.fa-info-circle.text-info{ style: 'font-size: 2em; margin-top: 20%;' }
|
||||
.col-xs-10{ style: 'padding-right: 0px;' }
|
||||
%b
|
||||
= link_to 'Accéder au guide', notice_url(@dossier.procedure), { target: '_blank' }
|
||||
pour remplir pour votre dossier
|
||||
|
||||
%h2.text-info
|
||||
= @dossier.procedure.libelle
|
||||
|
||||
-# TODO use form_for
|
||||
= form_tag(url_for({ controller: 'users/description', action: :update, dossier_id: @dossier.id }), class: 'form', method: 'POST', multipart: true) do
|
||||
- if @champs.present?
|
||||
#liste-champs
|
||||
= render partial: 'users/description/champs', locals: { private: false }
|
||||
|
||||
- if @procedure.lien_demarche.present? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0
|
||||
%br
|
||||
%h3 Pièces jointes
|
||||
|
||||
|
||||
-# TODO a refactorer
|
||||
.row
|
||||
.col-lg-8
|
||||
= render partial: 'users/description/pieces_justificatives', locals: { dossier: @dossier }
|
||||
|
||||
%div{ style: 'text-align: right;' }
|
||||
%h6 Tous les champs portant un * sont obligatoires.
|
||||
|
||||
- if !@dossier.can_be_en_construction?
|
||||
.alert.alert-danger
|
||||
= t('errors.messages.procedure_archived')
|
||||
- elsif !@dossier.brouillon?
|
||||
= render partial: '/layouts/modifications_terminees'
|
||||
- else
|
||||
= hidden_field_tag 'submit_action', 'brouillon'
|
||||
= submit_tag 'Bonjour Active Storage !', style: 'display: none;'
|
||||
= button_tag 'Soumettre mon dossier',
|
||||
id: 'suivant',
|
||||
type: 'submit',
|
||||
class: 'btn btn btn-success',
|
||||
style: 'float: right;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'nouveaux' }
|
||||
= button_tag 'Enregistrer un brouillon',
|
||||
id: 'brouillon',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon' }
|
||||
= button_tag "Enregistrer et voir mes dossiers",
|
||||
id: 'brouillon_then_dashboard',
|
||||
type: 'submit',
|
||||
class: 'btn btn-xs btn-default',
|
||||
style: 'float: right; margin-right: 10px; margin-top: 6px;',
|
||||
disabled: @procedure.archivee?,
|
||||
data: { disable: true, action: 'brouillon_then_dashboard' }
|
||||
|
|
|
@ -181,8 +181,6 @@ Rails.application.routes.draw do
|
|||
|
||||
resource :accompagnateurs, only: [:show, :update]
|
||||
|
||||
resource :previsualisation, only: [:show]
|
||||
|
||||
resource :attestation_template, only: [:edit, :update, :create]
|
||||
|
||||
post 'attestation_template/disactivate' => 'attestation_templates#disactivate'
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
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, params: { procedure_id: procedure.id } }
|
||||
it { expect(subject.status).to eq(200) }
|
||||
end
|
||||
end
|
|
@ -71,10 +71,12 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
|
|||
page.find_by_id('add_piece_justificative').click
|
||||
page.find_by_id('procedure_types_de_piece_justificative_attributes_1_libelle')
|
||||
|
||||
page.find_by_id('onglet-preview').click
|
||||
expect(page).to have_current_path(admin_procedure_previsualisation_path(Procedure.first.id.to_s))
|
||||
expect(page.find("input[type='text']")['placeholder']).to eq('libelle de champ')
|
||||
expect(page.first('.piece-libelle').text).to eq('libelle de piece')
|
||||
preview_window = window_opened_by { page.find_by_id('onglet-preview').click }
|
||||
within_window(preview_window) do
|
||||
expect(page).to have_current_path(apercu_procedure_path(Procedure.first))
|
||||
expect(page.find("input[type='text']")['placeholder']).to eq('libelle de champ')
|
||||
expect(page.first('.pj-input label').text).to eq('libelle de piece')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'After adding champ and file, check impossibility to publish procedure, add accompagnateur and make publication' do
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PrevisualisationService do
|
||||
describe '.delete_all_champs' do
|
||||
subject { described_class.delete_all_champs dossier }
|
||||
|
||||
let(:procedure_1) { create :procedure, :with_type_de_champ }
|
||||
let(:procedure_2) { create :procedure, :with_type_de_champ }
|
||||
|
||||
let!(:dossier_1) { create :dossier, procedure: procedure_1 }
|
||||
let!(:dossier_2) { create :dossier, procedure: procedure_2 }
|
||||
|
||||
it { expect(Dossier.all.size).to eq 2 }
|
||||
it { expect(TypeDeChamp.all.size).to eq 2 }
|
||||
it { expect(Champ.all.size).to eq 2 }
|
||||
|
||||
context 'when function delete_all_champs is call' do
|
||||
let(:dossier) { dossier_1 }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(Dossier.all.size).to eq 2 }
|
||||
it { expect(TypeDeChamp.all.size).to eq 2 }
|
||||
it { expect(Champ.all.size).to eq 1 }
|
||||
it { expect(Champ.first.type_de_champ).to eq procedure_2.types_de_champ.first }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,131 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/previsualisations/show.html.haml', type: :view do
|
||||
before do
|
||||
@request.env['HTTP_REFERER'] = admin_procedures_url
|
||||
end
|
||||
|
||||
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 '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.en_construction!
|
||||
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, user: user)
|
||||
end
|
||||
|
||||
before do
|
||||
render
|
||||
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("#champs_#{subject.id}") }
|
||||
end
|
||||
|
||||
describe 'last champs' do
|
||||
subject { dossier.champs.last }
|
||||
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
|
||||
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
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue