fix(drop_down_list): fix other option with combobox and some cleanup

This commit is contained in:
Paul Chavard 2023-10-27 17:39:02 +02:00
parent 4a698f8264
commit d76123831c
13 changed files with 25 additions and 48 deletions

View file

@ -13,6 +13,6 @@ class EditableChamp::DropDownListComponent < EditableChamp::EditableChampBaseCom
def contains_long_option?
max_length = 100
@champ.options.any? { _1.size > max_length }
@champ.enabled_non_empty_options.any? { _1.size > max_length }
end
end

View file

@ -17,12 +17,12 @@
.fr-radio-group
= @form.radio_button :value, Champs::DropDownListChamp::OTHER, checked: @champ.other?, id: "#{@champ.id}_radio_option_other"
%label.fr-label{ for: "#{@champ.id}_radio_option_other" }
Autre
= t('shared.champs.drop_down_list.other')
- elsif @champ.render_as_combobox?
= render Dsfr::ComboboxComponent.new form: @form, name: :value, options: @champ.enabled_non_empty_options, selected: @champ.selected, id: @champ.input_id, class: select_class_names, describedby: @champ.describedby_id
= render Dsfr::ComboboxComponent.new form: @form, name: :value, options: @champ.enabled_non_empty_options(other: true), selected: @champ.selected, id: @champ.input_id, class: select_class_names, describedby: @champ.describedby_id
- else
= @form.select :value,
@champ.options.compact_blank,
@champ.enabled_non_empty_options(other: true),
{ selected: @champ.selected, include_blank: true },
required: @champ.required?,
id: @champ.input_id,