From 304fb9ecef0d8b4a6582f66503b5874e49d2236e Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Wed, 13 Nov 2024 09:53:56 +0100 Subject: [PATCH] feat(simple routing): add options of list tdcs in tooltip --- app/components/dsfr/radio_button_list_component.rb | 2 +- .../radio_button_list_component.html.haml | 12 +++++++++--- .../groupe_instructeurs/simple_routing.html.haml | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/components/dsfr/radio_button_list_component.rb b/app/components/dsfr/radio_button_list_component.rb index 566d36653..775b70784 100644 --- a/app/components/dsfr/radio_button_list_component.rb +++ b/app/components/dsfr/radio_button_list_component.rb @@ -18,7 +18,7 @@ class Dsfr::RadioButtonListComponent < ApplicationComponent def each_button @buttons.each do |button| - yield(*button.values_at(:label, :value, :hint), **button.except(:label, :value, :hint)) + yield(*button.values_at(:label, :value, :hint, :tooltip), **button.except(:label, :value, :hint, :tooltip)) end end end diff --git a/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml b/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml index 8776b11af..f0dd1c403 100644 --- a/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml +++ b/app/components/dsfr/radio_button_list_component/radio_button_list_component.html.haml @@ -1,8 +1,9 @@ %fieldset{ class: class_names("fr-fieldset": true, "fr-fieldset--error": error?), 'aria-labelledby': 'radio-hint-element-legend radio-hint-element-messages', role: error? ? :group : nil } %legend.fr-fieldset__legend--regular.fr-fieldset__legend = content - - - each_button do |label, value, hint, **button_options| + - index = 0 + - each_button do |label, value, hint, tooltip, **button_options| + - index += 1 .fr-fieldset__element .fr-radio-group = @form.radio_button @target, value, **button_options @@ -12,7 +13,12 @@ = button_options[:after_label] if button_options[:after_label] - %span.fr-hint-text= hint if hint + - if hint.present? + .flex + .fr-hint-text= hint + - if tooltip.present? + .fr-icon-information-line.fr-icon--sm.ml-1{ 'aria-describedby': "tooltip-#{index}" } + %span.fr-tooltip.fr-placement{ id: "tooltip-#{index}", role: 'tooltip', 'aria-hidden': 'true' }= tooltip .fr-messages-group{ 'aria-live': 'assertive' } - if error? diff --git a/app/views/administrateurs/groupe_instructeurs/simple_routing.html.haml b/app/views/administrateurs/groupe_instructeurs/simple_routing.html.haml index bdcaa97aa..3fb90b18b 100644 --- a/app/views/administrateurs/groupe_instructeurs/simple_routing.html.haml +++ b/app/views/administrateurs/groupe_instructeurs/simple_routing.html.haml @@ -35,7 +35,7 @@ .card.fr-pb-0{ data: { 'action': "click->enable-submit-if-checked#click" } } .notice Sélectionner le champ à partir duquel créer des groupes d’instructeurs - - buttons_content = @procedure.active_revision.simple_routable_types_de_champ.map { |tdc| { label: tdc.libelle, value: tdc.stable_id, hint: "[#{I18n.t(tdc.type_champ, scope: 'activerecord.attributes.type_de_champ.type_champs')}]"} } + - buttons_content = @procedure.active_revision.simple_routable_types_de_champ.map { |tdc| { label: tdc.libelle, value: tdc.stable_id, hint: "[#{I18n.t(tdc.type_champ, scope: 'activerecord.attributes.type_de_champ.type_champs')}]", tooltip: tdc.drop_down_options.join(", ")} } = render Dsfr::RadioButtonListComponent.new(form: f, target: :stable_id, buttons: buttons_content)