CustomizationTab.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2015, 2017
  6. * US Government Users Restricted Rights - Use, duplication or disclosure
  7. * restricted by GSA ADP Schedule Contract with IBM Corp.
  8. */
  9. define(['underscore', 'bi/admin/nls/StringResource', 'bi/admin/common/ui/BaseCustomizationTab', 'bi/admin/multitenancy/services/TenantsCustomizationService'], function (_, StringResource, BaseCustomizationTab, TenantsCustomizationService) {
  10. 'use strict'; //NOSONAR
  11. var CustomizationTab = BaseCustomizationTab.extend({
  12. init: function init(options) {
  13. CustomizationTab.inherited('init', this, arguments);
  14. _.extend(this, options);
  15. this._customizationService = this._getNewTenantsCustomizationService({
  16. glassContext: this.glassContext
  17. });
  18. this.tenant = this.objectInfo;
  19. this.objectInfo.id = this.tenant.tenantID;
  20. },
  21. _getNewTenantsCustomizationService: function _getNewTenantsCustomizationService(spec) {
  22. return new TenantsCustomizationService(spec);
  23. },
  24. _showThemesPanel: function _showThemesPanel() {
  25. this._themesSlideout = this.glassContext.appController.showSlideOut({
  26. parent: this.slideout,
  27. width: '400px',
  28. content: {
  29. module: 'bi/admin/system/ThemesTab',
  30. glassContext: this.glassContext,
  31. showTitle: true,
  32. toastMessageLabel: 'tenantThemeSet',
  33. toastMessageParam: this.tenant.defaultName,
  34. getDefaultThemeCallback: function () {
  35. return Promise.resolve(this._getTheme());
  36. }.bind(this),
  37. setDefaultThemeCallback: this.setTheme.bind(this),
  38. global: false
  39. }
  40. });
  41. },
  42. _getAdvancedPropertyControlItem: function _getAdvancedPropertyControlItem() {
  43. return;
  44. },
  45. _showGlobalParametersPanel: function _showGlobalParametersPanel() {
  46. this._parametersSlideout = this.glassContext.appController.showSlideOut({
  47. 'parent': this.slideout,
  48. 'width': '400px',
  49. 'label': StringResource.get('globalParameters'),
  50. 'content': {
  51. 'module': 'bi/admin/common/GlobalParametersTab',
  52. 'parentView': this,
  53. 'glassContext': this.glassContext,
  54. 'getParameters': this._getParameters.bind(this),
  55. 'updateParameters': this._setParameters.bind(this),
  56. 'title': StringResource.get('globalParameters')
  57. }
  58. });
  59. this._parametersSlideout.onHide = function () {
  60. if (this.contentView.modified) {
  61. this.contentView.save();
  62. }
  63. };
  64. },
  65. _getParameters: function _getParameters() {
  66. return Promise.try(function () {
  67. var parameters = [];
  68. _.each(this._customizations.parameters, function (parameter) {
  69. parameters.push(parameter);
  70. });
  71. return parameters;
  72. }.bind(this));
  73. },
  74. _refresh: function _refresh() {},
  75. _setParameters: function _setParameters(tenantParameters) {
  76. var parameters = {};
  77. for (var i = 0; i < tenantParameters.length; ++i) {
  78. parameters[tenantParameters[i].name] = tenantParameters[i];
  79. }
  80. return this._customizationService.setParameters(this.tenant.tenantID, parameters).then(function (result) {
  81. this._customizations = result;
  82. });
  83. }
  84. });
  85. return CustomizationTab;
  86. });