Class: Ecoportal::API::GraphQL::Interface::BasePage

Inherits:
Logic::BaseModel show all
Includes:
Concerns::DataFieldAccess, Concerns::PageCompat
Defined in:
lib/ecoportal/api/graphql/interface/base_page.rb

Direct Known Subclasses

Base::Page::Basic, Base::Page::Phased

Constant Summary

Constants included from Common::GraphQL::Model::Diffable

Common::GraphQL::Model::Diffable::DIFF_CLASS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::DataFieldAccess

#components, #data_fields_additions, #data_fields_deletions, #data_fields_dirty?, #data_fields_updates, #field_collection, #section_collection, #sections

Methods included from Concerns::PageCompat

#components, #consolidate!, #dirty?, #external_id, #stages?, #template_id, #validate

Methods included from Concerns::SnakeCamelAccess

#method_missing, #respond_to_missing?

Methods included from Common::GraphQL::Model::AsInput

#as_input

Methods included from Common::GraphQL::Model::Diffable

#as_update, #dirty?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ecoportal::API::GraphQL::Concerns::SnakeCamelAccess

Instance Attribute Details

#_compat_source_template_idObject

Compat marker (not a server field). Compat::Pages#get_new records the source template id here when it builds a draft from a template — the read fragment does NOT fetch sourceTemplateId, so the model can't recover it from the doc. Lets the dry-run know this is a never-saved CREATE draft (a built draft DOES carry a patchVer, so patchVer-nil alone can't detect it) and supplies the templateId for the CreateFromTemplateInput preview. nil for fetched/persisted pages.



79
80
81
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 79

def _compat_source_template_id
  @_compat_source_template_id
end

Instance Method Details

#forcesObject

Returns a Force::Collection wrapping the page's forces array. Forces are only populated when the query includes the ForceFields fragment (e.g. via Query::PageWithForces — used by OozeRedirect::ForceCompat). Returns an empty collection when forces were not queried.



62
63
64
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 62

def forces
  @forces ||= Base::Force::Collection.new(doc['forces'] || [])
end

#location_idsObject

Page-level location assignment. Locations are set on the PAGE (UpdatePageInput.page .locations = [LocationInputid]) — NOT via the location data field (LocationFieldInput has no value). The locations embed above is read_only, so write the raw doc here so as_update serialises it under PAGE_FIELD_KEYS (:locations).



31
32
33
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 31

def location_ids
  Array(doc['locations']).map { |l| l.is_a?(Hash) ? l['id'] : l }.compact
end

#location_ids=(ids) ⇒ Object



35
36
37
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 35

def location_ids=(ids)
  doc['locations'] = Array(ids).map { |id_val| { 'id' => id_val } }
end

#workflowObject



91
92
93
94
95
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 91

def workflow
  return nil unless (raw = doc['workflow'])

  @workflow ||= pages_workflow_class.new(raw)
end