Sha256: 3ffa6fec67d2f8c61f8be5512e22a5fa814bfe319db7e5e26f2b89a67fbf49f6

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

module Ecoportal
  module API
    class V2
      class Pages
        class PageStage
          class Task < Ecoportal::API::Common::Content::DoubleModel
            passkey     :id
            passforced  :patch_ver, default: 0

            passthrough :name
            passthrough :user_lookups, :user_ids
            passthrough :strategies, :scheduled_callbacks
            passboolean :historic

            passboolean :complete, :completable
            passdate :due, :complete_at
            passthrough :complete_by_id, :completed_by_name

            passthrough :last_strategy
            passboolean :is_retry, :rejected
            passthrough :retry_reason
            passthrough :rejected_by, :rejected_by_name, :rejected_notes
            passdate :rejected_at

            passboolean :escalated
            passdate :escalated_at

            passboolean :submitted
            passthrough :type
            passthrough :view_type

            def ooze
              self._parent.ooze
            end

            def fill_in?
              type == 'complete_page'
            end

            def review?
              type == 'review_page'
            end

            def complete!(force: false)
              return mark_as_submit(force: force)   if fill_in?
              return mark_as_sign_off(force: force) if review?
            end

            private

            def mark_as_submit(force: false)
              return doc['submitted'] = true unless force

              doc['forced_complete'] = true
            end

            def mark_as_sign_off(force: false)
              return doc['sign_off'] = true unless force

              doc['forced_complete'] = true
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-v2-2.0.12 lib/ecoportal/api/v2/pages/page_stage/task.rb
ecoportal-api-v2-2.0.11 lib/ecoportal/api/v2/pages/page_stage/task.rb
ecoportal-api-v2-2.0.10 lib/ecoportal/api/v2/pages/page_stage/task.rb
ecoportal-api-v2-2.0.9 lib/ecoportal/api/v2/pages/page_stage/task.rb