From 51e192939c38c8160b4fee2501c650d48526b69a Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 17 Sep 2024 12:08:43 +0200 Subject: [PATCH] pack drop_down stuff together --- app/models/type_de_champ.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index aa33ad68a..ca94c3c3c 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -474,6 +474,20 @@ class TypeDeChamp < ApplicationRecord 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 if drop_down_options.present? drop_down_options.reject(&:empty?).join("\r\n") @@ -566,20 +580,6 @@ class TypeDeChamp < ApplicationRecord 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) options && options[layer] && options[layer] != '0' end