module Ecoportal module API class V2 class Page class Component < Common::Content::DoubleModel extend Ecoportal::API::Common::Content::StringDigest class_resolver :tag_field_class, "Ecoportal::API::V2::Page::Component::TagField" class_resolver :geo_field_class, "Ecoportal::API::V2::Page::Component::GeoField" class_resolver :selection_field_class, "Ecoportal::API::V2::Page::Component::SelectionField" class_resolver :date_field_class, "Ecoportal::API::V2::Page::Component::DateField" class_resolver :number_field_class, "Ecoportal::API::V2::Page::Component::NumberField" class_resolver :gauge_field_class, "Ecoportal::API::V2::Page::Component::GaugeField" class_resolver :plain_text_field_class, "Ecoportal::API::V2::Page::Component::PlainTextField" class_resolver :rich_text_field_class, "Ecoportal::API::V2::Page::Component::RichTextField" class_resolver :people_field_class, "Ecoportal::API::V2::Page::Component::PeopleField" class_resolver :checklist_field_class, "Ecoportal::API::V2::Page::Component::ChecklistField" class_resolver :action_field_class, "Ecoportal::API::V2::Page::Component::ActionField" class_resolver :files_field_class, "Ecoportal::API::V2::Page::Component::FilesField" class_resolver :images_field_class, "Ecoportal::API::V2::Page::Component::ImagesField" class_resolver :signature_field_class, "Ecoportal::API::V2::Page::Component::SignatureField" class_resolver :reference_field_class, "Ecoportal::API::V2::Page::Component::ReferenceField" class_resolver :law_field_class, "Ecoportal::API::V2::Page::Component::LawField" class << self def new_doc(type:) { "id" => new_uuid, "type" => type } end 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" 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 else self end end end end passkey :id passthrough :patch_ver, :undeletable passthrough :type, :label, :tooltip, :global_binding passthrough :hidden, :accent, :deindex passthrough :hide_view, :hidden_on_reports, :hidden_on_mobile def ref if digest = self.class.hash_label(label) [type, digest].join(".") end end def section root.sections.find {|sec| sec.component?(id)} end def indexable_label self.class.indexable_label(label) end end end end end end require 'ecoportal/api/v2/page/component/tag_field' require 'ecoportal/api/v2/page/component/geo_field' require 'ecoportal/api/v2/page/component/selection_field' require 'ecoportal/api/v2/page/component/date_field' require 'ecoportal/api/v2/page/component/number_field' require 'ecoportal/api/v2/page/component/gauge_field' require 'ecoportal/api/v2/page/component/plain_text_field' require 'ecoportal/api/v2/page/component/rich_text_field' require 'ecoportal/api/v2/page/component/people_field' require 'ecoportal/api/v2/page/component/checklist_field' require 'ecoportal/api/v2/page/component/action_field' require 'ecoportal/api/v2/page/component/files_field' require 'ecoportal/api/v2/page/component/images_field' require 'ecoportal/api/v2/page/component/signature_field' require 'ecoportal/api/v2/page/component/reference_field' require 'ecoportal/api/v2/page/component/law_field'