[SSE] Separator settings

This commit is contained in:
Julia Svinareva 2019-12-06 16:46:11 +03:00
parent 8e28b90c73
commit 29b2eafb11
3 changed files with 46 additions and 25 deletions

View file

@ -387,11 +387,16 @@ define([
} }
var reg = Common.localStorage.getItem("sse-settings-reg-settings"), var reg = Common.localStorage.getItem("sse-settings-reg-settings"),
decimal = Common.localStorage.getItem("sse-settings-decimal-separator"), baseRegSettings = Common.Utils.InternalSettings.get("sse-settings-use-base-separator");
group = Common.localStorage.getItem("sse-settings-group-separator"); if (reg === null) {
decimal = decimal === 'undefined' ? undefined : decimal; reg = this.api.asc_getLocale();
group = group === 'undefined' ? undefined : group; }
if (reg!==null) this.api.asc_setLocale(parseInt(reg), decimal, group); 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(); menu.hide();

View file

@ -343,10 +343,10 @@ define([
.setUserName(this.appOptions.user.fullname); .setUserName(this.appOptions.user.fullname);
var reg = Common.localStorage.getItem("sse-settings-reg-settings"), 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"), decimal = Common.localStorage.getItem("sse-settings-decimal-separator"),
group = Common.localStorage.getItem("sse-settings-group-separator"); group = Common.localStorage.getItem("sse-settings-group-separator");
decimal = decimal === 'undefined' ? undefined : decimal; Common.Utils.InternalSettings.set("sse-settings-use-base-separator", isUseBaseSeparator);
group = group === 'undefined' ? undefined : group;
if (reg!==null) if (reg!==null)
this.api.asc_setLocale(parseInt(reg), decimal, group); this.api.asc_setLocale(parseInt(reg), decimal, group);
else { else {
@ -359,7 +359,7 @@ define([
this.api.asc_setLocale(reg, decimal, group); 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); Common.Utils.InternalSettings.set("sse-settings-r1c1", value);
this.api.asc_setR1C1Mode(value); this.api.asc_setR1C1Mode(value);

View file

@ -771,6 +771,12 @@ define([
labelText: this.strUseSeparatorsBasedOnRegionalSettings labelText: this.strUseSeparatorsBasedOnRegionalSettings
}).on('change', _.bind(function(field, newValue, oldValue, eOpts){ }).on('change', _.bind(function(field, newValue, oldValue, eOpts){
var checked = field.getValue() === 'checked'; 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.inputDecimalSeparator.setDisabled(checked);
this.inputThousandsSeparator.setDisabled(checked); this.inputThousandsSeparator.setDisabled(checked);
}, this)); }, this));
@ -892,14 +898,19 @@ define([
} }
this.updateRegionalExample(value); this.updateRegionalExample(value);
var decimal = this.api.asc_getDecimalSeparator(); var isBaseSettings = Common.Utils.InternalSettings.get("sse-settings-use-base-separator");
this.inputDecimalSeparator.setValue(decimal ? decimal : '');
var group = this.api.asc_getGroupSeparator();
this.inputThousandsSeparator.setValue(group ? group : '');
var isBaseSettings = _.isUndefined(decimal) && _.isUndefined(group);
this.chSeparator.setValue(isBaseSettings); 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.inputDecimalSeparator.setDisabled(isBaseSettings);
this.inputThousandsSeparator.setDisabled(isBaseSettings); this.inputThousandsSeparator.setDisabled(isBaseSettings);
}, },
@ -923,17 +934,22 @@ define([
if (this.cmbRegSettings.getSelectedRecord()) if (this.cmbRegSettings.getSelectedRecord())
Common.localStorage.setItem("sse-settings-reg-settings", this.cmbRegSettings.getValue()); Common.localStorage.setItem("sse-settings-reg-settings", this.cmbRegSettings.getValue());
var decimal, var value,
group; isChecked = this.chSeparator.isChecked();
if (this.chSeparator.isChecked()) { if (!isChecked) {
decimal = undefined; value = this.inputDecimalSeparator.getValue();
group = undefined; if (value.length > 0) {
} else { Common.localStorage.setItem("sse-settings-decimal-separator", value);
decimal = this.inputDecimalSeparator.getValue(); Common.Utils.InternalSettings.set("sse-settings-decimal-separator", value);
group = this.inputThousandsSeparator.getValue(); }
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.setBool("sse-settings-use-base-separator", isChecked);
Common.localStorage.setItem("sse-settings-group-separator", group); Common.Utils.InternalSettings.set("sse-settings-use-base-separator", isChecked);
Common.localStorage.save(); Common.localStorage.save();
if (this.menu) { if (this.menu) {