'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, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../../widgets/livewidget/nls/StringResources', 'jquery', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI'], function (stringResources, $, APIFactory, ContentActionsProviderAPI) { var PROP_ID_SUPPRESSION = 'suppression'; var SuppressionAction = function () { function SuppressionAction(_ref) { var features = _ref.features; _classCallCheck(this, SuppressionAction); if (features) { this.dashboardApi = features.API; this.icons = features.Icons; features.ContentActions.registerProvider('suppressionAction', this.getAPI()); } } SuppressionAction.prototype.getAPI = function getAPI() { if (!this._api) { this._api = APIFactory.createAPI(this, [ContentActionsProviderAPI]); } return this._api; }; SuppressionAction.prototype.getLifeCycleHandlers = function getLifeCycleHandlers() { return [{ name: 'post:dashboard.initialize', action: this.postDashboardInitialize.bind(this) }]; }; SuppressionAction.prototype.postDashboardInitialize = function postDashboardInitialize() { return Promise.resolve(); }; SuppressionAction.prototype.destroy = function destroy() { this.dashboardApi = null; }; SuppressionAction.prototype.isEnabled = function isEnabled(idList) { var selectedContent = this._getSelectedContent(); var propertyProvider = selectedContent && selectedContent.getFeature('SuppressionPropertyProvider'); return idList.length === 1 && propertyProvider && propertyProvider.getPropertyList().length && this.dashboardApi.getMode() !== this.dashboardApi.MODES.EDIT_GROUP; }; SuppressionAction.prototype.getContentActionList = function getContentActionList(idList) { var iconSuppresion = this.icons.getIcon('iconSuppresion'); if (this.isEnabled(idList)) { return [{ name: PROP_ID_SUPPRESSION, label: this._getLabel(), icon: iconSuppresion.id, type: 'Button', actions: { apply: this._toggleSuppress.bind(this, idList) } }]; } return []; }; SuppressionAction.prototype._getSelectedContent = function _getSelectedContent() { return this.dashboardApi.getCanvas().getSelectedContentList()[0]; }; SuppressionAction.prototype._getLabel = function _getLabel(suppressValue) { suppressValue = suppressValue || this._getValue(); return suppressValue === 'rowsAndColumns' ? stringResources.get('disableSuppression') : stringResources.get('enableSuppression'); }; SuppressionAction.prototype._getValue = function _getValue() { return this._getSelectedContent().getPropertyValue(PROP_ID_SUPPRESSION); }; SuppressionAction.prototype._toggleSuppress = function _toggleSuppress(idList, evt) { var propValue = this._getValue(); var toggleValue = propValue === 'rowsAndColumns' ? 'none' : 'rowsAndColumns'; var $suppressBtn = $(evt.currentTarget).find('.suppressBtnToggle').addBack(); var label = this._getLabel(toggleValue); $suppressBtn.attr('title', label); $suppressBtn.find('svg title').text(label); this._getSelectedContent().setPropertyValue(PROP_ID_SUPPRESSION, toggleValue); }; return SuppressionAction; }(); return SuppressionAction; }); //# sourceMappingURL=SuppressionAction.js.map