123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- '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
|