From 0b3636f663adb2f583cf234bae746a3a3ad3efbc Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Mon, 9 Dec 2019 14:53:06 +0300 Subject: [PATCH] [SSE] Separator settings --- .../main/app/controller/Main.js | 8 ++++-- .../main/app/view/FileMenuPanels.js | 28 ++++++++++++------- apps/spreadsheeteditor/main/locale/en.json | 4 +++ 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ed5744adc..1b7cb600f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -347,9 +347,13 @@ define([ 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 = undefined, + group = undefined; Common.Utils.InternalSettings.set("sse-settings-use-base-separator", isUseBaseSeparator); + if (!isUseBaseSeparator) { + decimal = Common.localStorage.getItem("sse-settings-decimal-separator"); + group = Common.localStorage.getItem("sse-settings-group-separator"); + } if (reg!==null) this.api.asc_setLocale(parseInt(reg), decimal, group); else { diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 6f9444113..f76357a5d 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -773,6 +773,11 @@ define([ ''].join('')) }).on('selected', function(combo, record) { me.updateRegionalExample(record.value); + var isBaseSettings = me.chSeparator.getValue(); + if (isBaseSettings === 'checked') { + me.inputDecimalSeparator.setValue(me.api.asc_getDecimalSeparator(record.value), true); + me.inputThousandsSeparator.setValue(me.api.asc_getGroupSeparator(record.value), true); + } }); if (this.cmbRegSettings.scroller) this.cmbRegSettings.scroller.update({alwaysVisibleY: true}); @@ -782,8 +787,9 @@ define([ }).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(); + var lang = this.cmbRegSettings.getValue(), + decimal = this.api.asc_getDecimalSeparator(_.isNumber(lang) ? lang : undefined), + group = this.api.asc_getGroupSeparator(_.isNumber(lang) ? lang : undefined); this.inputDecimalSeparator.setValue(decimal); this.inputThousandsSeparator.setValue(group); } @@ -795,14 +801,15 @@ define([ var key = event.key, value = event.target.value; if (key !== 'ArrowLeft' && key !== 'ArrowDown' && key !== 'ArrowUp' && key !== 'ArrowRight' && - key !== 'Home' && key !== 'End' && key !== 'Backspace' && key !== 'Delete' && value.length > 0) { + key !== 'Home' && key !== 'End' && key !== 'Backspace' && key !== 'Delete' && value.length > 0 && + event.target.selectionEnd - event.target.selectionStart === 0) { event.preventDefault(); } }; this.inputDecimalSeparator = new Common.UI.InputField({ el: $markup.findById('#fms-decimal-separator'), - style: 'width: 50px;', + style: 'width: 35px;', validateOnBlur: false }); var $decimalSeparatorInput = this.inputDecimalSeparator.$el.find('input'); @@ -810,7 +817,7 @@ define([ this.inputThousandsSeparator = new Common.UI.InputField({ el: $markup.findById('#fms-thousands-separator'), - style: 'width: 50px;', + style: 'width: 35px;', validateOnBlur: false }); var $thousandsSeparatorInput = this.inputThousandsSeparator.$el.find('input'); @@ -909,15 +916,16 @@ define([ this.updateRegionalExample(value); var isBaseSettings = Common.Utils.InternalSettings.get("sse-settings-use-base-separator"); - this.chSeparator.setValue(isBaseSettings); + this.chSeparator.setValue(isBaseSettings, true); 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() || ''; + 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(); + var lang = this.cmbRegSettings.getValue(); + decimal = this.api.asc_getDecimalSeparator(_.isNumber(lang) ? lang : undefined); + group = this.api.asc_getGroupSeparator(_.isNumber(lang) ? lang : undefined); } this.inputDecimalSeparator.setValue(decimal); this.inputThousandsSeparator.setValue(group); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 806bc1532..a31103b5e 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1595,6 +1595,10 @@ "SSE.Views.FileMenuPanels.MainSettingsGeneral.txtPt": "Point", "SSE.Views.FileMenuPanels.MainSettingsGeneral.txtRu": "Russian", "SSE.Views.FileMenuPanels.MainSettingsGeneral.txtWin": "as Windows", + "SSE.Views.FileMenuPanels.MainSettingsGeneral.strSeparator": "Separator", + "SSE.Views.FileMenuPanels.MainSettingsGeneral.strUseSeparatorsBasedOnRegionalSettings": "Use separators based on regional settings", + "SSE.Views.FileMenuPanels.MainSettingsGeneral.strDecimalSeparator": "Decimal separator", + "SSE.Views.FileMenuPanels.MainSettingsGeneral.strThousandsSeparator": "Thousands separator", "SSE.Views.FileMenuPanels.MainSpellCheckSettings.strIgnoreWordsInUPPERCASE": "Ignore words in UPPERCASE", "SSE.Views.FileMenuPanels.MainSpellCheckSettings.strIgnoreWordsWithNumbers": "Ignore words with numbers", "SSE.Views.FileMenuPanels.MainSpellCheckSettings.strDictionaryLanguage": "Dictionary language",