123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- '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 CreateEventGroupAction = function (_EventGroupActions) {
- _inherits(CreateEventGroupAction, _EventGroupActions);
- function CreateEventGroupAction(_ref) {
- var features = _ref.features;
- _classCallCheck(this, CreateEventGroupAction);
- var _this = _possibleConstructorReturn(this, _EventGroupActions.call(this, { features: features }));
- if (features) {
- features.ContentActions.registerProvider('createFilterGroup', _this.getAPI());
- _this._icons = features.Icons;
- }
- return _this;
- }
- CreateEventGroupAction.prototype.getContentActionList = function getContentActionList(idList) {
- if (this._isAvailable(idList)) {
- return [{
- name: 'createFilterGroup',
- label: stringResources.get('toolbarActionCreateFilterGroup'),
- icon: this._icons.getIcon('new-link').id,
- actions: {
- apply: this.execute.bind(this, idList)
- },
- disabled: this.isDisabled.bind(this, idList),
- type: 'Button',
- order: 3,
- update: true
- }];
- } else {
- return [];
- }
- };
- CreateEventGroupAction.prototype.execute = function execute(idList) {
- this.eventGroups.createGroup(idList, _.uniqueId('_createGroup_'));
- };
- CreateEventGroupAction.prototype.isDisabled = function isDisabled(idList) {
- if (this._isStaticWidget(idList)) {
- return true;
- }
- /*
- * if the selection contains only 1 distinct group and the selection contains every widget in that group,
- * then disable the "Create event group" button
- */
- var distinctGroupIdsInSelection = this._getDistinctGroupIdsInSelection(idList);
- var numberOfWidgetsInGroup = this.eventGroups.getContentIdList(distinctGroupIdsInSelection[0]).length;
- if (distinctGroupIdsInSelection.length === 1 && idList.length === numberOfWidgetsInGroup) {
- return true;
- }
- /*
- * Also, if more than 5 groups will result from the execution of a create group event, then disable the button.
- * count represents the number of groups that will be eliminated after disconnecting
- */
- var count = this._getCountGroupsAffected(idList);
- if (this.getNumberOfGroups(idList) - count + 1 > 5) {
- return true;
- }
- return false;
- };
- return CreateEventGroupAction;
- }(EventGroupActions);
- return CreateEventGroupAction;
- });
- //# sourceMappingURL=CreateEventGroupAction.js.map
|