Module: Ecoportal::API::GraphQL::Concerns::DataFieldAccess
- Included in:
- Interface::BasePage
- Defined in:
- lib/ecoportal/api/graphql/concerns/data_field_access.rb
Overview
Provides typed data field access on page models. Include in Interface::BasePage so all concrete page classes inherit it.
Exposes: page.components — DataField::Collection (v2 compat alias for dataFields) page.field_collection — same, memoized page.data_fields_updates — [DataFieldInput, ...] for dirty fields page.data_fields_additions — [DataFieldInput, ...] for added fields page.data_fields_deletions — [field_id, ...] queued for deletion
Instance Method Summary collapse
-
#components ⇒ Object
v2 compat alias — eco-helpers scripts call entry.components.
-
#data_fields_additions ⇒ Object
Returns DataFieldInput hashes for newly added fields (via components.add).
-
#data_fields_deletions ⇒ Object
Returns field IDs queued for deletion (via components.mark_for_deletion).
- #data_fields_dirty? ⇒ Boolean
-
#data_fields_updates ⇒ Object
Returns DataFieldInput hashes for modified existing fields (updates).
-
#field_collection ⇒ Object
Returns a DataField::Collection wrapping raw dataFields from doc.
-
#section_collection ⇒ Object
Returns a SectionCollection wrapping sections from doc.
-
#sections ⇒ Object
v2 compat alias — eco-helpers scripts call entry.sections.
Instance Method Details
#components ⇒ Object
v2 compat alias — eco-helpers scripts call entry.components
22 23 24 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 22 def components field_collection end |
#data_fields_additions ⇒ Object
Returns DataFieldInput hashes for newly added fields (via components.add).
43 44 45 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 43 def data_fields_additions field_collection.dirty_additions end |
#data_fields_deletions ⇒ Object
Returns field IDs queued for deletion (via components.mark_for_deletion).
48 49 50 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 48 def data_fields_deletions field_collection.dirty_deletions end |
#data_fields_dirty? ⇒ Boolean
52 53 54 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 52 def data_fields_dirty? field_collection.dirty? end |
#data_fields_updates ⇒ Object
Returns DataFieldInput hashes for modified existing fields (updates).
38 39 40 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 38 def data_fields_updates field_collection.dirty_inputs end |
#field_collection ⇒ Object
Returns a DataField::Collection wrapping raw dataFields from doc. Memoized — mutating a field object persists across calls.
17 18 19 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 17 def field_collection @field_collection ||= Base::Page::DataField::Collection.from_doc(raw_data_fields) end |
#section_collection ⇒ Object
Returns a SectionCollection wrapping sections from doc. For BasicPage: doc['sections']. For PhasedPage: merged from stages (override in Phased).
28 29 30 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 28 def section_collection @section_collection ||= Base::Page::SectionCollection.from_doc(raw_sections) end |
#sections ⇒ Object
v2 compat alias — eco-helpers scripts call entry.sections
33 34 35 |
# File 'lib/ecoportal/api/graphql/concerns/data_field_access.rb', line 33 def sections section_collection end |