[#1568] Remove old previsualisation code
This commit is contained in:
parent
fd10310cbf
commit
521aec6af9
10 changed files with 32 additions and 238 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 }
|
|
@ -30,36 +30,35 @@
|
|||
.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.
|
||||
%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' }
|
||||
- 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 @@
|
|||
= render partial: 'show', locals: { previsualisation: false }
|
||||
= render partial: 'show'
|
||||
|
|
|
@ -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
|
|
@ -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