123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- /*
- * Licensed Materials - Property of IBM
- *
- * IBM Cognos Products: SHARE
- *
- * (C) Copyright IBM Corp. 2015, 2016
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define([
- 'bi/glass/core/Class',
- 'bi/sharecommon/utils/translator',
- 'bi/schedule/app/appControler'
- ], function(Class, t, appController) {
- 'use strict';
- var ContextMenuButtonView = Class.extend({
- onSelectItem: function(context) {
- var options =
- {
- context: context,
- launchPoint: context.target.plugin.activeObject.currentTarget
- };
- var idTokens = context.target.itemId.split('.');
- var key = idTokens[idTokens.length - 1];
-
- if(key === "update") {
- this._updateSubscriptionMenuItem(options);
- }
- else if(key === "versions") {
- this._viewVersionsOfSubscriptionMenuItem(options);
- }
- else if(key === "delete") {
- this._deleteSubscriptionMenuItem(options);
- }
- },
- isItemVisible: function(context) {
- var idTokens = context.target.itemId.split('.');
- var key = idTokens[idTokens.length - 1];
- if(key === "update" || key === "versions" || key === "delete") {
- return true;
- } else {
- return false;
- }
- },
- _updateSubscriptionMenuItem: function(options) {
- var subscriptionId = options.context.target.activeObject.subscriptionId;
- var updateCallback = options.context.target.activeObject.updateCallback;
- appController.getSubscriptionDetails(subscriptionId, options.context.glassContext).then(function(data) {
- appController.showSubscriptionPane(options.context.glassContext, data, options.launchPoint, {
- onUpdate: updateCallback
- });
- });
- },
- _viewVersionsOfSubscriptionMenuItem: function(options) {
- var subscriptionId = options.context.target.activeObject.subscriptionId;
- appController.getSubscriptionRunHistory(subscriptionId, options.context.glassContext).then(function(properties) {
- appController.showVersionsPane(options.context.glassContext, properties, options.launchPoint);
- });
- },
- _deleteSubscriptionMenuItem: function(options) {
- var subscriptionId = options.context.target.activeObject.subscriptionId;
- var deleteCallbacks = options.context.target.activeObject.deleteCallbacks;
- var $subscriptionRow = $(options.context.target.activeObject.currentTarget).closest('tr');
- var deleteOptions = {
- subscriptionId : subscriptionId,
- pending: true
- };
-
- if (options.context.glassContext.services.userProfile.preferences.accessibilityFeatures) {
- options.context.glassContext.appController.showMessage(t.translate('delete_subscription_confirm_message'), t.translate('delete_confirm'), 'info', ['ok','cancel'], undefined, function(evt) {
- if (evt.btn==='ok') {
- deleteCallbacks.hideRow($subscriptionRow).done(function() {
- deleteCallbacks.complete(deleteOptions);
- });
- //set focus to "Enabled" table header
- $("table.subscriptions_list_table thead tr th").eq(0).focus();
- } else {
- //set the focus back to the chevron that was clicked
- $(options.launchPoint).focus();
- }
- }.bind(this));
- } else {
- deleteCallbacks.hideRow($subscriptionRow);
- //set focus to "Enabled" table header
- $("table.subscriptions_list_table thead tr th").eq(0).focus();
- options.context.glassContext.appController.showToast(t.translate('delete_sub_message'),
- {
- 'type': 'info',
- 'btnLabel' : t.translate('delete_undo'),
- 'callback' : function() {
- deleteOptions.pending = false;
- deleteCallbacks.undoDelete($subscriptionRow);
- },
- 'newestOnTop' : true,
- 'preventDuplicates' : false,
- 'timeOut': 6000,
- 'extendedTimeOut': 1000,
- 'onHidden' : function() {
- deleteCallbacks.complete(deleteOptions);
- }
- });
- }
- }
- });
- return ContextMenuButtonView;
- });
|