commencer: add an independant page
This commit is contained in:
parent
bd77f82df0
commit
016e5f2e6f
14 changed files with 252 additions and 42 deletions
11
app/assets/stylesheets/new_design/commencer.scss
Normal file
11
app/assets/stylesheets/new_design/commencer.scss
Normal file
|
@ -0,0 +1,11 @@
|
|||
@import "constants";
|
||||
|
||||
.commencer {
|
||||
.button:first-of-type {
|
||||
margin-top: 4 * $default-spacer;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin-bottom: 2 * $default-spacer;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,10 @@
|
|||
h1 {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
|
||||
@media (max-width: $two-columns-breakpoint) {
|
||||
font-size: 28px;
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
|
|
|
@ -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 n’est 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
|
||||
|
|
|
@ -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
|
||||
|
|
30
app/views/commencer/show.html.haml
Normal file
30
app/views/commencer/show.html.haml
Normal 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 'J’ai 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']
|
Loading…
Add table
Add a link
Reference in a new issue