lib/ecoportal/api/v2/page/component/selection_field.rb in ecoportal-api-oozes-0.7.3 vs lib/ecoportal/api/v2/page/component/selection_field.rb in ecoportal-api-oozes-0.7.4

- old
+ new

@@ -5,12 +5,11 @@ class Component class SelectionField < Page::Component passthrough :multiple, :flat passthrough :other, :other_desc - #class_resolver :selection_option_class, "Ecoportal::API::V2::Page::Component::SelectionOption" - embeds_multiple :options, klass: "Ecoportal::API::V2::Page::Component::SelectionOption", order_key: :weight + embeds_many :options, klass: "Ecoportal::API::V2::Page::Component::SelectionOption", order_key: :weight def select(value) opt = options.find {|opt| opt.value == value} sel = selected return true if !multiple && opt == sel @@ -33,10 +32,10 @@ selected&.value end end def add_option(name:, value:, pos: NOT_USED, before: NOT_USED, after: NOT_USED) - opt_doc = Ecoportal::API::V2::Page::Component::SelectionOption.new_doc + opt_doc = options.items_class.new_doc options.upsert!(opt_doc, pos: pos, before: before, after: after) do |option| option.name = name option.value = value if prev = previous_option(option) option.weight = prev.weight