diff --git a/app/assets/stylesheets/new_design/demarches_index.scss b/app/assets/stylesheets/new_design/demarches_index.scss new file mode 100644 index 000000000..e14441051 --- /dev/null +++ b/app/assets/stylesheets/new_design/demarches_index.scss @@ -0,0 +1,32 @@ +@import "colors"; + +#demarches-index { + margin-bottom: 30px; +} + +.page-title { + margin-top: 30px; + margin-bottom: 30px; +} + +.list-header { + color: $grey; + font-weight: bold; + margin-bottom: 10px; +} + +.demarche-links { + border-top: 1px solid $border-grey; + margin-bottom: 30px; +} + +.demarche-link { + display: block; + padding: 10px; + border-bottom: 1px solid $border-grey; + width: 100%; + + &:hover { + background-color: $lighter-blue; + } +} diff --git a/app/controllers/new_user/demarches_controller.rb b/app/controllers/new_user/demarches_controller.rb new file mode 100644 index 000000000..56c984dd6 --- /dev/null +++ b/app/controllers/new_user/demarches_controller.rb @@ -0,0 +1,21 @@ +module NewUser + class DemarchesController < UserController + def index + @previous_demarches_still_active = current_user + .dossiers + .includes(:procedure) + .map(&:procedure) + .uniq + .select { |p| p.publiee? } + + @popular_demarches = Procedure + .select("procedures.*, COUNT(*) AS procedures_count") + .joins(:dossiers) + .publiees + .where(dossiers: { created_at: 7.days.ago..Time.now }) + .group("procedures.id") + .order("procedures_count DESC") + .limit(5) + end + end +end diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index d602695f5..ce5023b9f 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -2,8 +2,6 @@ module NewUser class DossiersController < UserController include DossierHelper - helper_method :new_demarche_url - before_action :ensure_ownership!, except: [:index, :show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :recherche] before_action :ensure_ownership_or_invitation!, only: [:show, :demande, :messagerie, :brouillon, :update_brouillon, :modifier, :update, :create_commentaire] before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon, :modifier, :update] @@ -177,10 +175,6 @@ module NewUser end end - def new_demarche_url - "https://doc.demarches-simplifiees.fr/listes-des-demarches" - end - private def ensure_dossier_can_be_updated diff --git a/app/views/new_user/demarches/index.html.haml b/app/views/new_user/demarches/index.html.haml new file mode 100644 index 000000000..c7ccaef2c --- /dev/null +++ b/app/views/new_user/demarches/index.html.haml @@ -0,0 +1,25 @@ +- content_for(:title, "Démarches") + +- content_for :footer do + = render partial: "new_user/dossiers/index_footer" + +#demarches-index + .container + %h1.page-title Démarches + + - if @previous_demarches_still_active.present? + %h2.list-header SUR LESQUELLES VOUS AVEZ DÉJÀ DÉPOSÉ UN DOSSIER + %ul.demarche-links + - @previous_demarches_still_active.each do |demarche| + %li + = link_to(demarche.libelle, commencer_url(procedure_path: demarche.path), class: "demarche-link") + + - if @popular_demarches.present? + %h2.list-header LES PLUS POPULAIRES + %ul.demarche-links + - @popular_demarches.each do |demarche| + %li + = link_to(demarche.libelle, commencer_url(procedure_path: demarche.path), class: "demarche-link") + + %h2.list-header TOUTES LES DÉMARCHES + = link_to("Voir l'intégralité des démarches disponibles", LISTE_DES_DEMARCHES_URL, class: "button") diff --git a/app/views/new_user/dossiers/index.html.haml b/app/views/new_user/dossiers/index.html.haml index c625952a7..40c6189c7 100644 --- a/app/views/new_user/dossiers/index.html.haml +++ b/app/views/new_user/dossiers/index.html.haml @@ -5,7 +5,7 @@ .dossiers-headers.sub-header .container - = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button secondary new-demarche" + = link_to "Commencer une nouvelle démarche", demarches_url, class: "button secondary new-demarche" - if @dossiers_invites.count == 0 %h1.page-title Mes dossiers @@ -66,4 +66,4 @@ .dossiers-table-empty %h2.empty-text Aucun dossier. %p.empty-text-details Vous n’avez pas encore commencé de démarche. - = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary" + = link_to "Commencer une nouvelle démarche", demarches_url, class: "button primary" diff --git a/config/routes.rb b/config/routes.rb index 12b5dab91..4651f88bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -292,6 +292,7 @@ Rails.application.routes.draw do end end resource :feedback, only: [:create] + get 'demarches' => 'demarches#index' end #