ContentAPI.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. 2019, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. /**
  9. * @interface ContentAPI
  10. * @hideconstructor
  11. * @classdesc API class that is used to control canvas content.
  12. * @example dashboard.getFeature('Canvas').getContent(<widgetId>)
  13. * @example dashboard.getFeature('Canvas').findContent()
  14. */
  15. define([], function () {
  16. var ContentAPI = function () {
  17. function ContentAPI() {
  18. _classCallCheck(this, ContentAPI);
  19. }
  20. /**
  21. * @function ContentAPI#getId
  22. * @description Returns the internal ID of the widget.
  23. * @return {String} Internal ID of the widget
  24. */
  25. ContentAPI.prototype.getId = function getId() {};
  26. /**
  27. * @function ContentAPI#getType
  28. * @description Returns the type of the canvas content.
  29. * @return {String} Type of the canvas content
  30. */
  31. ContentAPI.prototype.getType = function getType() {};
  32. /**
  33. * @function ContentAPI#getPropertyLayoutList
  34. * @description Returns a list of layout and properties used to render the properties UI.
  35. * @return {Object[]} Array of layout and properties used to render the properties UI.
  36. */
  37. ContentAPI.prototype.getPropertyLayoutList = function getPropertyLayoutList() {};
  38. /**
  39. * @function ContentAPI#getPropertiesNameList
  40. * @description Returns an array of property names.
  41. * @return {String[]} Array of property objects
  42. */
  43. ContentAPI.prototype.getPropertyNameList = function getPropertyNameList() {};
  44. /**
  45. * @function ContentAPI#getPropertyList
  46. * @description get the list of all properties
  47. * @return {Object[]}
  48. */
  49. ContentAPI.prototype.getPropertyList = function getPropertyList() {};
  50. /**
  51. * @function ContentAPI#setPropertyValue
  52. * @description Sets the value of a property.
  53. * @param {String} name - Name of the property to set
  54. * @param {Object} value - Value to set
  55. * @param {SetOptions} options
  56. */
  57. ContentAPI.prototype.setPropertyValue = function setPropertyValue() {};
  58. /**
  59. * @function ContentAPI#getPropertyValue
  60. * @description Returns the value of a property.
  61. * @param {String} name - Name of the property
  62. * @return {Object} Value of the property
  63. */
  64. ContentAPI.prototype.getPropertyValue = function getPropertyValue() {};
  65. /**
  66. * @function ContentAPI#getFeature
  67. * @description Returns a content-level feature. Features are extensions to the widget.
  68. * @param {String} featureId[.type] - featureId is the ID of the feature to get, while .type is the type of the feature.
  69. * @return {Promise} Promise resolved with the feature or with undefined, if the feature does not exist.
  70. * @example
  71. * content.getFeature('state') will return a public renderState API.
  72. * content.getFeature('state.internal') will return a private renderState API.
  73. */
  74. ContentAPI.prototype.getFeature = function getFeature() {};
  75. /**
  76. * @function ContentAPI#setFeatureEnabled
  77. * @description Determines whether a content-level feature is enabled or disabled at runtime.
  78. * @param {String} featureId - ID of the feature to update
  79. * @param {Boolean} isEnabled - Set to true to enable the feature. Default is true.
  80. */
  81. ContentAPI.prototype.setFeatureEnabled = function setFeatureEnabled() {};
  82. /**
  83. * @description Register a content event handler.
  84. * @function ContentAPI#on
  85. * @param {String} name Event name
  86. * @param {Function} handler Event handler
  87. * @return {Object} Object that has a remove function to remove the event handler.
  88. * @example
  89. * content.on('all', (event) => { console.log(event); });
  90. * content.on('change:selections', (event) => { console.log(event.info.events); });
  91. * content.on('change:selections:clearAll', (event) => { console.log(event); });
  92. */
  93. ContentAPI.prototype.on = function on() {};
  94. /**
  95. * @function ContentAPI#off
  96. * @description Unregisters an event handler that was registered with {@link ContentAPI#on}.
  97. * @param {String} eventName Name of the dashboard event
  98. * @param {function} handler Event handler to be called when the event occurs.
  99. * @param {object} context Context of the event
  100. */
  101. ContentAPI.prototype.off = function off() {};
  102. /**
  103. * Returns the content that matches the given ID.
  104. * @function ContentAPI#getContent
  105. * @param {String} id - ID of the content
  106. * @return {ContentAPI}
  107. */
  108. ContentAPI.prototype.getContent = function getContent() {};
  109. /**
  110. * Returns a list of content that matches the provided selector.
  111. * @function ContentAPI#findContent
  112. * @param {Object} selector - Selector object; returns all widgets if undefined.
  113. * @param {String} selector.type - Selector type
  114. * @param {Object} selector.properties
  115. * @return {ContentAPI[]} Array of content
  116. * @example
  117. * content.findContent({
  118. * properties: {
  119. * title: 'My page'
  120. * }
  121. * });
  122. * content.findContent({
  123. * type: 'page'
  124. * });
  125. */
  126. ContentAPI.prototype.findContent = function findContent() {};
  127. /**
  128. * Returns the parent container.
  129. * @function ContentAPI#getContainer
  130. * @return {ContentAPI} Content container
  131. */
  132. ContentAPI.prototype.getContainer = function getContainer() {};
  133. /**
  134. * Returns the children content.
  135. * @function ContentAPI#getChildren
  136. * @return {ContentAPI[]} Array of contents
  137. */
  138. ContentAPI.prototype.getChildren = function getChildren() {};
  139. /**
  140. * @function ContentAPI#addContent
  141. * @description Adds content with the specified spec.
  142. * @param {Object} options Contains the options for adding content to this contentApi.
  143. * @param {String} options.containerId Container ID specifying where to add the content. By default, the system selects the position.
  144. * @param {Number} options.position Index specifying where to add the content. By default, the system selects the position.
  145. * @param {Object} options.properties An object of property names and values to apply to the content.
  146. * @param {String} options.type Content provider type to use. Must provide a spec or content, if not defined.
  147. * @param {Object} options.spec Layout, widget or fragment spec.
  148. * @param {ContentAPI} options.content ContentAPI object to be added to this contentApi.
  149. * @param {TransactionToken} [transactionToken] - Optional transaction token.
  150. * @return {Promise<ContentAPI>} Promise resolved with the new content instance.
  151. */
  152. ContentAPI.prototype.addContent = function addContent() {};
  153. /**
  154. * Removes the content with the specified ID.
  155. * @function ContentAPI#removeContent
  156. * @param {String} id - ID of the content
  157. *
  158. * @param {TransactionToken} [transactionToken] - Optional transaction token
  159. */
  160. ContentAPI.prototype.removeContent = function removeContent() {};
  161. return ContentAPI;
  162. }();
  163. return ContentAPI;
  164. });
  165. //# sourceMappingURL=ContentAPI.js.map