1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- '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: BI Cloud (C) Copyright IBM Corp. 2017, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['./EventGroupActions', '../../../../app/nls/StringResources', 'underscore'], function (EventGroupActions, stringResources, _) {
- var DisconnectEventGroupAction = function (_EventGroupActions) {
- _inherits(DisconnectEventGroupAction, _EventGroupActions);
- function DisconnectEventGroupAction(_ref) {
- var features = _ref.features;
- _classCallCheck(this, DisconnectEventGroupAction);
- var _this = _possibleConstructorReturn(this, _EventGroupActions.call(this, { features: features }));
- if (features) {
- features.ContentActions.registerProvider('disconnectFilterGroup', _this.getAPI());
- _this._icons = features.Icons;
- }
- return _this;
- }
- DisconnectEventGroupAction.prototype.getContentActionList = function getContentActionList(idList) {
- if (this._isAvailable(idList)) {
- return [{
- name: 'disconnectFilterGroup',
- label: stringResources.get('toolbarActionDisconnectFilterGroup'),
- icon: this._icons.getIcon('unlink').id,
- type: 'Button',
- order: 1,
- actions: {
- apply: this.execute.bind(this, idList)
- },
- disabled: this.isDisabled.bind(this, idList),
- update: true
- }];
- } else {
- return [];
- }
- };
- DisconnectEventGroupAction.prototype.execute = function execute(idList) {
- this.eventGroups.removeFromGroup(idList, _.uniqueId('_disconnectFromGroup_'));
- };
- DisconnectEventGroupAction.prototype.isDisabled = function isDisabled(idList) {
- var _this2 = this;
- if (this._isStaticWidget(idList)) {
- return true;
- }
- var groups = this.eventGroups.getGroupIdsOnPage(this._getPageId(idList));
- if (!(groups.length > 0)) {
- // disable if no groups on page
- return true;
- }
- var count = this._getCountGroupsAffected(idList);
- //if the number of groups remaining after disconnecting will be greater than 5, it should be disabled
- if (this.getNumberOfGroups(idList) + idList.length - count > 5) {
- return true;
- }
- //also if the selection contains only groups that have a single widget, it should be disabled
- var selectedGroupsWithMoreThanOneWidget = _.filter(idList, function (id) {
- var groupId = _this2.eventGroups.getGroupId(id);
- return _this2.eventGroups.getContentIdList(groupId).length > 1;
- });
- if (selectedGroupsWithMoreThanOneWidget.length === 0) {
- return true;
- }
- return false;
- };
- return DisconnectEventGroupAction;
- }(EventGroupActions);
- return DisconnectEventGroupAction;
- });
- //# sourceMappingURL=DisconnectEventGroupAction.js.map
|