OpenSessionModuleHandler.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: Modeling UI
  5. *
  6. * Copyright IBM Corp. 2018
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. /**
  11. * This handler is for open a modue stored in cm session. A typical case is to create
  12. * a datamodule after file upload. In such case, we don't need the permission check. Plus,
  13. * it won't be exposed to any perspective contextmenu action, so it will always be hidden.
  14. */
  15. define(['bi/glass/core/Class', 'underscore'], function (BaseClass, _) {
  16. var OpenSessionModuleHandler = BaseClass.extend({
  17. init: function() {
  18. OpenSessionModuleHandler.inherited('init', this, arguments);
  19. },
  20. doAction: function(context) {
  21. return this._passSecurityCheck(context)
  22. ? Promise.resolve(this.onSelectItem(context))
  23. : Promise.reject();
  24. },
  25. onSelectItem: function(context) {
  26. var application = context.glassContext;
  27. var selected = context.target.activeObject.aSelectedContext[0];
  28. var id = selected.id;
  29. var sessionModule = selected.sessionModule;
  30. application.openAppView('ca-modeller', {
  31. content: {
  32. tid: id,
  33. id: id,
  34. sessionModule: sessionModule
  35. }
  36. });
  37. },
  38. _passSecurityCheck: function(context) {
  39. return (
  40. context.glassContext.services.userProfile.capabilities.indexOf('canUseWebBasedModeling') >= 0
  41. );
  42. },
  43. isItemVisible: function(context) {
  44. return false;
  45. }
  46. });
  47. return OpenSessionModuleHandler;
  48. });