12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- /*
- * Licensed Materials - Property of IBM
- *
- * IBM Cognos Products: Modeling UI
- *
- * Copyright IBM Corp. 2017, 2018
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['bi/glass/core/Class', 'underscore'], function(BaseClass, _) {
- var ModuleEditHandler = BaseClass.extend({
- init: function() {
- ModuleEditHandler.inherited('init', this, arguments);
- },
- doAction: function(context) {
- return this._passSecurityCheck(context)
- ? Promise.resolve(this.onSelectItem(context))
- : Promise.reject();
- },
- onSelectItem: function(context) {
- var application = context.glassContext;
- if (application.currentAppView.perspective === 'ca-modeller') {
- // launch the glass open dialog
- application.getCurrentContentView().openModel();
- return;
- }
- application.closeAppView('ca-modeller').then(
- function() {
- // from the glass open dialog
- var id = context.target.activeObject.aSelectedContext[0].id;
- application.openAppView('ca-modeller', {
- content: {
- objRef: id,
- id: id
- }
- });
- }
- );
- },
- _passSecurityCheck: function(context) {
- var aPerm = ['read'];
- var selection =
- context &&
- context.target &&
- context.target.activeObject &&
- context.target.activeObject.aSelectedContext;
- return (
- selection &&
- selection.length &&
- _.intersection(selection[0].permissions, aPerm).length === aPerm.length &&
- context.glassContext.services.userProfile.capabilities.indexOf(
- 'canUseWebBasedModeling'
- ) >= 0
- );
- },
- /**
- * Method invoked when rendering glass Menu, ContextMenu and GlassPlugin classes to determine if the item should be displayed
- * @param {context} which contains the following:
- * <ul>
- * <li>glassContext</li>
- * <li>target: object containing info on the target: plugin and itemId</li>
- * <li>activeObject: object for which the menu is displayed, used for the context menu</li>
- * </ul>
- * @return true or false
- */
- isItemVisible: function(context) {
- return (
- context.target.activeObject.aSelectedContext.length === 1 &&
- context.target.activeObject.aSelectedContext[0].type === 'module' &&
- this._passSecurityCheck(context)
- );
- }
- });
- return ModuleEditHandler;
- });
|