class Ecoportal::API::V2::Page::Component
Public Class Methods
get_class(doc)
click to toggle source
# File lib/ecoportal/api/v2/page/component.rb, line 38 def get_class(doc) if doc.is_a?(Hash) case doc["type"] when "tag_field" tag_field_class when "geo" geo_field_class when "select" selection_field_class when "date" date_field_class when "number" number_field_class when "gauge" gauge_field_class when "plain_text" plain_text_field_class when "rich_text" rich_text_field_class when "people" people_field_class when "checklist" checklist_field_class when "page_action","checklist_task" #doc["type"] = "checklist_task" action_field_class when "file" files_field_class when "image_gallery" images_field_class when "signature" signature_field_class when "cross_reference" reference_field_class when "law" law_field_class when "chart" chart_field_class when "frequency_rate_chart" chart_fr_field_class else self end end end
new_doc(type: nil)
click to toggle source
# File lib/ecoportal/api/v2/page/component.rb, line 28 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
Public Instance Methods
indexable_label()
click to toggle source
# File lib/ecoportal/api/v2/page/component.rb, line 106 def indexable_label self.class.indexable_label(label) end
ref()
click to toggle source
# File lib/ecoportal/api/v2/page/component.rb, line 96 def ref if digest = self.class.hash_label(label) [type, digest].join(".") end end
ref_backend()
click to toggle source
# File lib/ecoportal/api/v2/page/component.rb, line 92 def ref_backend refs.first end
section()
click to toggle source
# File lib/ecoportal/api/v2/page/component.rb, line 102 def section root.sections.find {|sec| sec.component?(id)} end