CancelDataSourceRefreshAction.js 2.3 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. *+------------------------------------------------------------------------+
  5. *| Licensed Materials - Property of IBM
  6. *| IBM Cognos Products: CA
  7. *| (C) Copyright IBM Corp. 2016, 2017
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define([], function () {
  13. 'use strict';
  14. var CancelDataSourceRefreshAction = function () {
  15. function CancelDataSourceRefreshAction() {
  16. _classCallCheck(this, CancelDataSourceRefreshAction);
  17. }
  18. // Called by Glass when actionController is created.
  19. CancelDataSourceRefreshAction.prototype.initialize = function initialize(context) {
  20. var _this = this;
  21. return context.glassContext.getSvc('.DatasetExecutionService').then(function (datasetExecutionService) {
  22. _this.datasetExecutionService = datasetExecutionService;
  23. });
  24. };
  25. /**
  26. * Determine when we show/hide the menu item
  27. */
  28. CancelDataSourceRefreshAction.prototype.isItemVisible = function isItemVisible(options) {
  29. var objectInfo = this._getObjectInfo(options);
  30. if (!objectInfo) {
  31. return false;
  32. }
  33. if (objectInfo.type !== 'dataSet2') {
  34. return false;
  35. }
  36. return this.datasetExecutionService.isExecuting(objectInfo.id);
  37. };
  38. /**
  39. * Default action handler
  40. */
  41. CancelDataSourceRefreshAction.prototype.onSelectItem = function onSelectItem(options) {
  42. var objectInfo = this._getObjectInfo(options);
  43. if (!objectInfo) {
  44. return;
  45. }
  46. this.datasetExecutionService.cancel({
  47. 'id': objectInfo.id,
  48. 'name': objectInfo.defaultName,
  49. 'glassContext': options.glassContext
  50. }, true);
  51. };
  52. CancelDataSourceRefreshAction.prototype._getObjectInfo = function _getObjectInfo(options) {
  53. if (options && options.target && options.target.activeObject) {
  54. var aSelectedContext = options.target.activeObject.aSelectedContext;
  55. if (aSelectedContext.length === 1) {
  56. return aSelectedContext[0];
  57. }
  58. }
  59. return null;
  60. };
  61. return CancelDataSourceRefreshAction;
  62. }();
  63. return CancelDataSourceRefreshAction;
  64. });
  65. //# sourceMappingURL=CancelDataSourceRefreshAction.js.map