12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content Explorer
- *| (C) Copyright IBM Corp. 2017, 2021
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define([
- 'bi/glass/app/NavbarButtonSlideoutController',
- 'bacontentnav/utils/UIHelper',
- 'bacontentnav/utils/ContentServiceUrls',
- 'underscore'
- ], function(NavbarButtonSlideoutController, UIHelper, ContentServiceUrls, _) {
- 'use strict'; //NOSONAR
- var ButtonSlideoutController = NavbarButtonSlideoutController.extend({
- /**
- * Builds a predefined spec for slideout.
- * If current content view has a folderInfo object then it
- * builds a slideout spec to display a folder instead of root
- * based on ancestors from folderInfo object.
- * @public
- * @override
- * @param {object} Context containing glass context and target
- * @returns {object} Slideout item spec
- */
- getCustomSpec: function() {
- var spec = ButtonSlideoutController.inherited('getCustomSpec', this, arguments);
- if (spec.options && spec.options.content.id) {
- let specWidth = UIHelper.getSlideoutWidth(spec.options.content.id);
- if (specWidth) {
- // We need to add 9px for the bar.
- specWidth = parseInt(specWidth);
- specWidth += 9;
- if (specWidth < $(document).width()) {
- spec.options.width = '' + specWidth + 'px';
- }
- }
- }
- return spec;
- },
- onRender: function(pluginData) {
- if (pluginData.target.itemId === 'com.ibm.bi.contentApps.myPortalPages') {
- return pluginData.glassContext.getCoreSvc('.Config').getConfigValue('ContentApps/enableMyPortalPages').then(function(isFeatureEnabled) {
- if (isFeatureEnabled === 'true') {
- pluginData.target.plugin.hideForever = false;
- return Promise.resolve(pluginData.target.plugin.show());
- } else {
- pluginData.target.plugin.hideForever = true;
- return Promise.resolve(pluginData.target.plugin.hide());
- }
- }.bind(this));
- } else if (pluginData.target.itemId === 'com.ibm.bi.contentApps.customFoldersSlideout') {
- var teamFolders = pluginData.glassContext.getCoreSvc('.UserProfile').userProfileSettings.ui_teamFolders;
- if (!_.isEmpty(teamFolders)) {
- var path = teamFolders.pathRef;
- if (path) {
- path = path.replace(/^\//, '');
- }
- var pathURL = ContentServiceUrls.getBasePathURL() + encodeURIComponent(path);
- var options = {
- dataType: 'json',
- url: pathURL
- };
- return pluginData.glassContext.getCoreSvc('.Ajax').ajax(options).then(function(result) {
- var cmObj = result.data.data[0];
- var label = cmObj.defaultName;
- pluginData.target.plugin.changeLabel(label);
- pluginData.target.plugin.hideForever = false;
- return Promise.resolve(pluginData.target.plugin.show());
- }.bind(this));
- } else {
- pluginData.target.plugin.hideForever = true;
- return Promise.resolve(pluginData.target.plugin.hide());
- }
- }
- }
- });
- return ButtonSlideoutController;
- });
|