/* * 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: *