12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- "use strict";
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Cognos Analytics
- * Copyright IBM Corp. 2015, 2017
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['underscore', 'bi/glass/app/ContentView', 'bi/admin/nls/StringResource', 'bi/commons/ui/properties/PropertyUIControl', 'bi/admin/common/ui/RegionalOptionsModule', 'bi/admin/multitenancy/services/TenantsCustomizationService'], function (_, ContentView, StringResource, PropertyUIControl, RegionalOptionsModule, TenantsCustomizationService) {
- 'use strict'; //NOSONAR: meant to be strict
- var RegionalSettingsTab = ContentView.extend({
- /**
- @paran options.el {node} - container dom node
- **/
- init: function init(options) {
- RegionalSettingsTab.inherited('init', this, arguments);
- _.extend(this, options);
- this.regionalOptions = new RegionalOptionsModule({
- $el: this.$el,
- glassContext: this.glassContext,
- objectInfo: this.objectInfo,
- slideout: this.slideout,
- parent: this
- });
- this.tenantsController = new TenantsCustomizationService({
- glassContext: this.glassContext
- });
- this.tenant = this.objectInfo;
- this._customizations = null;
- },
- render: function render() {
- //NOSONAR
- return Promise.resolve(this.tenantsController.getTenantPreferences(this.tenant.tenantID)).then(function (result) {
- this._customizations = result.data;
- return Promise.resolve(this.regionalOptions.getRegionalOptions(this._customizations)).then(function (customSettings) {
- var regionalSettings = customSettings;
- this._oPropertyUIControl = new PropertyUIControl({
- 'el': this.$el,
- 'glassContext': this.glassContext,
- 'slideout': this.slideout,
- 'items': regionalSettings
- });
- return this._oPropertyUIControl.render();
- }.bind(this));
- }.bind(this));
- },
- onClose: function onClose() {
- this._oPropertyUIControl.onClose().then(function (data) {
- var props = this._oPropertyUIControl.getModifiedProperties();
- if (!_.isEmpty(props)) {
- this.setRegionalSettings(props).then(function (response) {
- this.glassContext.appController.showToast(StringResource.get("tenantSavePreferencesToast", {
- 'tenantName': this.tenant.defaultName
- }));
- }.bind(this)).catch(function (response) {
- this.glassContext.appController.showErrorMessage(StringResource.get("tenantSavePreferencesErrorToast", {
- 'tenantName': this.tenant.defaultName
- }));
- }.bind(this));
- }
- }.bind(this));
- },
- setRegionalSettings: function setRegionalSettings(props) {
- if (!_.isEmpty(props)) {
- return this.tenantsController.setTenantPreferences(this.tenant.tenantID, props);
- } else {
- var promise = new Promise(function (resolve) {
- return true;
- });
- return promise;
- }
- }
- });
- return RegionalSettingsTab;
- });
|