12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- '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: Dashboard
- * (C) Copyright IBM Corp. 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- /**
- * @class PendingSelections
- * @hideconstructor
- */
- define(['underscore', '../../../../apiHelpers/SlotAPIHelper'], function (_, SlotAPIHelper) {
- var PendingSelections = function () {
- function PendingSelections() {
- _classCallCheck(this, PendingSelections);
- this._pendingSelections = [];
- }
- PendingSelections.prototype.select = function select(selections) {
- var _this = this;
- _.each(selections, function (selection) {
- var isPending = _.find(_this._pendingSelections, function (p) {
- return _.isEqual(p, selection);
- });
- if (!isPending) {
- _this._pendingSelections.push(selection);
- }
- });
- };
- PendingSelections.prototype.deselect = function deselect(selections) {
- var _this2 = this;
- _.each(selections, function (selection) {
- var index = _.findIndex(_this2._pendingSelections, function (p) {
- return _.isEqual(p, selection);
- });
- if (index > -1) {
- _this2._pendingSelections.splice(index, 1);
- }
- });
- };
- PendingSelections.prototype.clearAll = function clearAll() {
- this._pendingSelections.length = 0;
- };
- PendingSelections.prototype.getSelections = function getSelections() {
- var selectedDataItemList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- var catDataItemList = _.filter(selectedDataItemList, function (dataItem) {
- return dataItem.getType() === 'attribute' && SlotAPIHelper.MULTI_MEASURES_SERIES !== dataItem.getColumnId();
- });
- var selectDataItemIds = _.map(catDataItemList, function (dataItem) {
- return dataItem.getId();
- });
- return _.filter(this._pendingSelections, function (selection) {
- return _.every(selectDataItemIds, function (dataItemId) {
- return _.find(selection.categories, function (cat) {
- return cat.dataItemId === dataItemId;
- });
- });
- });
- };
- PendingSelections.prototype.isSelected = function isSelected(selections) {
- var _this3 = this;
- return !!_.every(selections, function (selection) {
- return !!_.find(_this3._pendingSelections, function (p) {
- return _.isEqual(p, selection);
- });
- });
- };
- return PendingSelections;
- }();
- return PendingSelections;
- });
- //# sourceMappingURL=PendingSelections.js.map
|