CanvasAPI.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 Business Analytics (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. * @interface CanvasAPI
  10. * @hideconstructor
  11. * @classdesc API class that is used to control the content and behavior of a dashboard canvas.
  12. * @example dashboard.getFeature('Canvas')
  13. */
  14. define([], function () {
  15. var CanvasAPI = function () {
  16. function CanvasAPI() {
  17. _classCallCheck(this, CanvasAPI);
  18. }
  19. /**
  20. * @description Registers a canvas event handler.
  21. * @function CanvasAPI#on
  22. * @param {String} name Event name
  23. * @param {Function} handler Event handler
  24. * @return {Object} Object that has a remove function to remove the event handler.
  25. * @example
  26. * canvas.on('all', (event) => { console.log(event); });
  27. * canvas.on('change:content:selections', (event) => { console.log(event.info.events); });
  28. * canvas.on('change:content:selections:clearAll', (event) => { console.log(event); });
  29. */
  30. CanvasAPI.prototype.on = function on() {};
  31. /**
  32. * @description Deregisters a canvas event handler.
  33. * @function CanvasAPI#off
  34. * @public
  35. *
  36. * @param {String} name Event name
  37. * @param {Function} name Event handler
  38. *
  39. */
  40. CanvasAPI.prototype.off = function off() {};
  41. /**
  42. * @function CanvasAPI#addContent
  43. * @description Adds content options to the canvas.
  44. * @param {Object} options Contains the options for adding content to the canvas.
  45. * @param {String} options.containerId Container ID specifying where to add the content. By default, the system selects the position.
  46. * @param {Number} options.position Index specifying where to add the content. By default, the system selects the position.
  47. * @param {Object} options.properties An object of property names and values to apply to the content.
  48. * @param {String} options.type Content provider type to use. Must provide a spec or content, if not defined.
  49. * @param {Object} options.spec Layout, widget, or fragment spec.
  50. * @param {ContentAPI} options.content ContentAPI object to be added to the canvas.
  51. * @param {TransactionToken} transactionToken
  52. * @return {Promise<ContentAPI>} new content
  53. */
  54. CanvasAPI.prototype.addContent = function addContent() {};
  55. /**
  56. * @function CanvasAPI#moveContent
  57. * @description Moves the contents specified in @contentIdList to new container @containerId.
  58. * @param {String} containerId Specifies the container ID.
  59. * @param {*} contentIdList Contains the content ID list.
  60. * @param {*} transactionToken Transaction token for this action.
  61. * @return {ContentAPI[]} the list of contentAPIs correnponding to @contentIdList
  62. */
  63. CanvasAPI.prototype.moveContent = function moveContent() {};
  64. /**
  65. * @description Returns the content that matches the specified ID.
  66. * @function CanvasAPI#getContent
  67. * @param {String} id - ID of the content
  68. * @return {ContentAPI}
  69. */
  70. CanvasAPI.prototype.getContent = function getContent() {};
  71. /**
  72. * @description Returns a list of toolbar actions.
  73. * @param {String[]} idList
  74. * @return {Object[]} Array of actions
  75. * @example
  76. * {
  77. * name: 'group',
  78. * label: stringResources.get('toolbarActionGroup'),
  79. * icon: 'dashboard-group',
  80. * type: 'Button',
  81. * action: () => {}
  82. * }
  83. */
  84. CanvasAPI.prototype.getContentActionList = function getContentActionList() /* idList */{};
  85. /**
  86. * Selects the content that matches the specified IDs.
  87. * @function CanvasAPI#selectContent
  88. * @param {String[]} idList- Array of IDs to select
  89. */
  90. CanvasAPI.prototype.selectContent = function selectContent() {};
  91. /**
  92. * Deselects the content that matches the specified IDs.
  93. * @function CanvasAPI#deselectContent
  94. * @param {String[]} idList- Array of IDs to deselect
  95. */
  96. CanvasAPI.prototype.deselectContent = function deselectContent() {};
  97. /**
  98. * Returns the list of content that is selected.
  99. * @function CanvasAPI#getSelectedContentList
  100. * @param {Object} selector - Optional, returns groups and widgets by default.
  101. * @param {String} selector.type - Selector string
  102. * @return {ContentAPI[]} contentList - Array of content
  103. */
  104. CanvasAPI.prototype.getSelectedContentList = function getSelectedContentList() {};
  105. /**
  106. * Removes the content with the specified ID.
  107. * @function CanvasAPI#removeContent
  108. * @param {String} id - ID of the content
  109. * @param {TransactionToken} transactionToken - Transaction token for this action
  110. */
  111. CanvasAPI.prototype.removeContent = function removeContent() {};
  112. /**
  113. * Returns a list of content that matches the specified selector.
  114. * @function CanvasAPI#findContent
  115. * @param {Object} selector - Selector object; returns all widgets if undefined.
  116. * @param {String} selector.type - Selector type
  117. * @param {Object} selector.properties
  118. * @return {ContentAPI[]} Array of content
  119. * @example
  120. * canvas.findContent({
  121. * properties: {
  122. * title: 'My page'
  123. * }
  124. * });
  125. * canvas.findContent({
  126. * type: 'page'
  127. * });
  128. */
  129. CanvasAPI.prototype.findContent = function findContent() {};
  130. /**
  131. * @function DashboardAPI#copy
  132. * @description Copies the currently selected widget(s) on the dashboard.
  133. * @private
  134. */
  135. CanvasAPI.prototype.copy = function copy() {};
  136. /**
  137. * @function DashboardAPI#paste
  138. * @description Pastes the copied widget(s) to the dashboard.
  139. * @private
  140. * @return {Promise} Promise, which is resolved once the widget(s) are successfully pasted.
  141. */
  142. CanvasAPI.prototype.paste = function paste() {};
  143. /**
  144. * @function CanvasAPI#getPropertyLayoutList
  145. * @descrpition Returns a list of layout and properties used to render the properties UI.
  146. * @return {Object[]} Array of layout and properties used to render the properties UI.
  147. */
  148. CanvasAPI.prototype.getPropertyLayoutList = function getPropertyLayoutList() {};
  149. /**
  150. * @function CanvasAPI#getPropertiesNameList
  151. * @description Returns an object of property objects.
  152. * @return {String[]} Array of property objects
  153. */
  154. CanvasAPI.prototype.getPropertyNameList = function getPropertyNameList() {};
  155. /**
  156. * @function CanvasAPI#setPropertyValue
  157. * @description Sets the value for a property.
  158. * @param {String} name - Name of the property to set
  159. * @param {Object} value - Value to set
  160. * @param {TransactionToken} transactionToken
  161. */
  162. CanvasAPI.prototype.setPropertyValue = function setPropertyValue() {};
  163. /**
  164. * @function CanvasAPI#getPropertyValue
  165. * @description Gets the value for a property.
  166. * @param {String} name - Name of the property
  167. * @return {Object} Value of the property
  168. */
  169. CanvasAPI.prototype.getPropertyValue = function getPropertyValue() {};
  170. return CanvasAPI;
  171. }();
  172. return CanvasAPI;
  173. });
  174. //# sourceMappingURL=CanvasAPI.js.map