LinkEventGroupAction.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. 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; }
  4. 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; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2017, 2020
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['./EventGroupActions', '../../../../app/nls/StringResources'], function (EventGroupActions, stringResources) {
  11. var LinkEventGroupAction = function (_EventGroupActions) {
  12. _inherits(LinkEventGroupAction, _EventGroupActions);
  13. function LinkEventGroupAction(_ref) {
  14. var features = _ref.features;
  15. _classCallCheck(this, LinkEventGroupAction);
  16. var _this = _possibleConstructorReturn(this, _EventGroupActions.call(this, { features: features }));
  17. if (features) {
  18. features.ContentActions.registerProvider('linkFilterGroup', _this.getAPI());
  19. _this._icons = features.Icons;
  20. }
  21. return _this;
  22. }
  23. LinkEventGroupAction.prototype.getContentActionList = function getContentActionList(idList) {
  24. if (this._isAvailable(idList)) {
  25. return [{
  26. name: 'linkFilterGroup',
  27. label: stringResources.get('toolbarActionLinkFilterGroup'),
  28. icon: this._icons.getIcon('link').id,
  29. type: 'NextView',
  30. order: 2,
  31. disabled: this.isDisabled.bind(this, idList),
  32. viewModule: 'dashboard-core/js/app/ui/dialogs/FilterGroupsDialog',
  33. viewOptions: {
  34. height: 140,
  35. width: 180,
  36. labels: false,
  37. idList: idList,
  38. controller: this
  39. },
  40. update: true
  41. }];
  42. } else {
  43. return [];
  44. }
  45. };
  46. LinkEventGroupAction.prototype.isDisabled = function isDisabled(idList) {
  47. if (this._isStaticWidget(idList)) {
  48. return true;
  49. }
  50. if (this.getNumberOfGroups(idList) < 2) {
  51. return true;
  52. }
  53. return false;
  54. };
  55. LinkEventGroupAction.prototype.getGroups = function getGroups(idList) {
  56. if (this._isStaticWidget(idList)) {
  57. return [];
  58. }
  59. var pageid = this._getPageId(idList);
  60. var groups = this.eventGroups.getGroupIdsOnPage(pageid);
  61. /*
  62. * return the array of group ids for the "add to group" function. If the selection contains only 1 distinct group,
  63. * then that group index should not be in the list of possible groups to be added to.
  64. */
  65. var distinctGroupIdsInSelection = this._getDistinctGroupIdsInSelection(idList);
  66. //remove the group id from the list if the selection only contains 1 distinct group
  67. if (distinctGroupIdsInSelection.length === 1) {
  68. groups = groups.filter(function (value) {
  69. return value !== distinctGroupIdsInSelection[0];
  70. });
  71. return groups;
  72. }
  73. return groups;
  74. };
  75. return LinkEventGroupAction;
  76. }(EventGroupActions);
  77. return LinkEventGroupAction;
  78. });
  79. //# sourceMappingURL=LinkEventGroupAction.js.map