'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, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../../datatray/ExtensionBaseController', './DataBehindTheVisView', '../../../dataSources/nls/StringResources'], function (BaseController, DataBehindTheVisView, StringResources) { var DataBehindTheVisController = function (_BaseController) { _inherits(DataBehindTheVisController, _BaseController); function DataBehindTheVisController(dashboard) { _classCallCheck(this, DataBehindTheVisController); var _this = _possibleConstructorReturn(this, _BaseController.call(this, dashboard)); _this.tabName = StringResources.get('contextualGridTabName'); _this.view = new DataBehindTheVisView({ dashboard: dashboard }); return _this; } /** * @see ExtensionBaseController */ DataBehindTheVisController.prototype.getTabContrib = function getTabContrib(event, eventName, currentTabId) { var _this2 = this; var content = this._getSelectedContent(); if (!content) { return Promise.resolve(null); } return this._isContextualGridEnabled(content).then(function (supported) { if (!supported) { return null; } var id = content.getId(); var isSelectedOnTrayRender = false; var forceRender = false; switch (eventName) { case 'change:selections:select': isSelectedOnTrayRender = true; break; case 'splitterPanel:show': isSelectedOnTrayRender = event && event.sender === 'showDataBehindVisAction'; forceRender = currentTabId === id; break; case 'dataInVis:selected': forceRender = currentTabId === id && event && event.payloadData && event.payloadData.focusOn && id === event.sender; break; case 'widget:rerendered': forceRender = currentTabId === id && event && event.sender === id; break; } return [{ id: id, name: _this2.tabName, isSelectedOnTrayRender: isSelectedOnTrayRender, select: _this2.select.bind(_this2, { content: content, id: id, forceRender: forceRender }) }]; }); }; DataBehindTheVisController.prototype._isContextualGridEnabled = function _isContextualGridEnabled(content) { var state = content.getFeature('state'); return state.whenStatusChanges(state.STATUS.RENDERED).then(function () { var supported = false; var visualization = content.getFeature('Visualization'); if (visualization) { var definition = visualization.getDefinition(); supported = !definition.getProperty('isMultilayersWidget') && !definition.getProperty('noDataQuery'); } return supported; }); }; /** * @see ExtensionBaseController */ DataBehindTheVisController.prototype.select = function select(context, currentTabId, container) { if (currentTabId === context.id && !context.forceRender) { return Promise.resolve(false); } return this.view.render(context.content, container); }; return DataBehindTheVisController; }(BaseController); return DataBehindTheVisController; }); //# sourceMappingURL=DataBehindTheVisController.js.map