amelioration(form): utilise les bonnes classes DSFR pour divers composants
This commit is contained in:
parent
2c04be5289
commit
f54ab0bf96
11 changed files with 103 additions and 70 deletions
|
@ -156,6 +156,10 @@ class Champ < ApplicationRecord
|
|||
stable_id_with_maybe_row.split('|')
|
||||
end
|
||||
|
||||
def dsfr_champ_container
|
||||
:div
|
||||
end
|
||||
|
||||
def html_label?
|
||||
true
|
||||
end
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
class Champs::CheckboxChamp < Champs::BooleanChamp
|
||||
def dsfr_champ_container
|
||||
:fieldset
|
||||
end
|
||||
|
||||
def for_export
|
||||
true? ? 'on' : 'off'
|
||||
end
|
||||
|
@ -7,9 +11,8 @@ class Champs::CheckboxChamp < Champs::BooleanChamp
|
|||
mandatory? && (blank? || !true?)
|
||||
end
|
||||
|
||||
# TODO remove when normalize_checkbox_values is over
|
||||
def true?
|
||||
value_with_legacy == TRUE_VALUE
|
||||
def legend_label?
|
||||
false
|
||||
end
|
||||
|
||||
def html_label?
|
||||
|
@ -19,11 +22,4 @@ class Champs::CheckboxChamp < Champs::BooleanChamp
|
|||
def single_checkbox?
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# TODO remove when normalize_checkbox_values is over
|
||||
def value_with_legacy
|
||||
value == 'on' ? TRUE_VALUE : value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,6 +30,10 @@ class Champs::DropDownListChamp < Champ
|
|||
render_as_radios?
|
||||
end
|
||||
|
||||
def dsfr_champ_container
|
||||
render_as_radios? ? :fieldset : :div
|
||||
end
|
||||
|
||||
def selected
|
||||
other? ? OTHER : value
|
||||
end
|
||||
|
|
|
@ -13,6 +13,10 @@ class Champs::LinkedDropDownListChamp < Champ
|
|||
end
|
||||
end
|
||||
|
||||
def dsfr_champ_container
|
||||
:fieldset
|
||||
end
|
||||
|
||||
def secondary_value
|
||||
if value.present?
|
||||
JSON.parse(value)[1]
|
||||
|
|
|
@ -43,10 +43,18 @@ class Champs::MultipleDropDownListChamp < Champ
|
|||
enabled_non_empty_options.size <= THRESHOLD_NB_OPTIONS_AS_CHECKBOX
|
||||
end
|
||||
|
||||
def dsfr_champ_container
|
||||
render_as_checkboxes? ? :fieldset : :div
|
||||
end
|
||||
|
||||
def html_label?
|
||||
!render_as_checkboxes?
|
||||
end
|
||||
|
||||
def legend_label?
|
||||
true
|
||||
end
|
||||
|
||||
def single_checkbox?
|
||||
render_as_checkboxes?
|
||||
end
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
class Champs::YesNoChamp < Champs::BooleanChamp
|
||||
def dsfr_champ_container
|
||||
:fieldset
|
||||
end
|
||||
|
||||
def legend_label?
|
||||
true
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue