RemoveDataSourceAction.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: CA
  6. *| (C) Copyright IBM Corp. 2016, 2019
  7. *| US Government Users Restricted Rights - Use, duplication or disclosure
  8. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *+------------------------------------------------------------------------+
  10. */
  11. define(['../../lib/@waca/core-client/js/core-client/ui/core/Class'], function (Class) {
  12. 'use strict';
  13. var RemoveDataSourceAction = null;
  14. RemoveDataSourceAction = Class.extend({
  15. /**
  16. * Determine when we show/hide the menu item
  17. */
  18. isItemVisible: function isItemVisible(options) {
  19. try {
  20. var dataSourceId = options.target.activeObject.dataSource.getId();
  21. var dashboardApi = options.glassContext.appController.getCurrentContentView().getDashboardApi();
  22. var dataSourcesApi = dashboardApi.getFeature('DataSources');
  23. var dataSourceApi = dataSourcesApi.getDataSource(dataSourceId);
  24. return !dataSourceApi.isDataSourceUsed();
  25. } catch (error) {
  26. options.glassContext.getCoreSvc('.Logger').error('could not decide to show/hide the menu items', error);
  27. return false;
  28. }
  29. },
  30. /**
  31. * Default action handler
  32. */
  33. onSelectItem: function onSelectItem(options) {
  34. try {
  35. var dataSourceId = options.target.activeObject.dataSource.getId();
  36. var dashboardApi = options.glassContext.appController.getCurrentContentView().getDashboardApi();
  37. var dataSourcesApi = dashboardApi.getFeature('DataSources');
  38. dataSourcesApi.removeDataSource(dataSourceId);
  39. } catch (error) {
  40. options.glassContext.getCoreSvc('.Logger').error('could not remove the datasource', error);
  41. }
  42. }
  43. });
  44. return RemoveDataSourceAction;
  45. });
  46. //# sourceMappingURL=RemoveDataSourceAction.js.map