ForecastDetailsController.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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
  9. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(['../ExtensionBaseController', './ForecastDetailsView', './Result', '../../dataSources/nls/StringResources'], function (BaseController, ForecastDetailsView, Result, StringResources) {
  12. 'use strict';
  13. var ForecastDetailsController = function (_BaseController) {
  14. _inherits(ForecastDetailsController, _BaseController);
  15. function ForecastDetailsController(dashboard) {
  16. _classCallCheck(this, ForecastDetailsController);
  17. var _this = _possibleConstructorReturn(this, _BaseController.call(this, dashboard));
  18. _this.tabName = StringResources.get('forecastDetailsTabName');
  19. _this.prefix_ID = 'fd_';
  20. _this.view = new ForecastDetailsView({});
  21. return _this;
  22. }
  23. /**
  24. * @see ExtensionBaseController
  25. */
  26. ForecastDetailsController.prototype.getTabContrib = function getTabContrib() {
  27. var content = this._getSelectedContent();
  28. if (!content) {
  29. return Promise.resolve(null);
  30. }
  31. var forecastFeature = content.getFeature('Forecast');
  32. if (!this._isThereForecastContribution(forecastFeature)) {
  33. return Promise.resolve(null);
  34. }
  35. var forecastQueryResult = forecastFeature.getQueryResult();
  36. // Check if there is a valid Forecast details in the response
  37. var statisticalDetailsResponse = forecastQueryResult ? forecastQueryResult.getStatisticalDetails() : null;
  38. if (!statisticalDetailsResponse || statisticalDetailsResponse.length <= 0) {
  39. return Promise.resolve(null);
  40. }
  41. var id = content.getId();
  42. var tabID = this.prefix_ID + id;
  43. var forceRender = false;
  44. return Promise.resolve([{
  45. id: tabID,
  46. name: this.tabName,
  47. isSelectedOnTrayRender: false,
  48. select: this.select.bind(this, { forecastQueryResult: forecastQueryResult, id: tabID, forceRender: forceRender })
  49. }]);
  50. };
  51. ForecastDetailsController.prototype._isThereForecastContribution = function _isThereForecastContribution(forecastFeature) {
  52. return forecastFeature && forecastFeature.getForecastDisplayState().toggleEnabled && forecastFeature.areThereValidForecastSettings() & forecastFeature.supportsForecasts();
  53. };
  54. /**
  55. * @see ExtensionBaseController
  56. */
  57. ForecastDetailsController.prototype.select = function select(context, currentTabId, container) {
  58. if (currentTabId === context.id && !context.forceRender) {
  59. return Promise.resolve(false);
  60. }
  61. var resultTable = new Result(context.forecastQueryResult);
  62. return this.view.render(container, resultTable);
  63. };
  64. return ForecastDetailsController;
  65. }(BaseController);
  66. return ForecastDetailsController;
  67. });
  68. //# sourceMappingURL=ForecastDetailsController.js.map