'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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; } 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; } /** * Licensed Materials - Property of IBM * IBM Cognos Products: Dashboard * (C) Copyright IBM Corp. 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../ExtensionBaseController', './ForecastDetailsView', './Result', '../../dataSources/nls/StringResources'], function (BaseController, ForecastDetailsView, Result, StringResources) { 'use strict'; var ForecastDetailsController = function (_BaseController) { _inherits(ForecastDetailsController, _BaseController); function ForecastDetailsController(dashboard) { _classCallCheck(this, ForecastDetailsController); var _this = _possibleConstructorReturn(this, _BaseController.call(this, dashboard)); _this.tabName = StringResources.get('forecastDetailsTabName'); _this.prefix_ID = 'fd_'; _this.view = new ForecastDetailsView({}); return _this; } /** * @see ExtensionBaseController */ ForecastDetailsController.prototype.getTabContrib = function getTabContrib() { var content = this._getSelectedContent(); if (!content) { return Promise.resolve(null); } var forecastFeature = content.getFeature('Forecast'); if (!this._isThereForecastContribution(forecastFeature)) { return Promise.resolve(null); } var forecastQueryResult = forecastFeature.getQueryResult(); // Check if there is a valid Forecast details in the response var statisticalDetailsResponse = forecastQueryResult ? forecastQueryResult.getStatisticalDetails() : null; if (!statisticalDetailsResponse || statisticalDetailsResponse.length <= 0) { return Promise.resolve(null); } var id = content.getId(); var tabID = this.prefix_ID + id; var forceRender = false; return Promise.resolve([{ id: tabID, name: this.tabName, isSelectedOnTrayRender: false, select: this.select.bind(this, { forecastQueryResult: forecastQueryResult, id: tabID, forceRender: forceRender }) }]); }; ForecastDetailsController.prototype._isThereForecastContribution = function _isThereForecastContribution(forecastFeature) { return forecastFeature && forecastFeature.getForecastDisplayState().toggleEnabled && forecastFeature.areThereValidForecastSettings() & forecastFeature.supportsForecasts(); }; /** * @see ExtensionBaseController */ ForecastDetailsController.prototype.select = function select(context, currentTabId, container) { if (currentTabId === context.id && !context.forceRender) { return Promise.resolve(false); } var resultTable = new Result(context.forecastQueryResult); return this.view.render(container, resultTable); }; return ForecastDetailsController; }(BaseController); return ForecastDetailsController; }); //# sourceMappingURL=ForecastDetailsController.js.map