SearchAction.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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
  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', '../../../widgets/livewidget/nls/StringResources', '../../../lib/@waca/dashboard-common/dist/api/ContentActionsProviderAPI'], function (APIFactory, stringResources, ContentActionsProviderAPI) {
  9. var visDefsHaveSearchButton = {
  10. list: true,
  11. hierarchy2: true,
  12. hierarchy3: true
  13. };
  14. var SearchAction = function () {
  15. function SearchAction(_ref) {
  16. var features = _ref.features;
  17. _classCallCheck(this, SearchAction);
  18. this._dashboard = features.API;
  19. this._dashboardState = features.DashboardState;
  20. this._icons = features.Icons;
  21. this._api = APIFactory.createAPI(this, [ContentActionsProviderAPI]);
  22. features.ContentActions.registerProvider('searchAction', this._api);
  23. }
  24. SearchAction.prototype.getAPI = function getAPI() {
  25. return this._api;
  26. };
  27. SearchAction.prototype.getContentActionList = function getContentActionList(idList) {
  28. var contribution = [];
  29. if (this._getSelectedContent(idList)) {
  30. var contentId = idList[0];
  31. var content = this._dashboard.getCanvas().getContent(contentId);
  32. var searchIcon = this._icons.getIcon('searchIcon');
  33. if (this._supportAction(idList, content)) {
  34. contribution = [{
  35. name: 'searchAction',
  36. label: stringResources.get('search'),
  37. icon: searchIcon.id,
  38. type: 'NextView',
  39. viewModule: 'dashboard-analytics/visualizations/search/DataWidgetSearchView',
  40. viewOptions: {
  41. height: 50,
  42. width: 242,
  43. content: content
  44. }
  45. }];
  46. }
  47. }
  48. return contribution;
  49. };
  50. SearchAction.prototype._supportAction = function _supportAction(idList, content) {
  51. var isAllowed = false;
  52. var uiState = this._dashboardState.getUiState();
  53. var visualization = content.getFeature('Visualization');
  54. if (visualization && !uiState.eventGroups) {
  55. var visId = visualization.getDefinition().getId();
  56. var mappingComplete = visualization.getSlots().isMappingComplete();
  57. isAllowed = mappingComplete && visDefsHaveSearchButton[visId];
  58. }
  59. return isAllowed;
  60. };
  61. SearchAction.prototype._getSelectedContent = function _getSelectedContent(idList) {
  62. return idList.length === 1;
  63. };
  64. return SearchAction;
  65. }();
  66. return SearchAction;
  67. });
  68. //# sourceMappingURL=SearchAction.js.map