diff --git a/app/assets/stylesheets/new_design/dossier_show.scss b/app/assets/stylesheets/new_design/dossier_show.scss index 66dc60376..c9c92a581 100644 --- a/app/assets/stylesheets/new_design/dossier_show.scss +++ b/app/assets/stylesheets/new_design/dossier_show.scss @@ -30,4 +30,8 @@ font-weight: bold; } } + + .button.edit-form { + float: right; + } } diff --git a/app/assets/stylesheets/new_design/status_progress.scss b/app/assets/stylesheets/new_design/status_progress.scss index cff35aac6..e9a5261eb 100644 --- a/app/assets/stylesheets/new_design/status_progress.scss +++ b/app/assets/stylesheets/new_design/status_progress.scss @@ -47,9 +47,9 @@ .status-explanation { text-align: left; - &.brouillon, - &.en-construction, - &.en-instruction { + .brouillon, + .en-construction, + .en-instruction { max-width: 600px; margin: auto; } diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index 6f53d7295..3ffa4fa57 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -4,8 +4,8 @@ module NewUser helper_method :new_demarche_url - before_action :ensure_ownership!, except: [:index, :show, :modifier, :update, :recherche] - before_action :ensure_ownership_or_invitation!, only: [:show, :modifier, :update] + before_action :ensure_ownership!, except: [:index, :show, :formulaire, :modifier, :update, :recherche] + before_action :ensure_ownership_or_invitation!, only: [:show, :formulaire, :modifier, :update] before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update] before_action :forbid_invite_submission!, only: [:update] @@ -34,6 +34,10 @@ module NewUser @dossier = dossier end + def formulaire + @dossier = dossier + end + def attestation send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') end @@ -104,7 +108,11 @@ module NewUser NotificationMailer.send_initiated_notification(@dossier).deliver_later redirect_to merci_dossier_path(@dossier) elsif current_user.owns?(dossier) - redirect_to users_dossier_recapitulatif_path(@dossier) + if Flipflop.new_dossier_details? + redirect_to formulaire_dossier_path(@dossier) + else + redirect_to users_dossier_recapitulatif_path(@dossier) + end else redirect_to users_dossiers_invite_path(@dossier.invite_for_user(current_user)) end diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml index c8a4ae923..6a0e2e9d8 100644 --- a/app/views/new_gestionnaire/avis/show.html.haml +++ b/app/views/new_gestionnaire/avis/show.html.haml @@ -2,5 +2,5 @@ = render partial: 'header', locals: { avis: @avis, dossier: @dossier } -= render partial: 'new_gestionnaire/shared/show', locals: { dossier: @dossier, demande_seen_at: nil } += render partial: 'shared/dossiers/show', locals: { dossier: @dossier, demande_seen_at: nil } diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml index 88017ec0c..ac7af1845 100644 --- a/app/views/new_gestionnaire/dossiers/print.html.haml +++ b/app/views/new_gestionnaire/dossiers/print.html.haml @@ -3,19 +3,19 @@ %h2 Identité du demandeur -= render partial: "new_gestionnaire/dossiers/user_infos", locals: { user: @dossier.user } += render partial: "shared/dossiers/user_infos", locals: { user: @dossier.user } - if @dossier.etablissement.present? - = render partial: "identite_entreprise", locals: { etablissement: @dossier.etablissement } + = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: @dossier.etablissement } - if @dossier.individual.present? - = render partial: "identite_individual", locals: { individual: @dossier.individual } + = render partial: "shared/dossiers/identite_individual", locals: { individual: @dossier.individual } %h2 Formulaire - champs = @dossier.ordered_champs.decorate - if champs.any? - = render partial: "champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil } + = render partial: "shared/dossiers/champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: nil } - if @dossier.procedure.use_api_carto %h3 Cartographie diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index c7a827ef3..378bfcdc3 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -2,4 +2,4 @@ = render partial: "header", locals: { dossier: @dossier } -= render partial: 'new_gestionnaire/shared/show', locals: { dossier: @dossier, demande_seen_at: @demande_seen_at } += render partial: "shared/dossiers/show", locals: { dossier: @dossier, demande_seen_at: @demande_seen_at } diff --git a/app/views/new_gestionnaire/shared/_show.html.haml b/app/views/new_gestionnaire/shared/_show.html.haml deleted file mode 100644 index ac26279b8..000000000 --- a/app/views/new_gestionnaire/shared/_show.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -.container - .tab-title Identité du demandeur - .card - = render partial: "new_gestionnaire/dossiers/user_infos", locals: { user: dossier.user } - - - if dossier.etablissement.present? - = render partial: "new_gestionnaire/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement } - - - if dossier.individual.present? - = render partial: "new_gestionnaire/dossiers/identite_individual", locals: { individual: dossier.individual } - - .tab-title Formulaire - - champs = dossier.ordered_champs.includes(:type_de_champ).decorate - - if champs.any? - .card - = render partial: "new_gestionnaire/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at } - - - if dossier.procedure.use_api_carto - .tab-title Cartographie - .card - = render partial: "new_gestionnaire/dossiers/map", locals: { dossier: dossier } - - - if dossier.types_de_piece_justificative.any? - .tab-title Pièces jointes - .card - = render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: dossier, demande_seen_at: demande_seen_at } diff --git a/app/views/new_user/dossiers/formulaire.html.haml b/app/views/new_user/dossiers/formulaire.html.haml new file mode 100644 index 000000000..986935c40 --- /dev/null +++ b/app/views/new_user/dossiers/formulaire.html.haml @@ -0,0 +1,8 @@ +#dossier-show + = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } + + = render partial: 'shared/dossiers/show', locals: { dossier: @dossier, demande_seen_at: nil } + + .container + - if !@dossier.read_only? + = link_to "Modifier le dossier", modifier_dossier_path(@dossier), class: 'button primary edit-form' diff --git a/app/views/new_user/dossiers/show.html.haml b/app/views/new_user/dossiers/show.html.haml index a9154569c..073022c10 100644 --- a/app/views/new_user/dossiers/show.html.haml +++ b/app/views/new_user/dossiers/show.html.haml @@ -1,4 +1,5 @@ #dossier-show = render partial: 'new_user/dossiers/show/header', locals: { dossier: @dossier } - = render partial: 'new_user/dossiers/show/resume', locals: { dossier: @dossier } + .container + = render partial: 'new_user/dossiers/show/status_progress', locals: { dossier: @dossier } diff --git a/app/views/new_user/dossiers/show/_header.html.haml b/app/views/new_user/dossiers/show/_header.html.haml index c4d4b63d4..bf42eddb4 100644 --- a/app/views/new_user/dossiers/show/_header.html.haml +++ b/app/views/new_user/dossiers/show/_header.html.haml @@ -8,5 +8,7 @@ %h2 Dossier nº #{dossier.id} %ul.tabs - %li.active + %li{ class: current_page?(dossier_path(dossier)) ? 'active' : nil } = link_to "Résumé", dossier_path(dossier) + %li{ class: current_page?(formulaire_dossier_path(dossier)) ? 'active' : nil } + = link_to "Formulaire", formulaire_dossier_path(dossier) diff --git a/app/views/new_user/dossiers/show/_resume.html.haml b/app/views/new_user/dossiers/show/_resume.html.haml deleted file mode 100644 index d0e584949..000000000 --- a/app/views/new_user/dossiers/show/_resume.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -.container - = render partial: 'new_user/dossiers/show/status_progress', locals: { dossier: dossier } diff --git a/app/views/new_gestionnaire/dossiers/_champs.html.haml b/app/views/shared/dossiers/_champs.html.haml similarity index 95% rename from app/views/new_gestionnaire/dossiers/_champs.html.haml rename to app/views/shared/dossiers/_champs.html.haml index 57d6d0e35..81537a06a 100644 --- a/app/views/new_gestionnaire/dossiers/_champs.html.haml +++ b/app/views/shared/dossiers/_champs.html.haml @@ -55,7 +55,7 @@ %td.rich-text %span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) } - if c.etablissement.present? - = render partial: "new_gestionnaire/dossiers/identite_entreprise", locals: { etablissement: c.etablissement } + = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: c.etablissement } - else %th.libelle = "#{c.libelle} :" diff --git a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml b/app/views/shared/dossiers/_identite_entreprise.html.haml similarity index 100% rename from app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml rename to app/views/shared/dossiers/_identite_entreprise.html.haml diff --git a/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml b/app/views/shared/dossiers/_identite_individual.html.haml similarity index 100% rename from app/views/new_gestionnaire/dossiers/_identite_individual.html.haml rename to app/views/shared/dossiers/_identite_individual.html.haml diff --git a/app/views/new_gestionnaire/dossiers/_map.html.haml b/app/views/shared/dossiers/_map.html.haml similarity index 100% rename from app/views/new_gestionnaire/dossiers/_map.html.haml rename to app/views/shared/dossiers/_map.html.haml diff --git a/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml b/app/views/shared/dossiers/_pieces_jointes.html.haml similarity index 100% rename from app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml rename to app/views/shared/dossiers/_pieces_jointes.html.haml diff --git a/app/views/shared/dossiers/_show.html.haml b/app/views/shared/dossiers/_show.html.haml new file mode 100644 index 000000000..4405f57b3 --- /dev/null +++ b/app/views/shared/dossiers/_show.html.haml @@ -0,0 +1,26 @@ +.container + .tab-title Identité du demandeur + .card + = render partial: "shared/dossiers/user_infos", locals: { user: dossier.user } + + - if dossier.etablissement.present? + = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement } + + - if dossier.individual.present? + = render partial: "shared/dossiers/identite_individual", locals: { individual: dossier.individual } + + .tab-title Formulaire + - champs = dossier.ordered_champs.includes(:type_de_champ).decorate + - if champs.any? + .card + = render partial: "shared/dossiers/champs", locals: { champs: champs, demande_seen_at: demande_seen_at } + + - if dossier.procedure.use_api_carto + .tab-title Cartographie + .card + = render partial: "shared/dossiers/map", locals: { dossier: dossier } + + - if dossier.types_de_piece_justificative.any? + .tab-title Pièces jointes + .card + = render partial: "shared/dossiers/pieces_jointes", locals: { dossier: dossier, demande_seen_at: demande_seen_at } diff --git a/app/views/new_gestionnaire/dossiers/_user_infos.html.haml b/app/views/shared/dossiers/_user_infos.html.haml similarity index 100% rename from app/views/new_gestionnaire/dossiers/_user_infos.html.haml rename to app/views/shared/dossiers/_user_infos.html.haml diff --git a/config/routes.rb b/config/routes.rb index e7830425c..f777e2612 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -274,6 +274,7 @@ Rails.application.routes.draw do get 'modifier' patch 'modifier', to: 'dossiers#update' get 'merci' + get 'formulaire' post 'ask_deletion' get 'attestation' end diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index c62e00de9..74f543c4a 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -509,6 +509,20 @@ describe NewUser::DossiersController, type: :controller do end end + describe '#formulaire' do + let(:dossier) { create(:dossier, :en_construction, user: user) } + + before do + Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true) + sign_in(user) + end + + subject! { get(:formulaire, params: { id: dossier.id }) } + + it { expect(assigns(:dossier)).to eq(dossier) } + it { is_expected.to render_template(:formulaire) } + end + describe '#ask_deletion' do before { sign_in(user) } diff --git a/spec/features/new_user/dossier_details_spec.rb b/spec/features/new_user/dossier_details_spec.rb index 3804804ae..6ddc49e11 100644 --- a/spec/features/new_user/dossier_details_spec.rb +++ b/spec/features/new_user/dossier_details_spec.rb @@ -1,6 +1,10 @@ describe 'Dossier details:' do let(:user) { create(:user) } - let(:dossier) { create(:dossier, :en_construction, user: user) } + let(:simple_procedure) do + tdcs = [create(:type_de_champ, libelle: 'texte obligatoire')] + create(:procedure, :published, :for_individual, types_de_champ: tdcs) + end + let(:dossier) { create(:dossier, :en_construction, :for_individual, user: user, procedure: simple_procedure) } before do Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true) @@ -14,6 +18,21 @@ describe 'Dossier details:' do expect(page).to have_selector('.status-explanation') end + scenario 'the user can see and edit dossier before instruction' do + visit_dossier dossier + click_on 'Formulaire' + + expect(page).to have_current_path(formulaire_dossier_path(dossier)) + click_on 'Modifier le dossier' + + expect(page).to have_current_path(modifier_dossier_path(dossier)) + fill_in('texte obligatoire', with: 'Nouveau texte') + click_on 'Enregistrer les modifications du dossier' + + expect(page).to have_current_path(formulaire_dossier_path(dossier)) + expect(page).to have_content('Nouveau texte') + end + private def visit_dossier(dossier) diff --git a/spec/views/new_user/dossiers/formulaire.html.haml_spec.rb b/spec/views/new_user/dossiers/formulaire.html.haml_spec.rb new file mode 100644 index 000000000..81bce7907 --- /dev/null +++ b/spec/views/new_user/dossiers/formulaire.html.haml_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe 'new_user/dossiers/formulaire.html.haml', type: :view do + let(:procedure) { create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private) } + let(:dossier) { create(:dossier, :en_construction, :with_entreprise, procedure: procedure) } + + before do + assign(:dossier, dossier) + end + + subject! { render } + + it 'renders the header' do + expect(rendered).to have_text("Dossier nº #{dossier.id}") + end + + it 'renders the dossier infos' do + expect(rendered).to have_text('Identité') + expect(rendered).to have_text('Formulaire') + expect(rendered).to have_text('Pièces jointes') + end + + context 'when the dossier is editable' do + it { is_expected.to have_link('Modifier le dossier', href: modifier_dossier_path(dossier)) } + end + + context 'when the dossier is read-only' do + let(:dossier) { create(:dossier, :en_instruction, :with_entreprise, procedure: procedure) } + it { is_expected.not_to have_link('Modifier le dossier') } + end +end diff --git a/spec/views/new_user/dossiers/show.html.haml_spec.rb b/spec/views/new_user/dossiers/show.html.haml_spec.rb index c3feada30..dda868f27 100644 --- a/spec/views/new_user/dossiers/show.html.haml_spec.rb +++ b/spec/views/new_user/dossiers/show.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'new_user/dossiers/show.html.haml', type: :view do - let(:dossier) { create(:dossier, :with_service, state: 'brouillon', procedure: create(:procedure)) } + let(:dossier) { create(:dossier, :en_construction, procedure: create(:procedure)) } before do sign_in dossier.user @@ -10,8 +10,8 @@ describe 'new_user/dossiers/show.html.haml', type: :view do subject! { render } - it 'affiche les informations du dossier' do - expect(rendered).to have_text(dossier.procedure.libelle) + it 'renders a summary of the dossier state' do expect(rendered).to have_text("Dossier nº #{dossier.id}") + expect(rendered).to have_selector('.status-progress') end end diff --git a/spec/views/new_user/dossiers/show/_header.html.haml_spec.rb b/spec/views/new_user/dossiers/show/_header.html.haml_spec.rb new file mode 100644 index 000000000..ece6e94fe --- /dev/null +++ b/spec/views/new_user/dossiers/show/_header.html.haml_spec.rb @@ -0,0 +1,15 @@ +describe 'new_user/dossiers/show/header.html.haml', type: :view do + let(:dossier) { create(:dossier, :en_construction, procedure: create(:procedure)) } + + subject! { render 'new_user/dossiers/show/header.html.haml', dossier: dossier } + + it 'affiche les informations du dossier' do + expect(rendered).to have_text(dossier.procedure.libelle) + expect(rendered).to have_text("Dossier nº #{dossier.id}") + expect(rendered).to have_text("en construction") + + expect(rendered).to have_selector("ul.tabs") + expect(rendered).to have_link("Résumé", href: dossier_path(dossier)) + expect(rendered).to have_link("Formulaire", href: formulaire_dossier_path(dossier)) + end +end diff --git a/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb b/spec/views/shared/dossiers/_champs.html.haml_spec.rb similarity index 92% rename from spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb rename to spec/views/shared/dossiers/_champs.html.haml_spec.rb index 05a2e22d2..9f86d9cec 100644 --- a/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_champs.html.haml_spec.rb @@ -1,4 +1,4 @@ -describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do +describe 'shared/dossiers/champs.html.haml', type: :view do let(:gestionnaire) { create(:gestionnaire) } let(:demande_seen_at) { nil } @@ -8,7 +8,7 @@ describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do allow(view).to receive(:current_gestionnaire).and_return(gestionnaire) end - subject { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs, demande_seen_at: demande_seen_at } + subject { render 'shared/dossiers/champs.html.haml', champs: champs, demande_seen_at: demande_seen_at } context "there are some champs" do let(:dossier) { create(:dossier) } diff --git a/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb b/spec/views/shared/dossiers/_identite_entreprise.html.haml_spec.rb similarity index 65% rename from spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb rename to spec/views/shared/dossiers/_identite_entreprise.html.haml_spec.rb index 121e08044..f80e4eee8 100644 --- a/spec/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_identite_entreprise.html.haml_spec.rb @@ -1,5 +1,5 @@ -describe 'new_gestionnaire/dossiers/identite_entreprise.html.haml', type: :view do - before { render 'new_gestionnaire/dossiers/identite_entreprise.html.haml', etablissement: etablissement } +describe 'shared/dossiers/identite_entreprise.html.haml', type: :view do + before { render 'shared/dossiers/identite_entreprise.html.haml', etablissement: etablissement } context "there is an association" do let(:etablissement) { create(:etablissement, :is_association) } diff --git a/spec/views/new_gestionnaire/dossiers/_map_spec.rb b/spec/views/shared/dossiers/_map_spec.rb similarity index 87% rename from spec/views/new_gestionnaire/dossiers/_map_spec.rb rename to spec/views/shared/dossiers/_map_spec.rb index d9c998cce..9e3d05c48 100644 --- a/spec/views/new_gestionnaire/dossiers/_map_spec.rb +++ b/spec/views/shared/dossiers/_map_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'new_gestionnaire/dossiers/_map.html.haml', type: :view do +describe 'shared/dossiers/map.html.haml', type: :view do subject do - render(partial: 'new_gestionnaire/dossiers/map.html.haml', locals: { dossier: dossier }) + render(partial: 'shared/dossiers/map.html.haml', locals: { dossier: dossier }) end describe "javascript variables printing" do