PackageEnrichHandler.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: Modeling UI
  5. *
  6. * Copyright IBM Corp. 2017, 2019
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['bi/glass/core/Class', 'ca-modeller/CMIcons'], function (BaseClass) {
  11. var PackageEnrichHandler = BaseClass.extend({
  12. init: function() {
  13. PackageEnrichHandler.inherited('init', this, arguments);
  14. },
  15. doAction: function(context) {
  16. return Promise.resolve(this.onSelectItem(context));
  17. },
  18. onSelectItem: function(context) {
  19. require(['ca-modeller/packageEnrich'], function(packageEnrich) {
  20. var selected = context.target.activeObject.aSelectedContext[0];
  21. packageEnrich.default(context.glassContext, { storeId: selected.id, packageName: selected.defaultName });
  22. })
  23. },
  24. /**
  25. * Method invoked when rendering glass Menu, ContextMenu and GlassPlugin classes to determine if the item should be displayed
  26. * @param {context} which contains the following:
  27. * <ul>
  28. * <li>glassContext</li>
  29. * <li>target: object containing info on the target: plugin and itemId</li>
  30. * <li>activeObject: object for which the menu is displayed, used for the context menu</li>
  31. * </ul>
  32. * @return true or false
  33. */
  34. isItemVisible: function(context) {
  35. // object type for data module
  36. return context.glassContext.services.userProfile.capabilities.indexOf('canUseWebBasedModeling') >= 0 &&
  37. context.target.activeObject.aSelectedContext.length === 1 &&
  38. !context.target.activeObject.aSelectedContext[0].disabled &&
  39. context.target.activeObject.aSelectedContext[0].type === 'package' &&
  40. (context.target.activeObject.aSelectedContext[0].permissions || []).indexOf('write') !== -1;
  41. }
  42. });
  43. return PackageEnrichHandler;
  44. });