UnionAPISpec.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // generate a list of action that will restore this union to its current stae
  14. APISpec.prototype.serializeActions = function serializeActions() {
  15. var actions = [];
  16. this.dataItemImplList.forEach(function (dataItemImpl) {
  17. var params = [];
  18. var resultActions = [];
  19. if (dataItemImpl) {
  20. params.push({ columnId: dataItemImpl.getColumnId(), id: dataItemImpl.getId() });
  21. resultActions.push(dataItemImpl.serializeActions());
  22. }
  23. actions.push({
  24. name: 'addDataItem',
  25. params: params,
  26. resultActions: resultActions
  27. });
  28. });
  29. return actions;
  30. };
  31. APISpec.prototype.getAPISpec = function getAPISpec() {
  32. var _this = this;
  33. if (!this.apiSpec) {
  34. this.apiSpec = {
  35. name: 'union API',
  36. events: {
  37. propagationInfo: {
  38. callStack: {
  39. name: 'getUnion',
  40. params: []
  41. }
  42. },
  43. actions: {
  44. addDataItem: {
  45. eventName: 'addUnionDataItem',
  46. isResolvePostResponse: true,
  47. getInfo: function getInfo(args) {
  48. return {
  49. columnId: args[0],
  50. supportsUndoRedo: true,
  51. refresh: {
  52. data: true
  53. }
  54. };
  55. },
  56. getUndoActions: function getUndoActions(args, returnValue) {
  57. var dataItemId = void 0;
  58. if (returnValue) {
  59. dataItemId = returnValue.getId();
  60. }
  61. return [{
  62. name: 'removeDataItem',
  63. params: [dataItemId]
  64. }];
  65. }
  66. },
  67. removeDataItem: {
  68. eventName: 'removeUnionDataItem',
  69. getInfo: function getInfo(args) {
  70. return {
  71. dataItemId: args[0],
  72. supportsUndoRedo: true,
  73. refresh: {
  74. data: true
  75. }
  76. };
  77. },
  78. getUndoActions: function getUndoActions(args) {
  79. var dataItemImpl = _this.getDataItemImpl(args[0]);
  80. var params = [];
  81. var resultActions = [];
  82. if (dataItemImpl) {
  83. params.push({ columnId: dataItemImpl.getColumnId(), id: dataItemImpl.getId() });
  84. resultActions.push(dataItemImpl.serializeActions());
  85. }
  86. return [{
  87. name: 'addDataItem',
  88. params: params,
  89. resultActions: resultActions
  90. }];
  91. }
  92. }
  93. }
  94. }
  95. };
  96. }
  97. return this.apiSpec;
  98. };
  99. return APISpec;
  100. }();
  101. return APISpec;
  102. });
  103. //# sourceMappingURL=UnionAPISpec.js.map