CanvasAPISpec.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. /**
  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 Events = function () {
  17. function Events(options) {
  18. _classCallCheck(this, Events);
  19. this.transaction = options.dashboardFeatures.getFeature('Transaction');
  20. }
  21. Events.prototype.getAPISpec = function getAPISpec() {
  22. var _this = this;
  23. if (!this.apiSpec) {
  24. this.apiSpec = {
  25. name: 'canvas api',
  26. features: {
  27. 'Dashboard.Transaction': this.transaction
  28. },
  29. events: {
  30. propagationInfo: {
  31. namespace: 'canvas',
  32. callStack: {
  33. name: 'getCanvas'
  34. }
  35. },
  36. actions: {
  37. selectContent: {
  38. eventName: 'selections:select',
  39. getInfo: function getInfo(args) {
  40. return {
  41. value: args[0]
  42. };
  43. },
  44. getUndoActions: function getUndoActions(args) {
  45. return [{
  46. name: 'deselectContent',
  47. params: [args[0]]
  48. }];
  49. }
  50. },
  51. deselectContent: {
  52. eventName: 'selections:deselect',
  53. getInfo: function getInfo(args) {
  54. return {
  55. value: args[0]
  56. };
  57. },
  58. getUndoActions: function getUndoActions(args) {
  59. return [{
  60. name: 'selectContent',
  61. params: [args[0]]
  62. }];
  63. }
  64. },
  65. moveContent: {
  66. type: 'move',
  67. eventName: 'content',
  68. transactionParamIndex: 2,
  69. transactionAPI: this.transaction,
  70. autoCreateTransaction: true,
  71. getInfo: function getInfo(args) {
  72. return {
  73. containerId: args[0],
  74. contentIdList: args[1],
  75. supportsUndoRedo: true
  76. };
  77. },
  78. getUndoActions: function getUndoActions(args) {
  79. var contentIdList = args[1];
  80. var undoActions = [];
  81. if (contentIdList) {
  82. contentIdList.forEach(function (id) {
  83. // get the current parent
  84. undoActions.push({
  85. name: 'moveContent',
  86. params: [_this.getContent(id).getContainer().getId(), [id]]
  87. });
  88. });
  89. }
  90. return undoActions;
  91. }
  92. },
  93. setPropertyValue: {
  94. eventName: 'property',
  95. getEventName: function getEventName(args) {
  96. return 'property:' + args[0];
  97. },
  98. getInfo: function getInfo(args) {
  99. var property = _this._propertiesMap && _this._propertiesMap[args[0]];
  100. if (!property) {
  101. property = _this._getProperty(args[0]);
  102. }
  103. var info = {
  104. name: args[0],
  105. value: args[1],
  106. supportsUndoRedo: !!(property && property.supportsUndoRedo)
  107. };
  108. if (args[2]) {
  109. info.options = JSON.parse(JSON.stringify(args[2]));
  110. }
  111. return info;
  112. },
  113. getUndoActions: function getUndoActions(args) {
  114. return [{ params: [args[0], _this.getPropertyValue(args[0])] }];
  115. }
  116. }
  117. }
  118. }
  119. };
  120. }
  121. return this.apiSpec;
  122. };
  123. return Events;
  124. }();
  125. return Events;
  126. });
  127. //# sourceMappingURL=CanvasAPISpec.js.map