VisAPI.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: Dashboard
  6. *| (C) Copyright IBM Corp. 2014, 2020
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define(['../../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../../dataSources/utils/DatasourceUtil', 'dashboard-analytics/util/DashboardFormatter'], function (Class, DatasourceUtil, Formatter) {
  13. 'use strict';
  14. /**
  15. * INTENT: The VisAPI is the topmost API to operations that have to do with mappings, slots, or data
  16. * (the mapping AND data portions of the spec).
  17. */
  18. var VisAPI = Class.extend({
  19. // constructor
  20. init: function init(args) {
  21. VisAPI.inherited('init', this, arguments);
  22. this._intialize(args);
  23. this.flag = 'VisAPI';
  24. },
  25. destroy: function destroy() {
  26. this._clear();
  27. if (this.visModelManager) {
  28. this.visModelManager.remove();
  29. this.visModelManager = null;
  30. }
  31. VisAPI.inherited('destroy', this, arguments);
  32. },
  33. reIntialize: function reIntialize(options) {
  34. this._clear();
  35. if (this.visRenderSupport) {
  36. this.visRenderSupport.clear();
  37. this.visRenderSupport = null;
  38. }
  39. this._intialize(options);
  40. },
  41. _clear: function _clear() {
  42. if (this.visFilterSupport) {
  43. this.visFilterSupport = null;
  44. }
  45. if (this.visConditionsSupport) {
  46. this.visConditionsSupport.destroy();
  47. this.visConditionsSupport = null;
  48. }
  49. if (this.visPropertySupport) {
  50. this.visPropertySupport.remove();
  51. this.visPropertySupport = null;
  52. }
  53. if (this.visModelManagerLEFTOVER) {
  54. this.visModelManagerLEFTOVER = null;
  55. }
  56. },
  57. _intialize: function _intialize(args) {
  58. var visModelManager = this.visModelManager = args.visModelManager;
  59. var visRenderSupport = this.visRenderSupport = args.visRenderSupport;
  60. var visFilterSupport = this.visFilterSupport = args.visFilterSupport;
  61. var visConditionsSupport = this.visConditionsSupport = args.visConditionsSupport;
  62. var visPropertySupport = this.visPropertySupport = args.visPropertySupport;
  63. var ownerWidget = args.ownerWidget;
  64. var visModelManagerLEFTOVER = this.visModelManagerLEFTOVER = args.visModelManagerLEFTOVER;
  65. this.visQuerySupport = args.visQuerySupport;
  66. this.getVisId = visModelManager.getVisId.bind(visModelManager);
  67. this.getSuppressViewAnimations = visModelManager.getSuppressViewAnimations.bind(visModelManager);
  68. this.getModule = visModelManager.getModule.bind(visModelManager);
  69. this.getMetadataColumn = visModelManager.getMetadataColumn.bind(visModelManager);
  70. this.getMetadataManager = visModelManager.getMetadataManager.bind(visModelManager);
  71. this.getUsedMetadataColumns = visModelManager.getUsedMetadataColumns.bind(visModelManager);
  72. this.getInvalidReason = visModelManager.getInvalidReason.bind(visModelManager);
  73. this.setInvalidReason = visModelManager.setInvalidReason.bind(visModelManager);
  74. this.clearModelInvalid = visModelManager.clearModelInvalid.bind(visModelManager);
  75. this.getDefinition = visModelManager.getDefinition.bind(visModelManager);
  76. this.getTitle = visModelManager.getTitle.bind(visModelManager);
  77. this.setTitle = visModelManager.setTitle.bind(visModelManager);
  78. this.isFilterEditable = visModelManager.isFilterEditable.bind(visModelManager);
  79. this.getShowTitle = visModelManager.getShowTitle.bind(visModelManager);
  80. this.supportsSortAction = visModelManager.supportsSortAction.bind(visModelManager);
  81. this.supportsFormatAction = visModelManager.supportsFormatAction.bind(visModelManager);
  82. this.supportsBinAction = visModelManager.supportsBinAction.bind(visModelManager);
  83. this.supportsCustomGroupAction = visModelManager.supportsCustomGroupAction.bind(visModelManager);
  84. this.supportsMaintainAxisScale = visModelManager.supportsMaintainAxisScale.bind(visModelManager);
  85. this.getListenForPropChangesFromDefinition = visModelManager.getListenForPropChangesFromDefinition.bind(visModelManager);
  86. this.getFormatter = function () {
  87. return Formatter;
  88. };
  89. // Vis Interactivity settings
  90. this.getInteractivitySettings = ownerWidget.getInteractivitySettings.bind(ownerWidget);
  91. this.isOptimizeForSize = ownerWidget.isOptimizeForSize.bind(ownerWidget);
  92. //SLOTS AND MAPPINGS =======================================
  93. this.swapSlots = visModelManager.swapSlots.bind(visModelManager);
  94. this.getDataSlots = visModelManager.getDataSlots.bind(visModelManager);
  95. this.getLayers = visModelManager.getLayers && visModelManager.getLayers.bind(visModelManager);
  96. this.getDefaultLayer = visModelManager.getDefaultLayer && visModelManager.getDefaultLayer.bind(visModelManager);
  97. this.getDataSlotById = visModelManager.getDataSlotById.bind(visModelManager);
  98. this.getDataItemSlotAndIndex = visModelManager.getDataItemSlotAndIndex.bind(visModelManager);
  99. this.filterSlotDataItems = visModelManager.filterSlotDataItems.bind(visModelManager);
  100. this.isMappingEmpty = visModelManager.isMappingEmpty.bind(visModelManager);
  101. this.getConditions = visModelManager.getConditions.bind(visModelManager);
  102. this.isDataItemMapped = visModelManager.isDataItemMapped.bind(visModelManager);
  103. this.hasBinnedDataItems = visModelManager.hasBinnedDataItems.bind(visModelManager);
  104. this.isIgnoreDefaultSlotSort = visModelManager.isIgnoreDefaultSlotSort.bind(visModelManager);
  105. //QUERY DEPENDENCIES....
  106. this.getQueryAPI = this.visQuerySupport.getAPI.bind(this.visQuerySupport);
  107. this.getQueryManager = this.visQuerySupport.getQueryManager.bind(this.visQuerySupport);
  108. this.getQueryResults = this.visQuerySupport.getQueryResults.bind(this.visQuerySupport);
  109. this.getQueryExecution = this.visQuerySupport.getQueryExecution.bind(this.visQuerySupport);
  110. this.whenQueryResultsReady = this.visQuerySupport.whenQueryResultsReady.bind(this.visQuerySupport);
  111. this.whenColumnsMinMaxQueryReady = this.visQuerySupport.whenColumnsMinMaxQueryReady.bind(this.visQuerySupport);
  112. this.whenDataItemsMinMaxQueryReady = this.visQuerySupport.whenDataItemsMinMaxQueryReady.bind(this.visQuerySupport);
  113. this.queryChanged = this.visQuerySupport.queryChanged.bind(this.visQuerySupport);
  114. //ANNOTATIONS SUPPORT
  115. this.getAnnotations = visModelManager.getAnnotations.bind(visModelManager);
  116. this.setAnnotations = visModelManager.setAnnotations.bind(visModelManager);
  117. this.whenAnnotatedResultsReady = this.visQuerySupport.whenAnnotatedResultsReady.bind(this.visQuerySupport);
  118. this.getSmartAnnotationsManger = this.visQuerySupport.getSmartAnnotationsManger.bind(this.visQuerySupport);
  119. this.getEnabledAnnotations = this.visQuerySupport.getEnabledAnnotations.bind(this.visQuerySupport);
  120. this.getAllSuggestedAnnotations = this.visQuerySupport.getAllSuggestedAnnotations.bind(this.visQuerySupport);
  121. this.areThereValidInsights = this.visQuerySupport.areThereValidInsights.bind(this.visQuerySupport);
  122. this.areThereValidFPDMessages = this.visQuerySupport.areThereValidFPDMessages.bind(this.visQuerySupport);
  123. this.resetAnnotations = this.visQuerySupport.resetAnnotations.bind(this.visQuerySupport);
  124. this.setAnnotationMessages = this.visQuerySupport.setAnnotationMessages.bind(this.visQuerySupport);
  125. this.clearInsightsIndicatorMessages = this.visQuerySupport.clearInsightsIndicatorMessages.bind(this.visQuerySupport);
  126. //FORECASTING SUPPORT
  127. this.whenPredictIsReady = this.visQuerySupport.whenPredictIsReady.bind(this.visQuerySupport);
  128. //POSSIBLE KEY DRIVER SUPPORT
  129. this.executeFastPatternDetectionRequest = this.visQuerySupport.executeFastPatternDetectionRequest.bind(this.visQuerySupport);
  130. this.getPossibleKeyDrivers = visModelManager.getPossibleKeyDrivers.bind(visModelManager);
  131. this.setPossibleKeyDrivers = visModelManager.setPossibleKeyDrivers.bind(visModelManager);
  132. this.whenPossibleKeyDriversAreReady = this.visQuerySupport.whenPossibleKeyDriversAreReady.bind(this.visQuerySupport);
  133. this.whenPossibleKeyDriversQueryIsReady = this.visQuerySupport.whenPossibleKeyDriversQueryIsReady.bind(this.visQuerySupport);
  134. this.getPossibleKeyDriversDisplayState = this.visQuerySupport.getPossibleKeyDriversDisplayState.bind(this.visQuerySupport);
  135. this.getNewPossibleKeyDriversForTargetId = this.visQuerySupport.getNewPossibleKeyDriversForTargetId.bind(this.visQuerySupport);
  136. this.possibleKeyDriverSelectionStateChanged = this.visQuerySupport.possibleKeyDriverSelectionStateChanged.bind(this.visQuerySupport);
  137. this.getEnabledPossibleKeyDrivers = this.visQuerySupport.getEnabledPossibleKeyDrivers.bind(this.visQuerySupport);
  138. this.getPossibleKeyDriversErrorState = this.visQuerySupport.getPossibleKeyDriversErrorState.bind(this.visQuerySupport);
  139. //RENDER SUPPORT API's ==============================================================
  140. this.getRenderer = visRenderSupport.getRenderer.bind(visRenderSupport);
  141. this.getRenderSequence = visRenderSupport.getRenderSequence.bind(visRenderSupport);
  142. this.getPreferredSize = visRenderSupport.getPreferredSize.bind(visRenderSupport);
  143. this.renderComplete = visRenderSupport.renderComplete.bind(visRenderSupport);
  144. this.renderCompleteBeforeAnimation = visRenderSupport.renderCompleteBeforeAnimation.bind(visRenderSupport);
  145. this.resize = visRenderSupport.resize.bind(visRenderSupport); //function(newWidth, newHeight)
  146. this.reRender = visRenderSupport.reRender.bind(visRenderSupport); //function(extraInfo)
  147. this.mapVizRenderForPrint = visRenderSupport.mapVizRenderForPrint.bind(visRenderSupport);
  148. //FILTER SUPPORT API's =================================================
  149. this.selectData = visFilterSupport.select.bind(visFilterSupport);
  150. this.supportsFilterOnColumn = visFilterSupport.supportsFilterOnColumn.bind(visFilterSupport);
  151. this.getPendingFilters = visFilterSupport.getPendingFilters.bind(visFilterSupport);
  152. this.getActiveFilters = visFilterSupport.getActiveFilters.bind(visFilterSupport);
  153. this.getPageContextAPI = visFilterSupport.getPageContextAPI.bind(visFilterSupport);
  154. this.getFilterInfo = visFilterSupport.getFilterInfo.bind(visFilterSupport);
  155. this.setSynchronizeDataFilters = visFilterSupport.setSynchronizeDataFilters.bind(visFilterSupport);
  156. this.setPendingFilters = visFilterSupport.setPendingFilters.bind(visFilterSupport);
  157. this.getLocalFiltersList = visFilterSupport.getLocalFiltersList.bind(visFilterSupport);
  158. this.validateFilters = visFilterSupport.validateFilters.bind(visFilterSupport);
  159. this.cleanUpMissingFilters = visFilterSupport.cleanUpMissingFilters.bind(visFilterSupport);
  160. this.getAllFiltersAsLocalFiltersForPinning = visFilterSupport.getAllFiltersAsLocalFiltersForPinning.bind(visFilterSupport);
  161. this.getLocalFilterAndTopBottomInfo = visFilterSupport.getLocalFilterAndTopBottomInfo.bind(visFilterSupport);
  162. this.clearSelectionsByDataItemIds = visFilterSupport.clearSelectionsByDataItemIds.bind(visFilterSupport);
  163. //showby
  164. this.getSelectionAsLocalFilters = visFilterSupport.getSelectionAsLocalFilters.bind(visFilterSupport);
  165. this.clearSelectionsUsedForShowBy = visFilterSupport.clearSelectionsUsedForShowBy.bind(visFilterSupport);
  166. //DRILL - TOPN
  167. this.getDrillInfo = visFilterSupport.getDrillInfo.bind(visFilterSupport);
  168. this.getTopBottomInfo = visFilterSupport.getTopBottomInfo.bind(visFilterSupport);
  169. //CONDITIONAL FORMAT
  170. this.hasHeatByItem = visConditionsSupport.hasHeatByItem.bind(visConditionsSupport);
  171. this.getConditionalMinMaxValue = visConditionsSupport.getConditionalMinMaxValue.bind(visConditionsSupport);
  172. this.createDefaultConditionalPalette = visConditionsSupport.createDefaultConditionalPalette.bind(visConditionsSupport); // function(min, max, options)
  173. this.initConditionalPalette = visConditionsSupport.initConditionalPalette.bind(visConditionsSupport);
  174. this.updateConditionalPalette = visConditionsSupport.updateConditionalPalette.bind(visConditionsSupport);
  175. this.getConditionalPaletteLength = visConditionsSupport.getConditionalPaletteLength.bind(visConditionsSupport);
  176. //PROPERTY SUPPORT ==========================================
  177. this.getPropertyValue = visPropertySupport.getPropertyValue.bind(visPropertySupport);
  178. this.getPropertyById = visPropertySupport.getPropertyById.bind(visPropertySupport);
  179. this.getProperties = visPropertySupport.getProperties.bind(visPropertySupport);
  180. this.getVisPropertiesCSSProxy = visPropertySupport.getVisPropertiesCSSProxy.bind(visPropertySupport);
  181. //VizDef METADATA SUPPORT ==========================================
  182. this.getMetaDataValue = visModelManager.getMetaDataValue.bind(visModelManager);
  183. //WIDGET-TO-WIDGET FILTER apis....
  184. this.getLocalFilters = visModelManager.getLocalFilters.bind(visModelManager);
  185. //EVENT apis
  186. this.onChangeTheme = visRenderSupport.onChangeTheme.bind(visRenderSupport);
  187. this.clearError = ownerWidget.clearError.bind(ownerWidget);
  188. this.getScope = ownerWidget.getScope.bind(ownerWidget);
  189. this.getEventGroupId = ownerWidget.getEventGroupId.bind(ownerWidget);
  190. this.getWidgetId = ownerWidget.getId.bind(ownerWidget);
  191. this.getDecoratorAPI = ownerWidget.getDecoratorAPI.bind(ownerWidget);
  192. this.getDecoratorAPIs = ownerWidget.getDecoratorAPIs.bind(ownerWidget);
  193. this.on = visModelManager.on.bind(visModelManager);
  194. this.off = visModelManager.off.bind(visModelManager);
  195. //Custom Data apis
  196. this.getCustomDataDecoration = visModelManagerLEFTOVER.getCustomDataDecoration.bind(visModelManagerLEFTOVER);
  197. this.setCustomDataDecoration = visModelManagerLEFTOVER.setCustomDataDecoration.bind(visModelManagerLEFTOVER);
  198. this.getDecoratedCustomData = visModelManagerLEFTOVER.getDecoratedCustomData.bind(visModelManagerLEFTOVER);
  199. this.getCustomData = visModelManagerLEFTOVER.getCustomData.bind(visModelManagerLEFTOVER);
  200. this.getPromptSpec = ownerWidget.getPromptSpec.bind(ownerWidget);
  201. this.getFredIsRed = ownerWidget.getFredIsRed.bind(ownerWidget);
  202. // thumbnail generation
  203. this.generateThumbnail = ownerWidget.generateThumbnail.bind(ownerWidget);
  204. },
  205. /**
  206. * TODO: CLEANUP AREA - This is a 'transitional function' to allow us to move to a visAPI rather then pass around a visModel.
  207. * The VisAPI should NOT have any data members but the current renderer addresses these members directly.
  208. * When we copy the renderer, these direct references to members should be the first thing to go.
  209. */
  210. setDataMembersTEMPORARILY: function setDataMembersTEMPORARILY(options) {
  211. this.ownerWidget = options.ownerWidget;
  212. this.pendingFilters = options.pendingFilters;
  213. this.localFilters = options.localFilters;
  214. },
  215. renderComplete: function renderComplete() {
  216. throw new Error('VisAPI:renderComplete needs to be implemented');
  217. }
  218. });
  219. return VisAPI;
  220. });
  221. //# sourceMappingURL=VisAPI.js.map