pack drop_down stuff together

This commit is contained in:
simon lehericey 2024-09-17 12:08:43 +02:00
parent 85684e3bea
commit 51e192939c
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5

View file

@ -474,6 +474,20 @@ class TypeDeChamp < ApplicationRecord
end end
end end
def drop_down_options
Array.wrap(super)
end
def drop_down_list_enabled_non_empty_options(other: false)
list_options = drop_down_options.reject(&:empty?)
if other && drop_down_other?
list_options + [[I18n.t('shared.champs.drop_down_list.other'), Champs::DropDownListChamp::OTHER]]
else
list_options
end
end
def drop_down_list_value def drop_down_list_value
if drop_down_options.present? if drop_down_options.present?
drop_down_options.reject(&:empty?).join("\r\n") drop_down_options.reject(&:empty?).join("\r\n")
@ -566,20 +580,6 @@ class TypeDeChamp < ApplicationRecord
end end
end end
def drop_down_options
Array.wrap(super)
end
def drop_down_list_enabled_non_empty_options(other: false)
list_options = drop_down_options.reject(&:empty?)
if other && drop_down_other?
list_options + [[I18n.t('shared.champs.drop_down_list.other'), Champs::DropDownListChamp::OTHER]]
else
list_options
end
end
def layer_enabled?(layer) def layer_enabled?(layer)
options && options[layer] && options[layer] != '0' options && options[layer] && options[layer] != '0'
end end