DockAction.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['../../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../../app/nls/StringResources', '../../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI'], function (APIFactory, stringResources, ContentActionsProviderAPI) {
  9. var DockAction = function () {
  10. function DockAction(_ref) {
  11. var features = _ref.features;
  12. _classCallCheck(this, DockAction);
  13. if (features) {
  14. this._toolbarDock = features.ToolbarDock;
  15. this._dashboard = features.API;
  16. this._contentActions = features.ContentActions;
  17. this._dashboardState = features.DashboardState;
  18. this._icons = features.Icons;
  19. }
  20. }
  21. DockAction.prototype.initialize = function initialize() {
  22. if (this._toolbarDock) {
  23. this._api = APIFactory.createAPI(this, [ContentActionsProviderAPI]);
  24. this._contentActions.registerProvider('dockToolbarAction', this._api);
  25. }
  26. };
  27. DockAction.prototype.getAPI = function getAPI() {
  28. return APIFactory.createAPI(this, [ContentActionsProviderAPI]);
  29. };
  30. DockAction.prototype._isAvailable = function _isAvailable(idList) {
  31. var isExplore = this._dashboard.getType().toUpperCase() === 'EXPLORE';
  32. return idList.length && !isExplore;
  33. };
  34. DockAction.prototype._isDisabled = function _isDisabled() {
  35. return this._dashboardState.getUiState().focus;
  36. };
  37. DockAction.prototype.getContentActionList = function getContentActionList(idList) {
  38. var contribution = void 0;
  39. if (this._isAvailable(idList)) {
  40. var icon = void 0,
  41. tooltip = void 0;
  42. if (this._toolbarDock.isContentToolbarDocked()) {
  43. icon = this._icons.getIcon('undock-icon').id;
  44. tooltip = stringResources.get('undockToolbar');
  45. } else {
  46. icon = this._icons.getIcon('dock-icon').id;
  47. tooltip = stringResources.get('dockToolbar');
  48. }
  49. contribution = [{
  50. name: 'dockToolbarAction',
  51. label: tooltip,
  52. icon: icon,
  53. type: 'Button',
  54. disabled: this._isDisabled.bind(this),
  55. actions: {
  56. apply: function () {
  57. this._toolbarDock.toggle();
  58. }.bind(this)
  59. }
  60. }];
  61. } else {
  62. contribution = [];
  63. }
  64. return contribution;
  65. };
  66. return DockAction;
  67. }();
  68. return DockAction;
  69. });
  70. //# sourceMappingURL=DockAction.js.map