feat(simple routing): add options of list tdcs in tooltip

This commit is contained in:
Eric Leroy-Terquem 2024-11-13 09:53:56 +01:00
parent 4e8200aaf7
commit 304fb9ecef
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
3 changed files with 11 additions and 5 deletions

View file

@ -18,7 +18,7 @@ class Dsfr::RadioButtonListComponent < ApplicationComponent
def each_button def each_button
@buttons.each do |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 end
end end

View file

@ -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 } %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 %legend.fr-fieldset__legend--regular.fr-fieldset__legend
= content = content
- index = 0
- each_button do |label, value, hint, **button_options| - each_button do |label, value, hint, tooltip, **button_options|
- index += 1
.fr-fieldset__element .fr-fieldset__element
.fr-radio-group .fr-radio-group
= @form.radio_button @target, value, **button_options = @form.radio_button @target, value, **button_options
@ -12,7 +13,12 @@
= button_options[:after_label] if button_options[:after_label] = 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' } .fr-messages-group{ 'aria-live': 'assertive' }
- if error? - if error?

View file

@ -35,7 +35,7 @@
.card.fr-pb-0{ data: { 'action': "click->enable-submit-if-checked#click" } } .card.fr-pb-0{ data: { 'action': "click->enable-submit-if-checked#click" } }
.notice .notice
Sélectionner le champ à partir duquel créer des groupes dinstructeurs Sélectionner le champ à partir duquel créer des groupes dinstructeurs
- 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, = render Dsfr::RadioButtonListComponent.new(form: f,
target: :stable_id, target: :stable_id,
buttons: buttons_content) buttons: buttons_content)