From 5c53c6b86cab8361a6436f1d64a95f4323652bbc Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Thu, 17 Oct 2024 09:20:52 +0200 Subject: [PATCH] feat(routing): add modal once custom routing is configurated --- .../groupes_management_component.html.haml | 3 +++ .../groupe_instructeurs_controller.rb | 2 ++ app/helpers/application_helper.rb | 2 ++ .../_custom_routing_modal.html.haml | 20 +++++++++++++++++++ .../routing/rules_full_scenario_spec.rb | 5 +++++ 5 files changed, 32 insertions(+) create mode 100644 app/views/administrateurs/groupe_instructeurs/_custom_routing_modal.html.haml diff --git a/app/components/procedure/groupes_management_component/groupes_management_component.html.haml b/app/components/procedure/groupes_management_component/groupes_management_component.html.haml index 3ae0bb3f9..7548d6da0 100644 --- a/app/components/procedure/groupes_management_component/groupes_management_component.html.haml +++ b/app/components/procedure/groupes_management_component/groupes_management_component.html.haml @@ -50,3 +50,6 @@ = select_tag :defaut_groupe_instructeur_id, options_for_select(@procedure.groupe_instructeurs.pluck(:label, :id), selected: @procedure.defaut_groupe_instructeur.id), class: 'fr-select' + +- if flash[:routing_mode] == 'custom' + = render partial: 'custom_routing_modal' diff --git a/app/controllers/administrateurs/groupe_instructeurs_controller.rb b/app/controllers/administrateurs/groupe_instructeurs_controller.rb index 544e3591f..741e3a025 100644 --- a/app/controllers/administrateurs/groupe_instructeurs_controller.rb +++ b/app/controllers/administrateurs/groupe_instructeurs_controller.rb @@ -107,6 +107,8 @@ module Administrateurs procedure.toggle_routing + flash[:routing_mode] = 'custom' + redirect_to admin_procedure_groupe_instructeurs_path(procedure) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3fdc45795..a4dc44d5d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -44,6 +44,8 @@ module ApplicationHelper class_names << 'alert-success' when 'alert', 'error' class_names << 'alert-danger' + when 'routing_mode' + class_names << 'hidden' end if sticky class_names << 'sticky' diff --git a/app/views/administrateurs/groupe_instructeurs/_custom_routing_modal.html.haml b/app/views/administrateurs/groupe_instructeurs/_custom_routing_modal.html.haml new file mode 100644 index 000000000..cc503f514 --- /dev/null +++ b/app/views/administrateurs/groupe_instructeurs/_custom_routing_modal.html.haml @@ -0,0 +1,20 @@ +%dialog{ aria: { labelledby: "fr-modal-title-modal-1" }, role: "dialog", id: "routing-mode-modal", class: "fr-modal fr-modal--opened" } + .fr-container.fr-container--fluid.fr-container-md + .fr-grid-row.fr-grid-row--center + .fr-col-12.fr-col-md-8.fr-col-lg-6 + .fr-modal__body + .fr-modal__header + %button.fr-btn.fr-btn--close{ title: "Fermer la fenêtre modale", aria: { controls: "routing-mode-modal" } } Fermer + .fr-modal__content + %h1#fr-modal-title-modal-1.fr-modal__title + %span.fr-icon-arrow-right-line.fr-icon--lg + Routage avancé + .fr-alert.fr-alert--success + %h2.fr-alert__title + Deux groupes par défaut ont été créés + %p + Vous devez maintenant les renommer et leur attribuer des règles de routage à partir du ou des champs « routables » de votre formulaire, soit des champs de type : + %ul + - TypeDeChamp.humanized_conditionable_types_by_category.each do |category| + %li + = category.join(', ') diff --git a/spec/system/routing/rules_full_scenario_spec.rb b/spec/system/routing/rules_full_scenario_spec.rb index ee4620705..5d392b03d 100644 --- a/spec/system/routing/rules_full_scenario_spec.rb +++ b/spec/system/routing/rules_full_scenario_spec.rb @@ -53,6 +53,11 @@ describe 'The routing with rules', js: true do expect(page).to have_text('Gestion des groupes') expect(page).to have_text('règle invalide') + # close modal + expect(page).to have_selector("#routing-mode-modal", visible: true) + within("#routing-mode-modal") { click_on "Fermer" } + expect(page).to have_selector("#routing-mode-modal", visible: false) + # update defaut groupe click_on 'défaut' expect(page).to have_text('Paramètres du groupe')