always show user choice even if no more in enum in columns
This commit is contained in:
parent
6e5aa90bc7
commit
c578c88f48
2 changed files with 3 additions and 16 deletions
|
@ -70,7 +70,7 @@ class Columns::ChampColumn < Column
|
|||
when :date
|
||||
parse_datetime(value)&.to_date
|
||||
when :enum
|
||||
parse_enum(value)
|
||||
value
|
||||
when :enums
|
||||
parse_enums(value)
|
||||
else
|
||||
|
@ -91,9 +91,9 @@ class Columns::ChampColumn < Column
|
|||
when ['integer_number', 'text'], ['decimal_number', 'text'] # number to text
|
||||
value
|
||||
when ['drop_down_list', 'multiple_drop_down_list'] # single list can become multi
|
||||
[parse_enum(value)].compact_blank
|
||||
[value]
|
||||
when ['drop_down_list', 'text'] # single list can become text
|
||||
parse_enum(value)
|
||||
value
|
||||
when ['multiple_drop_down_list', 'drop_down_list'] # multi list can become single
|
||||
parse_enums(value)&.first
|
||||
when ['multiple_drop_down_list', 'text'] # multi list can become text
|
||||
|
@ -116,11 +116,6 @@ class Columns::ChampColumn < Column
|
|||
end
|
||||
end
|
||||
|
||||
def parse_enum(value)
|
||||
return value if options_for_select.blank?
|
||||
value if options_for_select.to_set(&:second).member?(value)
|
||||
end
|
||||
|
||||
def parse_enums(value)
|
||||
values = JSON.parse(value)
|
||||
return values if options_for_select.blank?
|
||||
|
|
|
@ -121,14 +121,6 @@ describe Columns::ChampColumn do
|
|||
expect(column('multiple_drop_down_list').value(champ)).to eq(['val1'])
|
||||
expect(column('text').value(champ)).to eq('val1')
|
||||
end
|
||||
|
||||
context 'value not in options' do
|
||||
let(:value) { 'toto' }
|
||||
|
||||
it do
|
||||
expect(column('simple_drop_down_list').value(champ)).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'from a multiple_drop_down_list' do
|
||||
|
|
Loading…
Reference in a new issue