display small selects as radio buttons

This commit is contained in:
clemkeirua 2020-06-15 16:29:22 +02:00
parent debbb21440
commit 22fc4c4195
3 changed files with 19 additions and 4 deletions

View file

@ -1,2 +1,3 @@
class Champs::DropDownListChamp < Champ
THRESHOLD_NB_OPTIONS_AS_RADIO = 3
end

View file

@ -8,6 +8,10 @@ class DropDownList < ApplicationRecord
result.blank? ? [] : [''] + result
end
def enabled_non_empty_options
(options - disabled_options).reject(&:empty?)
end
def disabled_options
options.filter { |v| (v =~ /^--.*--$/).present? }
end