diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 84872c92c..8f9bc7c70 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -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 diff --git a/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb b/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb index a308a7859..5459a7d4e 100644 --- a/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb +++ b/app/models/types_de_champ/linked_drop_down_list_type_de_champ.rb @@ -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 --texte--") end end