Class: Ecoportal::API::V2::Page::Component

Inherits:
Common::Content::DoubleModel show all
Extended by:
Common::Content::StringDigest
Defined in:
lib/ecoportal/api/v2/page/component.rb,
lib/ecoportal/api/v2/page/component/file.rb,
lib/ecoportal/api/v2/page/component/image.rb,
lib/ecoportal/api/v2/page/component/action.rb,
lib/ecoportal/api/v2/page/component/geo_field.rb,
lib/ecoportal/api/v2/page/component/law_field.rb,
lib/ecoportal/api/v2/page/component/tag_field.rb,
lib/ecoportal/api/v2/page/component/date_field.rb,
lib/ecoportal/api/v2/page/component/gauge_stop.rb,
lib/ecoportal/api/v2/page/component/files_field.rb,
lib/ecoportal/api/v2/page/component/gauge_field.rb,
lib/ecoportal/api/v2/page/component/action_field.rb,
lib/ecoportal/api/v2/page/component/images_field.rb,
lib/ecoportal/api/v2/page/component/number_field.rb,
lib/ecoportal/api/v2/page/component/people_field.rb,
lib/ecoportal/api/v2/page/component/checklist_item.rb,
lib/ecoportal/api/v2/page/component/checklist_field.rb,
lib/ecoportal/api/v2/page/component/reference_field.rb,
lib/ecoportal/api/v2/page/component/rich_text_field.rb,
lib/ecoportal/api/v2/page/component/selection_field.rb,
lib/ecoportal/api/v2/page/component/signature_field.rb,
lib/ecoportal/api/v2/page/component/plain_text_field.rb,
lib/ecoportal/api/v2/page/component/selection_option.rb

Defined Under Namespace

Classes: Action, ActionField, ChecklistField, ChecklistItem, DateField, File, FilesField, GaugeField, GaugeStop, GeoField, Image, ImagesField, LawField, NumberField, PeopleField, PlainTextField, ReferenceField, RichTextField, SelectionField, SelectionOption, SignatureField, TagField

Constant Summary

Constants included from Common::Content::StringDigest

Common::Content::StringDigest::MAX_HASH_LABEL

Constants inherited from Common::Content::DoubleModel

Common::Content::DoubleModel::NOT_USED

Constants included from Common::Content::ClassHelpers

Common::Content::ClassHelpers::NOT_USED

Instance Attribute Summary

Attributes inherited from Common::Content::DoubleModel

#_key, #_parent

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::Content::StringDigest

hash_label

Methods inherited from Common::Content::DoubleModel

#_doc_key, #as_json, #as_update, #consolidate!, #dirty?, #doc, embeds_multiple, embeds_one, #initialize, #key, #key=, key?, new_uuid, #original_doc, pass_reader, pass_writer, passarray, passdate, passkey, passthrough, #pretty_print, #replace_doc, #reset!, #root, #to_json

Methods included from Common::Content::ClassHelpers

#instance_variable_name, #new_class, #resolve_class, #to_constant, #to_time, #used_param?

Constructor Details

This class inherits a constructor from Ecoportal::API::Common::Content::DoubleModel

Class Method Details

.get_class(doc) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ecoportal/api/v2/page/component.rb', line 33

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
    else
      self
    end
  end
end

.new_doc(type:) ⇒ Object



26
27
28
29
30
31
# File 'lib/ecoportal/api/v2/page/component.rb', line 26

def new_doc(type:)
  {
    "id"   => new_uuid,
    "type" => type
  }
end

Instance Method Details

#indexable_labelObject



92
93
94
# File 'lib/ecoportal/api/v2/page/component.rb', line 92

def indexable_label
  self.class.indexable_label(label)
end

#refObject



82
83
84
85
86
# File 'lib/ecoportal/api/v2/page/component.rb', line 82

def ref
  if digest = self.class.hash_label(label)
    [type, digest].join(".")
  end
end

#sectionObject



88
89
90
# File 'lib/ecoportal/api/v2/page/component.rb', line 88

def section
  root.sections.find {|sec| sec.component?(id)}
end