From 04212bd27982069d24d25fbbc2b5f4c1768ac908 Mon Sep 17 00:00:00 2001 From: tnicolas1 Date: Fri, 24 Jan 2025 11:30:17 +0100 Subject: [PATCH] Correction de tests et factorisation de la barre de recherche --- app/controllers/asp/schoolings_controller.rb | 12 ++++++--- .../asp/schoolings/_search-bar.html.haml | 6 +++++ app/views/asp/schoolings/index.html.haml | 9 ++----- app/views/asp/schoolings/show.html.haml | 26 +++++++++++-------- config/locales/fr.yml | 2 +- features/asp_consultation_de_dossier.feature | 6 ++--- 6 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 app/views/asp/schoolings/_search-bar.html.haml diff --git a/app/controllers/asp/schoolings_controller.rb b/app/controllers/asp/schoolings_controller.rb index d143dd756..0c9b41731 100644 --- a/app/controllers/asp/schoolings_controller.rb +++ b/app/controllers/asp/schoolings_controller.rb @@ -4,15 +4,21 @@ module ASP class SchoolingsController < ApplicationController layout "application" - before_action :set_pfmps, only: :show + before_action :set_schooling, :set_pfmps, only: :show before_action :set_search_result, :infer_page_title, only: :index def index; end - def show; end + def show + infer_page_title(attributive_decision_number: @schooling.attributive_decision_number) + end private + def set_schooling + @schooling = Schooling.find(params[:id]) + end + def set_pfmps return if @schooling.nil? @@ -33,7 +39,7 @@ def set_search_result def find_schooling_by_attributive_decision_filename Schooling .joins(:attributive_decision_blob) - .find_by("filename LIKE ?", "%_#{@attributive_decision_number.strip.upcase}.pdf") + .where("filename LIKE ?", "%#{@attributive_decision_number.strip.upcase}%") end end end diff --git a/app/views/asp/schoolings/_search-bar.html.haml b/app/views/asp/schoolings/_search-bar.html.haml new file mode 100644 index 000000000..3885f00f6 --- /dev/null +++ b/app/views/asp/schoolings/_search-bar.html.haml @@ -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 \ No newline at end of file diff --git a/app/views/asp/schoolings/index.html.haml b/app/views/asp/schoolings/index.html.haml index 02174d2c8..f67ca0f3b 100644 --- a/app/views/asp/schoolings/index.html.haml +++ b/app/views/asp/schoolings/index.html.haml @@ -1,9 +1,4 @@ -.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 += render partial: 'search-bar' - if @attributive_decision_number.blank? .fr-mb-5w @@ -24,7 +19,7 @@ %tbody - @schoolings.each do |schooling| %tr - %td= dsfr_link_to schooling.attributive_decision_number, asp_schoolings_path(schooling) + %td= dsfr_link_to schooling.attributive_decision_number, asp_schooling_path(schooling) %td= schooling.student.full_name %td= schooling.classe.label \ No newline at end of file diff --git a/app/views/asp/schoolings/show.html.haml b/app/views/asp/schoolings/show.html.haml index 1c51e16c4..44c344963 100644 --- a/app/views/asp/schoolings/show.html.haml +++ b/app/views/asp/schoolings/show.html.haml @@ -1,6 +1,6 @@ -%h1 - Dossier - = @schooling.attributive_decision_number += render partial: 'search-bar' + +%h1.fr-mb-5w= @page_title .fr-my-3w - if @schooling.attributive_decision.present? @@ -8,9 +8,10 @@ - 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 @@ -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 @@ -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 @@ -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? diff --git a/config/locales/fr.yml b/config/locales/fr.yml index bd981a67e..05d396ed5 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -163,7 +163,7 @@ fr: login: Connexion à APLyPro schoolings: index: Recherche d'un dossier - show: Dossier + show: "Dossier %{attributive_decision_number}" stats: index: Statistiques school_years: diff --git a/features/asp_consultation_de_dossier.feature b/features/asp_consultation_de_dossier.feature index 46a3b8308..849d29812 100644 --- a/features/asp_consultation_de_dossier.feature +++ b/features/asp_consultation_de_dossier.feature @@ -19,13 +19,13 @@ Fonctionnalité: Le personnel ASP consulte des dossiers Sachant que le numéro administratif de "Marie Curie" est "THEDOSS" Et que je remplis "Numéro de décision d'attribution" avec "ENPUTHEDOSS20240" 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" + Alors le titre de la page contient "Recherche d'un dossier" Et la page ne contient pas "Classes" Et la page ne contient pas "Envoyer en paiement"