SlotAPISpec.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define([], function () {
  9. var APISpec = function () {
  10. function APISpec() {
  11. _classCallCheck(this, APISpec);
  12. }
  13. APISpec.prototype.getAPISpec = function getAPISpec() {
  14. var _this = this;
  15. if (!this.apiSpec) {
  16. this.apiSpec = {
  17. name: 'slot API',
  18. features: {
  19. 'Dashboard.Transaction': this.transaction
  20. },
  21. events: {
  22. propagationInfo: {
  23. info: {
  24. slotId: this.getId()
  25. },
  26. callStack: {
  27. name: 'getSlot',
  28. params: [this.getId()]
  29. }
  30. },
  31. actions: {
  32. 'removeDataItemsMapping': {
  33. eventName: 'dataitems:removeMapping',
  34. getInfo: function getInfo(args) {
  35. return {
  36. dataItemIdList: args[0]
  37. };
  38. },
  39. getUndoActions: function getUndoActions(args) {
  40. var undoActions = [];
  41. var ids = args[0];
  42. if (ids) {
  43. var lastIndex = void 0;
  44. ids.forEach(function (id) {
  45. var dataItem = _this.getDataItem(id);
  46. if (dataItem) {
  47. var currentIndex = _this.getDataItemIndex(id);
  48. // add an addColumn reverse action
  49. if (currentIndex !== lastIndex + 1) {
  50. undoActions.push({
  51. name: 'addDataItemsMapping',
  52. params: [[], currentIndex]
  53. });
  54. }
  55. var lastAction = undoActions[undoActions.length - 1];
  56. // add the column id to column ids param
  57. lastAction.params[0].push(dataItem.getId());
  58. lastIndex = currentIndex;
  59. }
  60. });
  61. }
  62. return undoActions;
  63. }
  64. },
  65. 'addDataItemsMapping': {
  66. eventName: 'dataitems:addMapping',
  67. isResolvePostResponse: true,
  68. getInfo: function getInfo(args) {
  69. return {
  70. dataItemIdList: args[0],
  71. position: args[1] || 0
  72. };
  73. },
  74. getUndoActions: function getUndoActions(args) {
  75. return [{
  76. name: 'removeDataItemsMapping',
  77. params: [args[0]]
  78. }];
  79. }
  80. }
  81. }
  82. }
  83. };
  84. }
  85. return this.apiSpec;
  86. };
  87. return APISpec;
  88. }();
  89. return APISpec;
  90. });
  91. //# sourceMappingURL=SlotAPISpec.js.map