'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: CA *| (C) Copyright IBM Corp. 2016, 2017 *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define([], function () { 'use strict'; var CancelDataSourceRefreshAction = function () { function CancelDataSourceRefreshAction() { _classCallCheck(this, CancelDataSourceRefreshAction); } // Called by Glass when actionController is created. CancelDataSourceRefreshAction.prototype.initialize = function initialize(context) { var _this = this; return context.glassContext.getSvc('.DatasetExecutionService').then(function (datasetExecutionService) { _this.datasetExecutionService = datasetExecutionService; }); }; /** * Determine when we show/hide the menu item */ CancelDataSourceRefreshAction.prototype.isItemVisible = function isItemVisible(options) { var objectInfo = this._getObjectInfo(options); if (!objectInfo) { return false; } if (objectInfo.type !== 'dataSet2') { return false; } return this.datasetExecutionService.isExecuting(objectInfo.id); }; /** * Default action handler */ CancelDataSourceRefreshAction.prototype.onSelectItem = function onSelectItem(options) { var objectInfo = this._getObjectInfo(options); if (!objectInfo) { return; } this.datasetExecutionService.cancel({ 'id': objectInfo.id, 'name': objectInfo.defaultName, 'glassContext': options.glassContext }, true); }; CancelDataSourceRefreshAction.prototype._getObjectInfo = function _getObjectInfo(options) { if (options && options.target && options.target.activeObject) { var aSelectedContext = options.target.activeObject.aSelectedContext; if (aSelectedContext.length === 1) { return aSelectedContext[0]; } } return null; }; return CancelDataSourceRefreshAction; }(); return CancelDataSourceRefreshAction; }); //# sourceMappingURL=CancelDataSourceRefreshAction.js.map