no more empty case
This commit is contained in:
parent
5a19cc1a09
commit
77b754a08d
2 changed files with 4 additions and 9 deletions
|
@ -481,12 +481,10 @@ class TypeDeChamp < ApplicationRecord
|
|||
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]]
|
||||
drop_down_options + [[I18n.t('shared.champs.drop_down_list.other'), Champs::DropDownListChamp::OTHER]]
|
||||
else
|
||||
list_options
|
||||
drop_down_options
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -89,9 +89,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
|||
end
|
||||
|
||||
def unpack_options
|
||||
chunked = drop_down_options
|
||||
.reject(&:empty?) # TODO: remove after removing empty options
|
||||
.slice_before(PRIMARY_PATTERN)
|
||||
chunked = drop_down_options.slice_before(PRIMARY_PATTERN)
|
||||
|
||||
chunked.map do |chunk|
|
||||
primary, *secondary = chunk
|
||||
|
@ -101,8 +99,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
|||
end
|
||||
|
||||
def check_presence_of_primary_options
|
||||
# TODO: replace by `drop_down_options.first` when the empty options are removed
|
||||
if !PRIMARY_PATTERN.match?(drop_down_options.find(&:present?))
|
||||
if !PRIMARY_PATTERN.match?(drop_down_options.first)
|
||||
errors.add(libelle.presence || "La liste", "doit commencer par une entrée de menu primaire de la forme <code style='white-space: pre-wrap;'>--texte--</code>")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue