'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Content Explorer *| (C) Copyright IBM Corp. 2019 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['../../../lib/@waca/dashboard-common/dist/utils/ContentUtil', 'underscore'], function (ContentUtil, _) { /** * The base class of data point selections actions. The selections are built from brushing or pending filters, * usually as a form of multi-select (using the ctrl/command key or long press). */ var DataPointActionBase = function () { function DataPointActionBase(options) { _classCallCheck(this, DataPointActionBase); options = options || {}; this.dashboard = options.dashboardAPI; this.logger = this.dashboard.getGlassCoreSvc('.Logger'); this.content = options.content; this.globalFilters = this.dashboard.getFeature('GlobalFilters'); this.eventGroups = this.dashboard.getFeature('EventGroups'); this.transaction = this.dashboard.getFeature('Transaction'); } DataPointActionBase.prototype._getLocalFilters = function _getLocalFilters() { if (!this.localFilters) { this.visualization = this.visualization || this.content.getFeature('Visualization'); this.localFilters = this.visualization.getLocalFilters(); } return this.localFilters; }; DataPointActionBase.prototype._getSelector = function _getSelector() { var type = this.dashboard.getAppConfig('pageContainerType'); var page = ContentUtil.getPageContent(this.content, type); return { origin: 'visualization', sourceId: this._getVisualization().getDataSource().getId(), scope: page && page.getId(), eventGroupId: this.eventGroups.getGroupId(this.content.getId()), //use the 'strict match option' and event source to only select brushing entries //that originate from this visualization. eventSourceId: this.content.getId(), _strictMatch: true }; }; DataPointActionBase.prototype._getVisualization = function _getVisualization() { this.visualization = this.visualization || this.content.getFeature('Visualization'); return this.visualization; }; DataPointActionBase.prototype._groupSelections = function _groupSelections(selectionList) { var groupedSelections = {}; if (!selectionList || !selectionList.length) { return; } var columnIdList = null; var tupleList = null; var categoryList = _.pluck(selectionList, 'categories'); categoryList.forEach(function (tuple) { tupleList = []; columnIdList = []; tuple && tuple.forEach(function (value) { columnIdList.push(value.columnId); // TODO Add .u and .d internally until all internal implementation classes (pageContext, filters etc.) use .value and .label. value.u = value.value; value.d = value.label; if (value.parentId) { value.p = { u: value.parentId }; } tupleList.push(value); }); var groupKey = _.uniq(columnIdList).join(); if (!groupedSelections[groupKey]) { groupedSelections[groupKey] = []; } groupedSelections[groupKey].push(tupleList); }); return groupedSelections; }; return DataPointActionBase; }(); return DataPointActionBase; }); //# sourceMappingURL=DataPointActionBase.js.map