'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, 2020 * 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 Events = function () { function Events() { _classCallCheck(this, Events); } Events.prototype.getAPISpec = function getAPISpec() { var _this = this; if (!this.apiSpec) { this.apiSpec = { name: 'content API', events: { propagationInfo: { namespace: 'content', info: { contentId: this.getId() }, callStack: { name: 'getContent', params: [this.getId()] } }, actions: { addContent: { eventName: 'child', type: 'add', isResolvePostResponse: true, transactionAPI: this.transaction, transactionParamIndex: 1, autoCreateTransaction: true, getInfo: function getInfo(args, returnValue) { return { value: args[0], newContentId: returnValue.getId(), parentId: returnValue.getContainer().getId(), supportsUndoRedo: true }; }, getAction: function getAction(args, returnValue) { // TODO: ideally should not need to do a copy here, it should be supported by APIFactory // https://github.ibm.com/BusinessAnalytics/dashboard-common/blob/master/src/core/APIFactory.js#L89 // or // https://github.ibm.com/BusinessAnalytics/dashboard-common/blob/master/src/core/APIFactory.js#L108 var options = JSON.parse(JSON.stringify(args[0])); if (options.spec) { options.spec = returnValue.getFeature('Serializer').toJSON(); } options.modelIdsValid = true; return { name: 'addContent', params: [options] }; }, getUndoActions: function getUndoActions(args, content) { void args; return [{ name: 'removeContent', params: content ? [content.getId()] : [] }]; } }, removeContent: { eventName: 'child', type: 'remove', isResolvePostResponse: false, transactionParamIndex: 1, transactionAPI: this.transaction, autoCreateTransaction: true, getInfo: function getInfo(args) { return { value: args[0], supportsUndoRedo: true }; }, getUndoActions: function getUndoActions(args) { var dashboardAPI = _this.dashboardFeatures.getFeature('API'); var content = dashboardAPI.getCanvas().getContent(args[0]); if (content) { var param = { containerId: content.getContainer().getId(), spec: content.getFeature('Serializer').toJSON(), modelIdsValid: true }; var position = _this.getContentPosition(args[0]); if (position !== -1) { param.position = position; } return [{ name: 'addContent', params: [param] }]; } else { return []; } } }, setPropertyValue: { eventName: 'property', getEventName: function getEventName(args) { return 'property:' + args[0]; }, getInfo: function getInfo(args) { var info = { name: args[0], value: args[1], supportsUndoRedo: true }; if (args[2]) { info.options = JSON.parse(JSON.stringify(args[2])); } var property = _this.getPropertyList().find(function (property) { return property.id === args[0]; }); if (property) { if (property.onPropertyChange && property.onPropertyChange.refresh) { info.refresh = property.onPropertyChange.refresh; } else { info.refresh = {}; } } return info; }, getUndoActions: function getUndoActions(args) { return [{ params: [args[0], _this.getPropertyValue(args[0])] }]; } } } } }; } return this.apiSpec; }; return Events; }(); return Events; }); //# sourceMappingURL=ContentAPISpec.js.map