Sha256: 2e6ca48e31f4877d1c88e4723b02d59e1ff8396fe177e4819332ebea2747d51c

Contents?: true

Size: 1.97 KB

Versions: 77

Compression:

Stored size: 1.97 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'
require_relative '../../../helpers/global_helpers'

module GoodData
  class ReportItem < DashboardItem
    EMPTY_OBJECT = {
      :reportItem => {
        :obj => nil,
        :sizeY => 200,
        :sizeX => 300,
        :style => {
          :displayTitle => 1,
          :background => {
            :opacity => 0
          }
        },
        :visualization => {
          :grid => {
            :columnWidths => []
          },
          :oneNumber => {
            :labels => {}
          }
        },
        :positionY => 0,
        :filters => [],
        :positionX => 0
      }
    }

    ASSIGNABLE_MEMBERS = DashboardItem::ASSIGNABLE_MEMBERS + [
      :filters,
      :obj,
      :report,
      :style,
      :visualization
    ]

    class << self
      def obj_uri(obj)
        obj.respond_to?(:uri) ? obj.uri : obj
      end

      def create(tab, item)
        res = GoodData::ReportItem.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 obj
      GoodData::MdObject[data['obj'], :client => tab.dashboard.client, :project => tab.dashboard.project]
    end

    alias_method :object, :obj

    def obj=(new_obj)
      data['obj'] = ReportItem.obj_uri(new_obj)
    end

    alias_method :object=, :obj=
    alias_method :report=, :obj=

    def style
      data['style']
    end

    def style=(new_style)
      data['style'] = new_style
    end

    def visualization
      data['visualization']
    end

    def visualization=(new_visualization)
      data['visualization'] = new_visualization
    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/report_item.rb
gooddata-2.3.1 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.3.0-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.3.0 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.2.0-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.2.0 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.19-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.19 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.17-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.17 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.15-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.15 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.14-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.14 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.13-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.13 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.12-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.12 lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.11-java lib/gooddata/models/metadata/dashboard/report_item.rb
gooddata-2.1.11 lib/gooddata/models/metadata/dashboard/report_item.rb