commencer: add an independant page

This commit is contained in:
Pierre de La Morinerie 2019-01-16 10:57:58 +00:00
parent bd77f82df0
commit 016e5f2e6f
14 changed files with 252 additions and 42 deletions

View file

@ -0,0 +1,11 @@
@import "constants";
.commencer {
.button:first-of-type {
margin-top: 4 * $default-spacer;
}
.button {
margin-bottom: 2 * $default-spacer;
}
}

View file

@ -5,6 +5,10 @@
h1 {
text-align: center;
margin-bottom: 20px;
@media (max-width: $two-columns-breakpoint) {
font-size: 28px;
}
}
hr {

View file

@ -1,25 +1,44 @@
module NewUser
class CommencerController < ApplicationController
def commencer_test
procedure = Procedure.brouillons.find_by(path: params[:path])
if procedure.present?
redirect_to new_dossier_path(procedure_id: procedure.id, brouillon: true)
else
flash.alert = "La démarche est inconnue."
redirect_to root_path
end
end
layout 'procedure_context'
def commencer
procedure = Procedure.publiees.find_by(path: params[:path])
@procedure = Procedure.publiees.find_by(path: params[:path])
if procedure.present?
redirect_to new_dossier_path(procedure_id: procedure.id)
else
if @procedure.blank?
flash.alert = "La démarche est inconnue, ou la création de nouveaux dossiers pour cette démarche est terminée."
redirect_to root_path
return redirect_to root_path
end
render 'commencer/show'
end
def commencer_test
@procedure = Procedure.brouillons.find_by(path: params[:path])
if @procedure.blank?
flash.alert = "La démarche est inconnue, ou cette démarche nest maintenant plus en test."
return redirect_to root_path
end
render 'commencer/show'
end
def sign_in
store_user_location!
redirect_to new_user_session_path
end
def sign_up
store_user_location!
redirect_to new_user_registration_path
end
private
def store_user_location!
procedure = Procedure.find_by(path: params[:path])
store_location_for(:user, new_dossier_path(procedure_id: procedure.id))
end
end
end

View file

@ -23,6 +23,14 @@ module DossierHelper
end
end
def url_for_new_dossier(procedure)
if procedure.brouillon?
new_dossier_url(procedure_id: procedure.id, brouillon: true)
else
new_dossier_url(procedure_id: procedure.id)
end
end
def dossier_submission_is_closed?(dossier)
dossier.brouillon? && dossier.procedure.archivee?
end

View file

@ -0,0 +1,30 @@
- content_for(:title, @procedure.libelle)
.commencer.form
- if !user_signed_in?
%h1 Commencer la démarche
= link_to 'Créer un compte demarches-simplifiees.fr', commencer_sign_up_path(path: @procedure.path), class: ['button large expand primary']
= link_to 'Jai déjà un compte', commencer_sign_in_path(path: @procedure.path), class: ['button large expand']
- else
- dossiers = current_user.dossiers.where(procedure: @procedure)
- drafts = dossiers.merge(Dossier.state_brouillon)
- not_drafts = dossiers.merge(Dossier.state_not_brouillon)
- if dossiers.count == 0
= link_to 'Commencer la démarche', url_for_new_dossier(@procedure), class: ['button large expand primary']
- elsif drafts.count == 1 && not_drafts.count == 0
%h1 Vous avez déjà commencé à remplir un dossier
= link_to 'Continuer à remplir mon dossier', brouillon_dossier_path(drafts.first), class: ['button large expand primary']
= link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand']
- elsif not_drafts.count == 1
%h1 Vous avez déjà déposé un dossier
= link_to 'Voir mon dossier', dossier_path(not_drafts.first), class: ['button large expand primary']
= link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand']
- else
%h1 Vous avez déjà des dossiers pour cette démarche
= link_to 'Voir mes dossiers en cours', dossiers_path, class: ['button large expand primary']
= link_to 'Commencer un nouveau dossier', url_for_new_dossier(@procedure), class: ['button large expand']