layouts: use a common procedure_context layout for the demarche overview

This commit is contained in:
Pierre de La Morinerie 2019-01-07 11:17:11 +00:00
parent 5a36546485
commit e25bd7139f
11 changed files with 106 additions and 81 deletions

View file

@ -2,6 +2,8 @@ module NewUser
class DossiersController < UserController
include DossierHelper
layout 'procedure_context', only: [:identite, :update_identite, :siret, :update_siret]
SESSION_USER_RETURN_LOCATION = 'user_return_to'
ACTIONS_ALLOWED_TO_ANY_USER = [:index, :recherche, :new]
ACTIONS_ALLOWED_TO_OWNER_OR_INVITE = [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire, :purge_champ_piece_justificative]

View file

@ -38,7 +38,7 @@
= render partial: "layouts/new_header"
= render partial: "layouts/flash_messages"
= yield
= content_for?(:content) ? yield(:content) : yield
- if content_for?(:footer)
= content_for(:footer)

View file

@ -0,0 +1,22 @@
- content_for :content do
.two-columns
.columns-container
.column.preview
- procedure = @dossier.procedure
.procedure-logos
= image_tag logo_img(procedure)
- if procedure.euro_flag
= image_tag "flag_of_europe.svg"
%h2.procedure-title
= procedure.libelle
.procedure-description
= h string_to_html(procedure.description)
.column.identity-form
= yield
- content_for :footer do
= render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }
= render template: 'layouts/application'

View file

@ -1,9 +0,0 @@
.procedure-logos
= image_tag logo_img(procedure)
- if procedure.euro_flag
= image_tag "flag_of_europe.svg"
%h2.procedure-title
= procedure.libelle
.procedure-description
= h string_to_html(procedure.description)

View file

@ -1,39 +1,30 @@
- content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})")
- content_for :footer do
= render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
.two-columns
.columns-container
.column.preview
= render partial: "new_user/dossiers/demarche_overview", locals: { procedure: @dossier.procedure }
- if !dossier_submission_is_closed?(@dossier)
= form_for @dossier.individual, url: update_identite_dossier_path(@dossier), html: { class: "form" } do |f|
%h1 Données d'identité
.column.identity-form
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
%p.mb-1 Merci de remplir vos informations personnelles pour accéder à la démarche.
- if !dossier_submission_is_closed?(@dossier)
= form_for @dossier.individual, url: update_identite_dossier_path(@dossier), html: { class: "form" } do |f|
%h1 Données d'identité
%label
%span.mandatory *
champs requis
%p.mb-1 Merci de remplir vos informations personnelles pour accéder à la démarche.
= f.label :gender, class: "required"
= f.select :gender, ['M.', 'Mme'], {}, class: "small"
%label
%span.mandatory *
champs requis
.flex
.inline-champ
= f.label :prenom, class: "required"
= f.text_field :prenom, class: "small", required: true
.inline-champ
= f.label :nom, class: "required"
= f.text_field :nom, class: "small", required: true
= f.label :gender, class: "required"
= f.select :gender, ['M.', 'Mme'], {}, class: "small"
- if @dossier.procedure.ask_birthday?
= f.label :birthdate, class: "required"
= f.date_field :birthdate, value: @dossier.individual.birthdate, placeholder: 'format : AAAA-MM-JJ', required: true, class: "small"
.flex
.inline-champ
= f.label :prenom, class: "required"
= f.text_field :prenom, class: "small", required: true
.inline-champ
= f.label :nom, class: "required"
= f.text_field :nom, class: "small", required: true
- if @dossier.procedure.ask_birthday?
= f.label :birthdate, class: "required"
= f.date_field :birthdate, value: @dossier.individual.birthdate, placeholder: 'format : AAAA-MM-JJ', required: true, class: "small"
= f.submit "Continuer", class: "button large primary expand"
= f.submit "Continuer", class: "button large primary expand"

View file

@ -1,25 +1,14 @@
- content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})")
- content_for :footer do
= render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier }
- if !dossier_submission_is_closed?(@dossier)
= form_for current_user, url: siret_dossier_path(@dossier), html: { class: 'form', method: 'post' } do |f|
%h1 Identifier votre établissement
.two-columns
.columns-container
.column.preview
= render partial: "new_user/dossiers/demarche_overview", locals: { procedure: @dossier.procedure }
%p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche.
.column.identity-form
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
= f.label :siret, style: "display: none"
= f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true
- if !dossier_submission_is_closed?(@dossier)
= form_for current_user, url: siret_dossier_path(@dossier), html: { class: 'form', method: 'post' } do |f|
%h1 Identifier votre établissement
= f.hidden_field :dossier_id, value: @dossier.id
%p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche.
= f.label :siret, style: "display: none"
= f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true
= f.hidden_field :dossier_id, value: @dossier.id
= f.submit "Valider", class: "button large primary expand", data: { disable_with: "Récupération des informations…" }
= f.submit "Valider", class: "button large primary expand", data: { disable_with: "Récupération des informations…" }

View file

@ -10,6 +10,7 @@ FactoryBot.define do
administrateur { create(:administrateur) }
duree_conservation_dossiers_dans_ds { 3 }
duree_conservation_dossiers_hors_ds { 6 }
ask_birthday { false }
factory :procedure_with_dossiers do
transient do

View file

@ -11,12 +11,17 @@ feature 'Creating a new dossier:' do
end
context 'when the procedure has identification by individual' do
let(:procedure) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, ask_birthday: ask_birthday) }
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_type_de_champ, :with_two_type_de_piece_justificative, ask_birthday: ask_birthday) }
let(:ask_birthday) { false }
let(:expected_birthday) { nil }
before do
visit commencer_path(path: procedure.path)
expect(page).to have_content(procedure.libelle)
expect(page).to have_content(procedure.description)
expect(page).to have_content(procedure.service.email)
fill_in 'individual_nom', with: 'Nom'
fill_in 'individual_prenom', with: 'Prenom'
end
@ -58,7 +63,7 @@ feature 'Creating a new dossier:' do
end
context 'when identifying through SIRET' do
let(:procedure) { create(:procedure, :published, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let(:procedure) { create(:procedure, :published, :with_service, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let(:dossier) { procedure.dossiers.last }
before do
@ -74,7 +79,11 @@ feature 'Creating a new dossier:' do
scenario 'the user can enter the SIRET of its etablissement and create a new draft', vcr: { cassette_name: 'api_adresse_search_paris_3' }, js: true do
visit commencer_path(path: procedure.path)
expect(page).to have_current_path(siret_dossier_path(dossier))
expect(page).to have_content(procedure.libelle)
expect(page).to have_content(procedure.description)
expect(page).to have_content(procedure.service.email)
fill_in 'Numéro SIRET', with: siret
click_on 'Valider'

View file

@ -0,0 +1,28 @@
require 'rails_helper'
describe 'layouts/procedure_context.html.haml', type: :view do
let(:procedure) { create(:simple_procedure, :with_service) }
let(:dossier) { create(:dossier, procedure: procedure) }
before do
assign(:dossier, dossier)
end
subject do
render html: 'Column content', layout: 'layouts/procedure_context.html.haml'
end
it 'renders a description of the procedure' do
expect(subject).to have_text(dossier.procedure.libelle)
expect(subject).to have_text(dossier.procedure.description)
end
it 'renders the inner content' do
expect(subject).to have_text('Column content')
end
it 'renders the dossier footer' do
expect(subject).to have_text(dossier.procedure.service.nom)
expect(subject).to have_text(dossier.procedure.service.email)
end
end

View file

@ -1,25 +1,26 @@
require 'spec_helper'
describe 'new_user/dossiers/identite.html.haml', type: :view do
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: create(:procedure, :with_two_type_de_piece_justificative, for_individual: true)) }
let(:footer) { view.content_for(:footer) }
let(:procedure) { create(:simple_procedure, for_individual: true) }
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
before do
sign_in dossier.user
assign(:dossier, dossier)
end
context 'test de composition de la page' do
before do
render
end
subject! { render }
it 'affiche les informations de la démarche' do
expect(rendered).to have_text(dossier.procedure.libelle)
end
it 'has identity fields' do
expect(rendered).to have_field('Prénom')
expect(rendered).to have_field('Nom')
end
it 'prépare le footer' do
expect(footer).to have_selector('footer')
context 'when the demarche asks for the birthdate' do
let(:procedure) { create(:simple_procedure, for_individual: true, ask_birthday: true) }
it 'has a birthday field' do
expect(rendered).to have_field('Date de naissance')
end
end
end

View file

@ -2,7 +2,6 @@ require 'spec_helper'
describe 'new_user/dossiers/siret.html.haml', type: :view do
let(:dossier) { create(:dossier) }
let(:footer) { view.content_for(:footer) }
before do
sign_in dossier.user
@ -11,15 +10,7 @@ describe 'new_user/dossiers/siret.html.haml', type: :view do
subject! { render }
it 'affiche les informations de la démarche' do
expect(rendered).to have_text(dossier.procedure.libelle)
end
it 'affiche le formulaire de SIRET' do
expect(rendered).to have_field('Numéro SIRET')
end
it 'prépare le footer' do
expect(footer).to have_selector('footer')
end
end