lib/ecoportal/api/v2/page/component.rb in ecoportal-api-oozes-0.7.4 vs lib/ecoportal/api/v2/page/component.rb in ecoportal-api-oozes-0.7.5
- old
+ new
@@ -23,15 +23,18 @@
class_resolver :law_field_class, "Ecoportal::API::V2::Page::Component::LawField"
class_resolver :chart_field_class, "Ecoportal::API::V2::Page::Component::ChartField"
class_resolver :chart_fr_field_class, "Ecoportal::API::V2::Page::Component::ChartFrField"
class << self
- def new_doc(type:)
- {
- "id" => new_uuid,
- "type" => type
- }
+ def new_doc(type: nil)
+ if type
+ type_doc = {"type" => type}
+ base_doc = get_class(type_doc)&.new_doc || {}
+ base_doc.merge!(type_doc)
+ end
+ return base_doc if base_doc&.key?("id")
+ (base_doc || {}).merge("id" => new_uuid)
end
def get_class(doc)
if doc.is_a?(Hash)
case doc["type"]
@@ -82,9 +85,14 @@
passkey :id
passthrough :patch_ver, :undeletable
passthrough :type, :label, :tooltip, :global_binding
passthrough :hidden, :accent, :deindex, :required
passthrough :hide_view, :hidden_on_reports, :hidden_on_mobile
+ passarray :refs
+
+ def ref_backend
+ refs.first
+ end
def ref
if digest = self.class.hash_label(label)
[type, digest].join(".")
end