'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: BI Cloud (C) Copyright IBM Corp. 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define([], function () { var APISpec = function () { function APISpec() { _classCallCheck(this, APISpec); } APISpec.prototype.getAPISpec = function getAPISpec() { var _this = this; if (!this.apiSpec) { var lockReverseAction = function lockReverseAction() { var name = void 0; if (_this.isTypeLocked()) { name = 'lockType'; } else { name = 'unlockType'; } return [{ name: name }]; }; this.apiSpec = { name: 'visualization API', features: { 'Dashboard.Transaction': this.transaction }, events: { propagationInfo: { info: { supportsUndoRedo: true, refresh: { dataIfQueryChanged: true } } }, actions: { setDataSource: { eventName: 'dataSource', getUndoActions: function getUndoActions() { var dataSource = _this.getDataSource(); return [{ params: [dataSource ? dataSource.getId() : null] }]; }, isTriggerEvent: function isTriggerEvent(action, undoActions, returnValue) { return returnValue; } }, setType: { info: { supportsUndoRedo: true, refresh: { all: true, // need to refresh all so that we can refresh the visView propertiesPane: true } }, eventName: 'type', getUndoActions: function getUndoActions(args) { var actions = []; actions.push({ name: 'setType', params: [_this.getType()] }); // Get the dataitem that are mappedn to slots that do not exist in the new definition var newDefinition = _this.visDefinitions.getByType(args[0]); if (newDefinition) { var newSlots = newDefinition.getSlotList(); var slotsToBeRemoved = _this.slotsImpl.getSlotList().filter(function (slot) { return !newSlots.find(function (newSlot) { return newSlot.getId() === slot.getId(); }); }); slotsToBeRemoved.forEach(function (slotToBeRemoved) { // Use the internal getDataItemList method and include the option to ignore default slot dataitems // default data items don't need to be tracked in here. var dataItems = _this.slotsImpl.getSlotImpl(slotToBeRemoved.getId()).getDataItemList(true); if (dataItems.length > 0) { actions.push({ callStack: [{ name: 'getSlots', params: [] }, { name: 'getSlot', params: [slotToBeRemoved.getId()] }], name: 'addDataItemsMapping', params: [dataItems.map(function (dataItem) { return dataItem.getId(); }), 0] }); } }); } return actions; } }, lockType: { eventName: 'lockType', getUndoActions: lockReverseAction }, unlockType: { info: { supportsUndoRedo: true, refresh: { all: true // Refresh everything including the visView.. unlocking might change the visType } }, eventName: 'unlockType', getUndoActions: lockReverseAction } } } }; } return this.apiSpec; }; return APISpec; }(); return APISpec; }); //# sourceMappingURL=VisualizationAPISpec.js.map