diff --git a/app/models/champs/multiple_drop_down_list_champ.rb b/app/models/champs/multiple_drop_down_list_champ.rb index 4b433bdb5..d03065baf 100644 --- a/app/models/champs/multiple_drop_down_list_champ.rb +++ b/app/models/champs/multiple_drop_down_list_champ.rb @@ -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 diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb index 5c3f2757c..182d4721a 100644 --- a/app/models/drop_down_list.rb +++ b/app/models/drop_down_list.rb @@ -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 diff --git a/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml b/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml index 8a49cf26e..1315362e9 100644 --- a/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml +++ b/app/views/shared/dossiers/editable_champs/_multiple_drop_down_list.html.haml @@ -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'