From 29b2eafb111a1d10711ddcaa66bd351f93953858 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 6 Dec 2019 16:46:11 +0300 Subject: [PATCH] [SSE] Separator settings --- .../main/app/controller/LeftMenu.js | 15 ++++-- .../main/app/controller/Main.js | 6 +-- .../main/app/view/FileMenuPanels.js | 50 ++++++++++++------- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 7bd49f28c..71ff4f2f7 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -387,11 +387,16 @@ define([ } var reg = Common.localStorage.getItem("sse-settings-reg-settings"), - decimal = Common.localStorage.getItem("sse-settings-decimal-separator"), - group = Common.localStorage.getItem("sse-settings-group-separator"); - decimal = decimal === 'undefined' ? undefined : decimal; - group = group === 'undefined' ? undefined : group; - if (reg!==null) this.api.asc_setLocale(parseInt(reg), decimal, group); + baseRegSettings = Common.Utils.InternalSettings.get("sse-settings-use-base-separator"); + if (reg === null) { + reg = this.api.asc_getLocale(); + } + if (baseRegSettings) { + this.api.asc_setLocale(parseInt(reg), undefined, undefined); + } + else { + this.api.asc_setLocale(parseInt(reg), Common.localStorage.getItem("sse-settings-decimal-separator"), Common.localStorage.getItem("sse-settings-group-separator")); + } menu.hide(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index b314928a3..201c37581 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -343,10 +343,10 @@ define([ .setUserName(this.appOptions.user.fullname); var reg = Common.localStorage.getItem("sse-settings-reg-settings"), + isUseBaseSeparator = Common.localStorage.getBool("sse-settings-use-base-separator", true), decimal = Common.localStorage.getItem("sse-settings-decimal-separator"), group = Common.localStorage.getItem("sse-settings-group-separator"); - decimal = decimal === 'undefined' ? undefined : decimal; - group = group === 'undefined' ? undefined : group; + Common.Utils.InternalSettings.set("sse-settings-use-base-separator", isUseBaseSeparator); if (reg!==null) this.api.asc_setLocale(parseInt(reg), decimal, group); else { @@ -359,7 +359,7 @@ define([ this.api.asc_setLocale(reg, decimal, group); } - value = Common.localStorage.getBool("sse-settings-r1c1"); + var value = Common.localStorage.getBool("sse-settings-r1c1"); Common.Utils.InternalSettings.set("sse-settings-r1c1", value); this.api.asc_setR1C1Mode(value); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 2907fca35..704661053 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -771,6 +771,12 @@ define([ labelText: this.strUseSeparatorsBasedOnRegionalSettings }).on('change', _.bind(function(field, newValue, oldValue, eOpts){ var checked = field.getValue() === 'checked'; + if (checked) { + var decimal = this.api.asc_getDecimalSeparator(), + group = this.api.asc_getGroupSeparator(); + this.inputDecimalSeparator.setValue(decimal); + this.inputThousandsSeparator.setValue(group); + } this.inputDecimalSeparator.setDisabled(checked); this.inputThousandsSeparator.setDisabled(checked); }, this)); @@ -892,14 +898,19 @@ define([ } this.updateRegionalExample(value); - var decimal = this.api.asc_getDecimalSeparator(); - this.inputDecimalSeparator.setValue(decimal ? decimal : ''); - - var group = this.api.asc_getGroupSeparator(); - this.inputThousandsSeparator.setValue(group ? group : ''); - - var isBaseSettings = _.isUndefined(decimal) && _.isUndefined(group); + var isBaseSettings = Common.Utils.InternalSettings.get("sse-settings-use-base-separator"); this.chSeparator.setValue(isBaseSettings); + var decimal, + group; + if (!isBaseSettings) { + decimal = Common.Utils.InternalSettings.get("sse-settings-decimal-separator") || this.api.asc_getDecimalSeparator() || ''; + group = Common.Utils.InternalSettings.get("sse-settings-group-separator") || this.api.asc_getGroupSeparator() || ''; + } else { + decimal = this.api.asc_getDecimalSeparator(); + group = this.api.asc_getGroupSeparator(); + } + this.inputDecimalSeparator.setValue(decimal); + this.inputThousandsSeparator.setValue(group); this.inputDecimalSeparator.setDisabled(isBaseSettings); this.inputThousandsSeparator.setDisabled(isBaseSettings); }, @@ -923,17 +934,22 @@ define([ if (this.cmbRegSettings.getSelectedRecord()) Common.localStorage.setItem("sse-settings-reg-settings", this.cmbRegSettings.getValue()); - var decimal, - group; - if (this.chSeparator.isChecked()) { - decimal = undefined; - group = undefined; - } else { - decimal = this.inputDecimalSeparator.getValue(); - group = this.inputThousandsSeparator.getValue(); + var value, + isChecked = this.chSeparator.isChecked(); + if (!isChecked) { + value = this.inputDecimalSeparator.getValue(); + if (value.length > 0) { + Common.localStorage.setItem("sse-settings-decimal-separator", value); + Common.Utils.InternalSettings.set("sse-settings-decimal-separator", value); + } + value = this.inputThousandsSeparator.getValue(); + if (value.length > 0) { + Common.localStorage.setItem("sse-settings-group-separator", value); + Common.Utils.InternalSettings.set("sse-settings-group-separator", value); + } } - Common.localStorage.setItem("sse-settings-decimal-separator", decimal); - Common.localStorage.setItem("sse-settings-group-separator", group); + Common.localStorage.setBool("sse-settings-use-base-separator", isChecked); + Common.Utils.InternalSettings.set("sse-settings-use-base-separator", isChecked); Common.localStorage.save(); if (this.menu) {