Sha256: 514ab4c8215f3e648ce226be76294e109dfbf57ee139c6468a54ecea2f78ae9d

Contents?: true

Size: 1.34 KB

Versions: 77

Compression:

Stored size: 1.34 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require_relative 'dashboard_item'

module GoodData
  class HeadlineItem < DashboardItem
    EMPTY_OBJECT = {
      'headlineItem' => {
        'positionX' => 0,
        'sizeY' => 200,
        'sizeX' => 300,
        'positionY' => 0
      }
    }

    ASSIGNABLE_MEMBERS = DashboardItem::ASSIGNABLE_MEMBERS + [
      :id,
      :metric,
      :linked_with_external_filter
    ]

    class << self
      def create(tab, item)
        res = GoodData::HeadlineItem.new(tab, GoodData::Helpers.deep_dup(GoodData::Helpers.stringify_keys(EMPTY_OBJECT)))
        item.each do |k, v|
          res.send("#{k}=", v) if ASSIGNABLE_MEMBERS.include? k
        end
        res
      end
    end

    def initialize(tab, json)
      super
    end

    def metric
      data['metric']
    end

    def metric=(new_metric)
      data['metric'] = new_metric.respond_to?(:uri) ? new_metric.uri : new_metric
    end

    def linked_with_external_filter
      data['linkedWithExternalFilter']
    end

    def linked_with_external_filter=(new_linked_with_external_filter)
      data['linked_with_external_filter'] = new_linked_with_external_filter ? 1 : 0
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.3.1 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.3.0-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.3.0 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.2.0-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.2.0 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.19-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.19 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.17-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.17 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.15-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.15 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.14-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.14 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.13-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.13 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.12-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.12 lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.11-java lib/gooddata/models/metadata/dashboard/headline_item.rb
gooddata-2.1.11 lib/gooddata/models/metadata/dashboard/headline_item.rb