remove drop_down_list_value reader

This commit is contained in:
simon lehericey 2024-09-18 17:21:22 +02:00
parent 483076970c
commit 5a19cc1a09
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
3 changed files with 8 additions and 12 deletions

View file

@ -72,7 +72,11 @@
.flex.column.justify-start.width-33
.cell
= form.label :drop_down_list_value, "Options de la liste", for: dom_id(type_de_champ, :drop_down_list_value)
= form.text_area :drop_down_list_value, class: 'fr-input small-margin small width-100', rows: 7, id: dom_id(type_de_champ, :drop_down_list_value)
= form.text_area :drop_down_list_value,
value: type_de_champ.drop_down_options.join("\r\n"),
class: 'fr-input small-margin small width-100',
rows: 7,
id: dom_id(type_de_champ, :drop_down_list_value)
- if type_de_champ.simple_drop_down_list?
.cell
= form.label :drop_down_other, for: dom_id(type_de_champ, :drop_down_other) do

View file

@ -490,14 +490,6 @@ class TypeDeChamp < ApplicationRecord
end
end
def drop_down_list_value
if drop_down_options.present?
drop_down_options.reject(&:empty?).join("\r\n")
else
''
end
end
def drop_down_list_value=(value)
self.drop_down_options = value.to_s.lines.map(&:strip).reject(&:empty?)
end

View file

@ -27,8 +27,8 @@ describe '20240912091625_clean_drop_down_options.rake' do
after { rake_task.reenable }
it 'removes the hidden options' do
expect(dashed_drop_down_list.drop_down_list_value).to eq(['1', '2'].join("\r\n"))
expect(witness_drop_down_list.drop_down_list_value).to eq(['1', 'hi', '2'].join("\r\n"))
expect(multiple_drop_down_list.drop_down_list_value).to eq(['1', '2'].join("\r\n"))
expect(dashed_drop_down_list.drop_down_options).to eq(['1', '2'])
expect(witness_drop_down_list.drop_down_options).to eq(['1', 'hi', '2'])
expect(multiple_drop_down_list.drop_down_options).to eq(['1', '2'])
end
end