'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. 2019, 2021 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** * Create a public API to a decorator for the n-th vipr dataset * * @class DecoratorAPI * @hideconstructor * @classdesc */ define([], function () { var APISpec = function () { function APISpec() { _classCallCheck(this, APISpec); } APISpec.prototype.getAPISpec = function getAPISpec() { var _this = this; if (!this.apiSpec) { this.apiSpec = { name: 'slots API', features: { 'Dashboard.Transaction': this.transaction }, events: { propagationInfo: { namespace: 'slots', callStack: { name: 'getSlots' }, info: { supportsUndoRedo: true, refresh: { predictSuggestions: true, keyDrivers: true, dataIfQueryChanged: true } } }, actions: { 'createDataItems': { eventName: 'dataitems:create', isResolvePostResponse: true, getInfo: function getInfo(args) { return { dataItemList: args[0] }; }, getAction: function getAction(args, returnValue) { // Include the id of the created dataItem in the action params.. so that we can recreate with the same id var dataItems = []; args[0].forEach(function (dataItem, index) { dataItems.push({ columnId: dataItem.columnId, id: returnValue[index].getId() }); }); return { params: [dataItems] }; }, getUndoActions: function getUndoActions(args, result) { var undoActions = []; var dataItemIds = result.map(function (dataItem) { return dataItem.getId(); }); undoActions.push({ name: 'deleteDataItems', params: [dataItemIds] }); return undoActions; } }, 'deleteDataItems': { eventName: 'dataitems:delete', getInfo: function getInfo(args, result) { return { dataItemList: result }; }, getUndoActions: function getUndoActions(args) { var undoActions = []; var resultActions = []; var ids = args[0]; var undoParam = []; ids.forEach(function (id) { var dataItem = _this.getDataItemImpl(id); if (dataItem) { undoParam.push({ id: id, columnId: dataItem.getColumnId(), itemLabel: dataItem.getLabel(), navigationPathId: dataItem.getNavigationPathId() }); resultActions.push(dataItem ? dataItem.serializeActions() : []); } else { //If the dataItem doesn't exist, the id should be eliminated - its a no-op. ids = ids.filter(function (thisId) { return thisId !== id; }); } }); if (undoParam.length) { var currentDataItems = _this.getDataItemList(); var dataSource = _this.getDataSource(); if (ids.length === currentDataItems.length && dataSource) { undoActions.push({ callStack: [{ name: '..' }], name: 'setDataSource', params: [dataSource.getId()] }); } undoActions.push({ callStack: [{ name: 'getSlots' }], name: 'createDataItems', params: [undoParam], resultActions: resultActions }); } return undoActions; } } } } }; } return this.apiSpec; }; return APISpec; }(); return APISpec; }); //# sourceMappingURL=SlotsAPISpec.js.map