'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../../../widgets/livewidget/nls/StringResources', '../../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory'], function (stringResources, ContentActionsProviderAPI, APIFactory) { var SwapRowColumnAction = function () { function SwapRowColumnAction(dashboard, dashboardState, icons) { _classCallCheck(this, SwapRowColumnAction); this._dashboard = dashboard; this._dashboardState = dashboardState; this._icons = icons; } SwapRowColumnAction.prototype.getContentActionList = function getContentActionList(idList) { var contribution = []; if (this._getSelectedContent(idList)) { var contentId = idList[0]; var content = this._dashboard.getCanvas().getContent(contentId); var visualization = content.getFeature('Visualization'); var swapIcon = this._icons.getIcon('dashboard-swap'); if (this._supportAction(content)) { contribution = [{ name: 'swapRowsAndColumns', label: stringResources.get('swapRowsAndColumns'), icon: swapIcon.id, actions: { apply: this.swapRowsAndColumns.bind(this, visualization) }, type: 'Button' }]; } } return contribution; }; SwapRowColumnAction.prototype.swapRowsAndColumns = function swapRowsAndColumns(visualization) { visualization.getSlots().swapSlots('column_level1', 'row_level1'); }; SwapRowColumnAction.prototype._supportAction = function _supportAction(content) { var isAllowed = false; var uiState = this._dashboardState.getUiState(); var visualization = content.getFeature('Visualization'); if (visualization && !uiState.eventGroups) { var visId = visualization.getDefinition().getId(); var mappingComplete = visualization.getSlots().isMappingComplete(); isAllowed = mappingComplete && visId === 'crosstab'; } return isAllowed; }; SwapRowColumnAction.prototype._getSelectedContent = function _getSelectedContent(idList) { return idList.length === 1; }; SwapRowColumnAction.prototype.getAPI = function getAPI() { if (!this._api) { this._api = APIFactory.createAPI(this, [ContentActionsProviderAPI]); } return this._api; }; return SwapRowColumnAction; }(); return SwapRowColumnAction; }); //# sourceMappingURL=SwapRowColumnAction.js.map