Rename DropDownList#selected_options_without_decorator

This commit is contained in:
gregoirenovel 2018-12-27 17:35:17 +01:00
parent 4b4eb6d53e
commit c4b9a0b79e
3 changed files with 5 additions and 5 deletions

View file

@ -2,7 +2,7 @@ class Champs::MultipleDropDownListChamp < Champ
before_save :format_before_save
def search_terms
drop_down_list.selected_options_without_decorator(self)
drop_down_list.selected_options(self)
end
private
@ -20,10 +20,10 @@ class Champs::MultipleDropDownListChamp < Champ
end
def string_value
drop_down_list.selected_options_without_decorator(self).join(', ')
drop_down_list.selected_options(self).join(', ')
end
def value_for_export
drop_down_list.selected_options_without_decorator(self).join(', ')
drop_down_list.selected_options(self).join(', ')
end
end

View file

@ -10,7 +10,7 @@ class DropDownList < ApplicationRecord
options.select { |v| (v =~ /^--.*--$/).present? }
end
def selected_options_without_decorator(champ)
def selected_options(champ)
champ.value.blank? ? [] : multiple ? JSON.parse(champ.value) : [champ.value]
end

View file

@ -1,7 +1,7 @@
- if champ.drop_down_list && champ.drop_down_list.options.any?
= form.select :value,
champ.drop_down_list.options,
{ selected: champ.drop_down_list.selected_options_without_decorator(champ),
{ selected: champ.drop_down_list.selected_options(champ),
disabled: champ.drop_down_list.disabled_options },
multiple: true,
class: 'select2'