GlobalParametersController.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. *
  5. * IBM Cognos Products: BI Glass
  6. *
  7. * Copyright IBM Corp. 2017
  8. *
  9. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. */
  11. define(['underscore', 'bi/glass/app/NavbarButtonSlideoutController'], function (_, BaseController) {
  12. 'use strict'; //NOSONAR
  13. var GlobalParametersController = BaseController.extend({
  14. onRender: function onRender(context) {
  15. if (!this._canShowGlobalParametersIcon(context)) {
  16. context.target.plugin.$el.css('display', 'none');
  17. }
  18. },
  19. _canShowGlobalParametersIcon: function _canShowGlobalParametersIcon(context) {
  20. var perspective = context.glassContext.appController.currentAppView.perspective;
  21. if ('createBoard dashboard ca-modeller ca-modeller-create ca-modeller-upload'.indexOf(perspective) !== -1) {
  22. return false;
  23. }
  24. var parameter_values = context.glassContext.services.userProfile.userProfileSettings.parameter_values;
  25. if (!parameter_values || _.isEmpty(parameter_values)) {
  26. return false;
  27. }
  28. var allParameterValuesDisabled = true;
  29. for (var parameterName in parameter_values) {
  30. if (typeof parameter_values[parameterName].enabled === 'undefined' || parameter_values[parameterName].enabled === true) {
  31. allParameterValuesDisabled = false;
  32. break;
  33. }
  34. }
  35. return !allParameterValuesDisabled;
  36. },
  37. _openSlideout: function _openSlideout() {
  38. var slideout = GlobalParametersController.inherited('_openSlideout', this, arguments);
  39. slideout.onHide = function () {
  40. this.contentView.saveToUserAccount();
  41. };
  42. return slideout;
  43. }
  44. });
  45. return GlobalParametersController;
  46. });