legacyAppButtonView.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: SHARE
  5. *
  6. * (C) Copyright IBM Corp. 2015
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure
  9. * restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(['bi/glass/app/plugins/MenuActionInterface', 'bi/commons/utils/Utils'], function(view, utils) {
  12. 'use strict';
  13. var legacyAppButtonView = view.extend({
  14. onSelectItem: function(context) {
  15. var index = context.target.specItemIndex;
  16. var item = context.target.plugin.itemSpec.items[index];
  17. if (item.tool) {
  18. utils.legacyLaunch(context.glassContext, item.tool);
  19. }
  20. },
  21. isItemVisible: function(context) {
  22. var id = context.target.itemId;
  23. var idTokens = id.split('.');
  24. var key = idTokens[idTokens.length-1];
  25. if (key === "legacy_myInbox" || key === "legacy_myWatchItems") {
  26. return this._getIsLaunchable();
  27. }
  28. else {
  29. return false;
  30. }
  31. },
  32. onRender: function(context) {
  33. context.glassContext.services.config.getLegacyLaunchable().done(function(value) {
  34. this._setIsLaunchable(value === 1);
  35. }.bind(this))
  36. },
  37. _setIsLaunchable: function(value) {
  38. this.isLaunchable = value;
  39. },
  40. _getIsLaunchable: function() {
  41. return this.isLaunchable;
  42. }
  43. });
  44. return legacyAppButtonView;
  45. });