Class: Ecoportal::API::V2::Page
- Inherits:
-
Common::Content::DoubleModel
- Object
- Common::BaseModel
- Common::Content::DoubleModel
- Ecoportal::API::V2::Page
- Defined in:
- lib/ecoportal/api/v2/page.rb,
lib/ecoportal/api/v2/page/force.rb,
lib/ecoportal/api/v2/page/stage.rb,
lib/ecoportal/api/v2/page/forces.rb,
lib/ecoportal/api/v2/page/permit.rb,
lib/ecoportal/api/v2/page/stages.rb,
lib/ecoportal/api/v2/page/section.rb,
lib/ecoportal/api/v2/page/sections.rb,
lib/ecoportal/api/v2/page/component.rb,
lib/ecoportal/api/v2/page/components.rb,
lib/ecoportal/api/v2/page/force/helper.rb,
lib/ecoportal/api/v2/page/component/law.rb,
lib/ecoportal/api/v2/page/force/binding.rb,
lib/ecoportal/api/v2/page/mould_counter.rb,
lib/ecoportal/api/v2/page/component/file.rb,
lib/ecoportal/api/v2/page/force/bindings.rb,
lib/ecoportal/api/v2/page/component/image.rb,
lib/ecoportal/api/v2/page/component/action.rb,
lib/ecoportal/api/v2/page/permission_flags.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/chart_field.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/actions_field.rb,
lib/ecoportal/api/v2/page/component/mailbox_field.rb,
lib/ecoportal/api/v2/page/component/chart_fr_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/geo_coordinates.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,
lib/ecoportal/api/v2/page/component/chart_field/serie.rb,
lib/ecoportal/api/v2/page/component/selection_options.rb,
lib/ecoportal/api/v2/page/component/chart_field/config.rb,
lib/ecoportal/api/v2/page/component/chart_field/sankey.rb,
lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb,
lib/ecoportal/api/v2/page/component/chart_field/benchmark.rb,
lib/ecoportal/api/v2/page/component/chart_field/frequency.rb,
lib/ecoportal/api/v2/page/component/chart_field/indicator.rb,
lib/ecoportal/api/v2/page/component/people_viewable_field.rb,
lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb,
lib/ecoportal/api/v2/page/component/chart_field/series_config.rb,
lib/ecoportal/api/v2/page/component/contractor_entities_field.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Component, Components, Force, Forces, MouldCounter, PermissionFlags, Permit, Section, Sections, Stage, Stages
Constant Summary collapse
- ALLOWED_KEYS =
%w[ id external_id patch_ver name template_id base_tags tags time_zone created_at updated_at components sections stages permits mould_counter mould state task_priority votes_enabled upvotes downvotes forces force_errors subtags tasks ].freeze
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
Instance Method Summary collapse
- #as_update ⇒ Object
-
#initialize(doc = [], parent: self, key: nil) ⇒ Page
constructor
A new instance of Page.
- #ooze ⇒ Object
- #stages? ⇒ Boolean
-
#validate ⇒ String
With feedback, if for this page instance, there are any of: 1.
Methods inherited from Common::Content::DoubleModel
#_doc_key, #as_json, #consolidate!, #dirty?, #doc, embeds_many, embeds_one, enforce!, #key, #key=, key?, new_uuid, #original_doc, pass_reader, pass_writer, passarray, passboolean, passdate, passforced, passkey, passthrough, #print_pretty, read_only!, read_only?, #read_only?, #replace_doc, #reset!, #resolved_doc_key, #root, #to_json
Methods included from Common::Content::ClassHelpers
#inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant, #to_time, #uid, #used_param?
Constructor Details
#initialize(doc = [], parent: self, key: nil) ⇒ Page
Returns a new instance of Page.
36 37 38 |
# File 'lib/ecoportal/api/v2/page.rb', line 36 def initialize(doc = [], parent: self, key: nil) super(_doc_bug_fix(doc), parent: parent, key: key) end |
Instance Method Details
#as_update ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ecoportal/api/v2/page.rb', line 44 def as_update super.tap do |hash| next unless hash hash["data"].select! do |key, _value| ALLOWED_KEYS.include?(key) end return nil if (hash["data"].keys - ["patch_ver"]).empty? end end |
#ooze ⇒ Object
40 41 42 |
# File 'lib/ecoportal/api/v2/page.rb', line 40 def ooze self end |
#stages? ⇒ Boolean
56 57 58 |
# File 'lib/ecoportal/api/v2/page.rb', line 56 def stages? doc["stages"] && stages.count.positive? end |
#validate ⇒ String
Returns with feedback, if for this page instance, there are any of:
- components multi-section (fields belonging to more than one section).
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ecoportal/api/v2/page.rb', line 62 def validate multi = components.multi_section return true unless multi.length.positive? msg = "" msg << "There are fields attached to more than one section:" msg << "\n • " msg << multi.map(&:label).join("\n • ") msg << "\n" msg end |