Class: Ecoportal::API::GraphQL::Interface::BasePage
- Inherits:
-
Logic::BaseModel
- Object
- Common::Content::DoubleModel
- Common::GraphQL::Model
- Logic::BaseModel
- Ecoportal::API::GraphQL::Interface::BasePage
- Includes:
- Concerns::DataFieldAccess, Concerns::PageCompat
- Defined in:
- lib/ecoportal/api/graphql/interface/base_page.rb
Direct Known Subclasses
Constant Summary collapse
- DIFF_CLASS =
Page-level leaf arrays (
otherTags, whole-setlocations) are cascaded attributes the default DiffService cannot see. LeafDiffService diffs them inline (full-set replace) while still cascading into real nested models (e.g. a phased page'sstages). See Diffable::LeafDiffService. Ecoportal::API::Common::GraphQL::Model::Diffable::LeafDiffService
Instance Attribute Summary collapse
-
#_compat_source_template_id ⇒ Object
Compat marker (not a server field).
Instance Method Summary collapse
-
#forces ⇒ Object
Returns a Force::Collection wrapping the page's forces array.
-
#location_ids ⇒ Object
Page-level location assignment.
- #location_ids=(ids) ⇒ Object
-
#template ⇒ Object
Deliberately NOT
embeds_one ..., read_only: true, and this is not a style choice:read_onlydoes not keep a mutated child out of the parent's diff. -
#templateContainerUid ⇒ Object
Convenience reader for the cross-version series key — nil unless this page is a template AND the read selected
template { templateContainerUid }(CommonPageUnion does). - #workflow ⇒ Object
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
Methods included from Common::GraphQL::Model::Diffable
Methods included from Common::GraphQL::ClassHelpers
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_id ⇒ Object
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.
83 84 85 |
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 83 def _compat_source_template_id @_compat_source_template_id end |
Instance Method Details
#forces ⇒ Object
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.
66 67 68 |
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 66 def forces @forces ||= Base::Force::Collection.new(doc['forces'] || []) end |
#location_ids ⇒ Object
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).
36 37 38 |
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 36 def location_ids Array(doc['locations']).map { |l| l.is_a?(Hash) ? l['id'] : l }.compact end |
#location_ids=(ids) ⇒ Object
40 41 42 |
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 40 def location_ids=(ids) doc['locations'] = Array(ids).map { |id_val| { 'id' => id_val } } end |
#template ⇒ Object
Deliberately NOT embeds_one ..., read_only: true, and this is not a style choice:
read_only does not keep a mutated child out of the parent's diff. With embeds_one,
page.template.templateContainerUid = 'x' yields
as_update => { id:, template: { templateContainerUid: 'x' } } — but UpdatePageInput
has NO template member, so that would push a key updatePage cannot accept. The
only writer for the series key is the editTemplateContainerUid workflow command.
So this follows the same on-demand read-only pattern as #forces above, over a COPY of
the sub-doc: the returned model is a genuine dead end — writes to it cannot reach
doc, cannot dirty the page, and cannot leak into an update.
100 101 102 103 104 105 106 |
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 100 def template return nil unless (raw = doc['template']) @template ||= template_class.new( Ecoportal::API::Common::GraphQL::HashHelpers.deep_dup(raw) ) end |
#templateContainerUid ⇒ Object
Convenience reader for the cross-version series key — nil unless this page is a
template AND the read selected template { templateContainerUid } (CommonPageUnion
does). Many versions may share one uid; only one may be published at a time.
111 112 113 |
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 111 def templateContainerUid template&.templateContainerUid end |
#workflow ⇒ Object
124 125 126 127 128 |
# File 'lib/ecoportal/api/graphql/interface/base_page.rb', line 124 def workflow return nil unless (raw = doc['workflow']) @workflow ||= pages_workflow_class.new(raw) end |