DataBehindTheVisController.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: Dashboard
  8. * (C) Copyright IBM Corp. 2019, 2020
  9. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(['../../../datatray/ExtensionBaseController', './DataBehindTheVisView', '../../../dataSources/nls/StringResources'], function (BaseController, DataBehindTheVisView, StringResources) {
  12. var DataBehindTheVisController = function (_BaseController) {
  13. _inherits(DataBehindTheVisController, _BaseController);
  14. function DataBehindTheVisController(dashboard) {
  15. _classCallCheck(this, DataBehindTheVisController);
  16. var _this = _possibleConstructorReturn(this, _BaseController.call(this, dashboard));
  17. _this.tabName = StringResources.get('contextualGridTabName');
  18. _this.view = new DataBehindTheVisView({
  19. dashboard: dashboard
  20. });
  21. return _this;
  22. }
  23. /**
  24. * @see ExtensionBaseController
  25. */
  26. DataBehindTheVisController.prototype.getTabContrib = function getTabContrib(event, eventName, currentTabId) {
  27. var _this2 = this;
  28. var content = this._getSelectedContent();
  29. if (!content) {
  30. return Promise.resolve(null);
  31. }
  32. return this._isContextualGridEnabled(content).then(function (supported) {
  33. if (!supported) {
  34. return null;
  35. }
  36. var id = content.getId();
  37. var isSelectedOnTrayRender = false;
  38. var forceRender = false;
  39. switch (eventName) {
  40. case 'change:selections:select':
  41. isSelectedOnTrayRender = true;
  42. break;
  43. case 'splitterPanel:show':
  44. isSelectedOnTrayRender = event && event.sender === 'showDataBehindVisAction';
  45. forceRender = currentTabId === id;
  46. break;
  47. case 'dataInVis:selected':
  48. forceRender = currentTabId === id && event && event.payloadData && event.payloadData.focusOn && id === event.sender;
  49. break;
  50. case 'widget:rerendered':
  51. forceRender = currentTabId === id && event && event.sender === id;
  52. break;
  53. }
  54. return [{
  55. id: id,
  56. name: _this2.tabName,
  57. isSelectedOnTrayRender: isSelectedOnTrayRender,
  58. select: _this2.select.bind(_this2, { content: content, id: id, forceRender: forceRender })
  59. }];
  60. });
  61. };
  62. DataBehindTheVisController.prototype._isContextualGridEnabled = function _isContextualGridEnabled(content) {
  63. var state = content.getFeature('state');
  64. return state.whenStatusChanges(state.STATUS.RENDERED).then(function () {
  65. var supported = false;
  66. var visualization = content.getFeature('Visualization');
  67. if (visualization) {
  68. var definition = visualization.getDefinition();
  69. supported = !definition.getProperty('isMultilayersWidget') && !definition.getProperty('noDataQuery');
  70. }
  71. return supported;
  72. });
  73. };
  74. /**
  75. * @see ExtensionBaseController
  76. */
  77. DataBehindTheVisController.prototype.select = function select(context, currentTabId, container) {
  78. if (currentTabId === context.id && !context.forceRender) {
  79. return Promise.resolve(false);
  80. }
  81. return this.view.render(context.content, container);
  82. };
  83. return DataBehindTheVisController;
  84. }(BaseController);
  85. return DataBehindTheVisController;
  86. });
  87. //# sourceMappingURL=DataBehindTheVisController.js.map