Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ameliorer l'UX de la recherche pour l'ASP #1353

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class ApplicationController < ActionController::Base
include UserLogger
include PageTitle

before_action :authenticate_user!,
:log_user,
Expand Down Expand Up @@ -47,30 +48,6 @@ def selected_school_year
SchoolYear.current
end

def infer_page_title(attrs = {})
key = page_title_key

return unless I18n.exists?(key)

title, breadcrumb = extract_title_data(I18n.t(key, deep_interpolation: true, **attrs))

@page_title = title

add_breadcrumb(breadcrumb)
end

def extract_title_data(data)
if data.is_a? Hash
[data[:title], data[:breadcrumb]]
else
[data, data]
end
end

def page_title_key
["pages", "titles", controller_name, action_name].join(".")
end

def redirect_asp_users!
redirect_to asp_schoolings_path and return if asp_user_signed_in?
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/asp/application_controller.rb
tnicolas1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
module ASP
class ApplicationController < ActionController::Base
include UserLogger
include PageTitle

layout "application"

before_action :authenticate_asp_user!, except: :login
before_action :log_user,
:set_overrides
:set_overrides,
:infer_page_title

helper_method :current_user, :current_establishment

Expand Down
37 changes: 16 additions & 21 deletions app/controllers/asp/schoolings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@ module ASP
class SchoolingsController < ApplicationController
layout "application"

before_action :sanitize_search,
:set_schooling_result,
:set_pfmps
before_action :set_schooling, :set_pfmps, only: :show
before_action :set_search_result, :infer_page_title, only: :index

def index
@page_title = "Rechercher un dossier"
def index; end

return if @schooling.nil?

@inhibit_title = true

@page_title = "Dossier #{@schooling.asp_dossier_id}"
def show
infer_page_title(attributive_decision_number: @schooling.attributive_decision_number)
end

private

def set_schooling_result
return if @search.blank?

@schooling = find_schooling_by_attributive_decision_filename
def set_schooling
@schooling = Schooling.find(params[:id])
end

def set_pfmps
Expand All @@ -35,16 +28,18 @@ def set_pfmps
.distinct
end

def set_search_result
@attributive_decision_number = params[:search]

return if @attributive_decision_number.blank?

@schoolings = find_schooling_by_attributive_decision_filename || []
end

def find_schooling_by_attributive_decision_filename
Schooling
.joins(:attributive_decision_blob)
.find_by("filename LIKE ?", "%_#{@search}.pdf")
end

def sanitize_search
return if params[:search].blank?

@search = params[:search].strip.upcase
.where("filename LIKE ?", "%#{@attributive_decision_number.strip.upcase}%")
tnicolas1 marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
32 changes: 32 additions & 0 deletions app/controllers/concerns/page_title.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

module PageTitle
extend ActiveSupport::Concern

def infer_page_title(attrs = {})
key = page_title_key

return unless I18n.exists?(key)

title, breadcrumb = extract_title_data(I18n.t(key, deep_interpolation: true, **attrs))

@page_title = title

add_breadcrumb(breadcrumb)
end

private

def page_title_key
asp = "asp" if controller_path.include?("asp/")
["pages", "titles", asp, controller_name, action_name].join(".")
end

def extract_title_data(data)
if data.is_a? Hash
[data[:title], data[:breadcrumb]]
else
[data, data]
end
end
end
6 changes: 6 additions & 0 deletions app/views/asp/schoolings/_search-bar.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.fr-mb-3w
= form_with method: :get, url: asp_schoolings_path do |form|
.fr-search-bar.fr-search-bar--lg.fr-col-md-8{id: "search", role: "search"}
= form.label :search, "Numéro de décision d'attribution...", class: "fr-label"
= form.text_field :search, placeholder: "Numéro de décision d'attribution", value: @attributive_decision_number, class: "fr-input"
= form.button "Rechercher", type: "submit", class: "fr-btn", name: nil
30 changes: 17 additions & 13 deletions app/views/asp/schoolings/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
.fr-mb-3w
= form_with method: :get, url: asp_schoolings_path do |form|
.fr-search-bar.fr-search-bar--lg.fr-col-md-8#search
= form.label :search, "Numéro de décision d'attribution", class: "fr-label"
= form.text_field :search, placeholder: "Numéro de décision d'attribution", value: @search, class: "fr-input"
= form.button "Rechercher", type: "submit", class: "fr-btn"
= render partial: 'search-bar'



- if @search.blank?
- if @attributive_decision_number.blank?
.fr-mb-5w
Entrez un numéro de décision d'attribution pour lancer une recherche

- elsif @schooling.blank?
- elsif @schoolings.none?
.fr-mb-5w
Aucune décision d'attribution trouvée avec le numéro
= @search
Aucune décision d'attribution trouvée avec le numéro : #{@attributive_decision_number}

- else
= render partial: "schooling"
.fr-table
%table
%caption #{@schoolings.count} résultats trouvés pour la recherche : #{@attributive_decision_number}
%thead
%td{scope: "col"} Dossiers
%th{scope: "col"} Élèves
%th{scope: "col"} Dernière classe
%tbody
- @schoolings.each do |schooling|
%tr
%td= dsfr_link_to schooling.attributive_decision_number, asp_schooling_path(schooling)
%td= schooling.student.full_name
%td= schooling.classe.label

Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
%h1
Dossier
= @schooling.attributive_decision_number
= render partial: 'search-bar'

%h1.fr-mb-5w= @page_title

.fr-my-3w
- if @schooling.attributive_decision.present?
= link_to "Télécharger la décision d'attribution", url_for(@schooling.attributive_decision), class: 'fr-btn fr-btn--secondary', target: :download
- else
Aucune décision d'attribution éditée

.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Élève
%thead
%th{colspan: 2} Élève
%tbody
%tr
%td Nom
Expand All @@ -28,9 +29,10 @@
%td Code INSEE du pays de naissance
%td= display_insee_code(@schooling.student.birthplace_country_insee_code)

.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Établissement
%thead
%th{colspan: 2} Établissement
%tbody
%tr
%td UAI
Expand All @@ -41,9 +43,10 @@
%tr
%td Email
%td= @schooling.establishment.email
.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Formation
%thead
%th{colspan: 2} Formation
%tbody
%tr
%td Forfait journalier
Expand All @@ -53,9 +56,10 @@
%td= number_to_currency @schooling.mef.wage.yearly_cap


.fr-table
.fr-table.fr-table--no-caption
%table
%caption.fr-h2 Coordonnées bancaires
%thead
%th{colspan: 2} Coordonnées bancaires
%tbody
- rib = @schooling.student.rib(@schooling.establishment)
- if rib.blank?
Expand Down
6 changes: 6 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ fr:
faq: F.A.Q.
pages:
titles:
asp:
application:
login: Connexion à APLyPro
schoolings:
index: Recherche d'un dossier
show: "Dossier %{attributive_decision_number}"
stats:
index: Statistiques
school_years:
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# rubocop:disable Metrics/BlockLength
Rails.application.routes.draw do
namespace :asp do
resources :schoolings, only: :index
resources :schoolings, only: %i[index show]

devise_for :users, skip: :all, class_name: "ASP::User"
end
Expand Down
16 changes: 9 additions & 7 deletions features/asp_consultation_de_dossier.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ Fonctionnalité: Le personnel ASP consulte des dossiers

Scénario: Le personnel ASP entre un numéro de décision d'attribution existant
Sachant que le numéro administratif de "Marie Curie" est "THEDOSS"
Et que je remplis "Numéro de décision d'attribution" avec "ENPUTHEDOSS20240"
Et que je remplis "Numéro de décision d'attribution" avec "THEDOSS2024"
Quand je clique sur "Rechercher"
Alors la page contient "ENPUTHEDOSS20240"
Et la page contient "3 jours x 10 € par jour = 30 €"
Quand je clique sur "ENPUTHEDOSS20240"
Alors la page contient "3 jours x 10 € par jour = 30 €"
Et la page contient "IBAN"

Scénario: Le personnel ASP n'a pas accès à l'interface principale
Quand je me rends sur la page d'accueil
Alors le titre de la page contient "Rechercher un dossier"
tnicolas1 marked this conversation as resolved.
Show resolved Hide resolved
Et la page ne contient pas "Classes"
Alors le titre de la page contient "Recherche d'un dossier"
Alors la page ne contient pas "Classes"
Et la page ne contient pas "Envoyer en paiement"

Scénario: Le personnel ASP est redirigé vers la page de connexion ASP en cas d'erreur de connexion
Sachant que je me déconnecte
Et que je suis un agent de l'ASP avec l'email "[email protected]"
Quand je me connecte au portail ASP
Et que je me rend sur la page de recherche de dossier
Alors la page contient "Vous devez vous connecter ou vous enregistrer pour continuer."
Sachant que je suis un agent de l'ASP avec l'email "[email protected]"
Et que je me connecte au portail ASP
Alors la page contient "Erreur lors du traitement de votre profil"
Et la page contient "Vous êtes un agent de l'ASP"
Loading