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
|
end
|
||||||
|
|
||||||
def drop_down_list_enabled_non_empty_options(other: false)
|
def drop_down_list_enabled_non_empty_options(other: false)
|
||||||
list_options = drop_down_options.reject(&:empty?)
|
|
||||||
|
|
||||||
if other && drop_down_other?
|
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
|
else
|
||||||
list_options
|
drop_down_options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
end
|
end
|
||||||
|
|
||||||
def unpack_options
|
def unpack_options
|
||||||
chunked = drop_down_options
|
chunked = drop_down_options.slice_before(PRIMARY_PATTERN)
|
||||||
.reject(&:empty?) # TODO: remove after removing empty options
|
|
||||||
.slice_before(PRIMARY_PATTERN)
|
|
||||||
|
|
||||||
chunked.map do |chunk|
|
chunked.map do |chunk|
|
||||||
primary, *secondary = chunk
|
primary, *secondary = chunk
|
||||||
|
@ -101,8 +99,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_presence_of_primary_options
|
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.first)
|
||||||
if !PRIMARY_PATTERN.match?(drop_down_options.find(&:present?))
|
|
||||||
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>")
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue