DataItemAPISpec.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. 2018, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. /**
  9. * Create a public API to a decorator for the n-th vipr dataset
  10. *
  11. * @class DecoratorAPI
  12. * @hideconstructor
  13. * @classdesc
  14. */
  15. define([], function () {
  16. var APISpec = function () {
  17. function APISpec() {
  18. _classCallCheck(this, APISpec);
  19. }
  20. APISpec.prototype.getAPISpec = function getAPISpec() {
  21. var _this = this;
  22. if (!this.apiSpec) {
  23. var drillGetUndoActions = function drillGetUndoActions() {
  24. var actionName = void 0;
  25. var params = void 0;
  26. var drillDown = _this.getDrillDownValue();
  27. var drillUp = _this.getDrillUpValue();
  28. if (!drillDown && !drillUp) {
  29. actionName = 'clearDrill';
  30. params = [];
  31. } else if (drillDown) {
  32. actionName = 'drillDown';
  33. params = [drillDown];
  34. } else if (drillUp) {
  35. actionName = 'drillUp';
  36. params = [drillUp];
  37. }
  38. return [{
  39. name: actionName,
  40. params: params
  41. }];
  42. };
  43. this.apiSpec = {
  44. name: 'dataitem API',
  45. features: {
  46. 'Dashboard.Transaction': this.transaction
  47. },
  48. events: {
  49. serializeActions: {
  50. children: [{
  51. getObject: function getObject() {
  52. return _this.unionImpl;
  53. },
  54. callStack: [{
  55. name: 'getUnion',
  56. params: []
  57. }]
  58. }]
  59. },
  60. propagationInfo: {
  61. namespace: this.isRootDataItem() ? 'dataitem' : null,
  62. info: {
  63. dataItemId: this.getId()
  64. },
  65. callStack: {
  66. name: 'getDataItem',
  67. params: [this.getId()]
  68. }
  69. },
  70. actions: {
  71. // This action is currently not exposed as a dataItem API . Will only be exposed when needed
  72. // setLabel: {
  73. // eventName:'label',
  74. // info:{
  75. // refresh: { render: true }
  76. // },
  77. // getUndoActions: () => [{ params:[this.dataItemModel.itemLabel] }]
  78. // },
  79. setAggregation: {
  80. eventName: 'aggregation',
  81. getUndoActions: function getUndoActions() {
  82. return [{ params: [_this.hasDefaultAggregation() ? undefined : _this.getAggregation()] }];
  83. },
  84. autoCreateTransaction: true,
  85. transactionParamIndex: 1,
  86. transactionAPI: this.transaction
  87. },
  88. setFormat: {
  89. eventName: 'format',
  90. info: {
  91. refresh: { data: true /* TODO: livewidget_cleanup - should not refresh data, but for some reason the data format change is not rendered properly without data refresh*/
  92. } },
  93. getUndoActions: function getUndoActions() {
  94. return [{ params: [_this.hasDefaultFormat() ? undefined : _this.getFormat()] }];
  95. }
  96. },
  97. setSort: {
  98. eventName: 'sort',
  99. transactionParamIndex: 1,
  100. getUndoActions: function getUndoActions() {
  101. return [{ params: [_this.hasDefaultSort() ? undefined : _this.getSort()] }];
  102. }
  103. },
  104. setTopBottom: {
  105. eventName: 'topbottom',
  106. getUndoActions: function getUndoActions() {
  107. return [{ params: [_this.getTopBottom()] }];
  108. },
  109. autoCreateTransaction: true,
  110. transactionParamIndex: 1,
  111. transactionAPI: this.transaction
  112. },
  113. setBinning: {
  114. eventName: 'binning',
  115. getUndoActions: function getUndoActions() {
  116. return [{ params: [_this.getBinning()] }];
  117. },
  118. autoCreateTransaction: true,
  119. transactionParamIndex: 1,
  120. transactionAPI: this.transaction
  121. },
  122. drillUp: {
  123. eventName: 'drillUp',
  124. getUndoActions: drillGetUndoActions,
  125. autoCreateTransaction: true,
  126. transactionParamIndex: 1,
  127. transactionAPI: this.transaction
  128. },
  129. drillDown: {
  130. eventName: 'drillDown',
  131. getUndoActions: drillGetUndoActions,
  132. autoCreateTransaction: true,
  133. transactionParamIndex: 1,
  134. transactionAPI: this.transaction
  135. },
  136. clearDrill: {
  137. eventName: 'clearDrill',
  138. getUndoActions: drillGetUndoActions,
  139. autoCreateTransaction: true,
  140. transactionParamIndex: 0,
  141. transactionAPI: this.transaction
  142. }
  143. }
  144. }
  145. };
  146. }
  147. return this.apiSpec;
  148. };
  149. return APISpec;
  150. }();
  151. return APISpec;
  152. });
  153. //# sourceMappingURL=DataItemAPISpec.js.map