rename remaining drop_down_list_enabled_non_empty_options(other: true) -> drop_down_options_with_other

This commit is contained in:
simon lehericey 2024-09-19 17:11:14 +02:00
parent 532f0f48fa
commit 5fc0eb11f5
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
5 changed files with 6 additions and 6 deletions

View file

@ -31,7 +31,7 @@ class EditableChamp::DropDownListComponent < EditableChamp::EditableChampBaseCom
class: 'fr-mt-1w',
name: @form.field_name(:value),
selected_key: @champ.selected,
items: @champ.drop_down_list_enabled_non_empty_options(other: true).map { _1.is_a?(Array) ? _1 : [_1, _1] },
items: @champ.drop_down_options_with_other.map { _1.is_a?(Array) ? _1 : [_1, _1] },
empty_filter_key: @champ.drop_down_other? ? Champs::DropDownListChamp::OTHER : nil,
'aria-describedby': @champ.describedby_id,
'aria-labelledby': @champ.labelledby_id)

View file

@ -22,7 +22,7 @@
= render ReactComponent.new "ComboBox/SingleComboBox", **react_props
- else
= @form.select :value,
@champ.drop_down_list_enabled_non_empty_options(other: true),
@champ.drop_down_options_with_other,
{ selected: @champ.selected, include_blank: true },
required: @champ.required?,
id: @champ.input_id,

View file

@ -31,7 +31,7 @@ class Champ < ApplicationRecord
:description,
:drop_down_options,
:drop_down_other?,
:drop_down_list_enabled_non_empty_options,
:drop_down_options_with_other,
:drop_down_secondary_libelle,
:drop_down_secondary_description,
:collapsible_explanation_enabled?,

View file

@ -128,7 +128,7 @@ class Logic::ChampValue < Logic::Term
elsif operator_name.in?([Logic::InDepartementOperator.name, Logic::NotInDepartementOperator.name]) || tdc.type_champ.in?([MANAGED_TYPE_DE_CHAMP.fetch(:communes), MANAGED_TYPE_DE_CHAMP.fetch(:epci), MANAGED_TYPE_DE_CHAMP.fetch(:departements), MANAGED_TYPE_DE_CHAMP.fetch(:address)])
APIGeoService.departements.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] }
else
tdc.drop_down_list_enabled_non_empty_options(other: true).map { _1.is_a?(Array) ? _1 : [_1, _1] }
tdc.drop_down_options_with_other.map { _1.is_a?(Array) ? _1 : [_1, _1] }
end
end

View file

@ -480,8 +480,8 @@ class TypeDeChamp < ApplicationRecord
Array.wrap(super)
end
def drop_down_list_enabled_non_empty_options(other: false)
if other && drop_down_other?
def drop_down_options_with_other
if drop_down_other?
drop_down_options + [[I18n.t('shared.champs.drop_down_list.other'), Champs::DropDownListChamp::OTHER]]
else
drop_down_options