Skip to content

Commit

Permalink
Merge pull request 'fix/bugfix' (#37) from fix/bugfix into release/v8…
Browse files Browse the repository at this point in the history
….2.0
  • Loading branch information
Julia Radzhabova committed Sep 20, 2024
2 parents ff42637 + 8db6920 commit 98cba42
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
2 changes: 1 addition & 1 deletion apps/common/main/lib/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ define([], function () {
if (window.isrtl === undefined) {
if (window.nativeprocvars && window.nativeprocvars.rtl !== undefined)
window.isrtl = window.nativeprocvars.rtl;
else window.isrtl = !Common.Utils.isIE && Common.localStorage.getBool("ui-rtl", Common.Locale.isCurrentLanguageRtl());
else window.isrtl = Common.Locale.isCurrentLanguageRtl() ? !Common.Utils.isIE && Common.localStorage.getBool("ui-rtl", Common.Locale.isCurrentLanguageRtl()) : false;
}

return window.isrtl;
Expand Down
69 changes: 41 additions & 28 deletions apps/common/main/lib/view/OpenDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,16 @@ define([
delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null,
delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null;
(delimiter == -1) && (delimiter = null);
if (!this.closable && this.type == Common.Utils.importTextType.TXT) { //save last encoding only for opening txt files
Common.localStorage.setItem("de-settings-open-encoding", encoding);
}
if (this.type === Common.Utils.importTextType.CSV) { // only for csv files
Common.localStorage.setItem("sse-settings-csv-delimiter", delimiter === null ? -1 : delimiter);
Common.localStorage.setItem("sse-settings-csv-delimiter-char", delimiterChar || '');
Common.localStorage.setItem("sse-settings-csv-encoding", encoding);
if (this.type === Common.Utils.importTextType.TXT) { //save last encoding only for txt files
this._isEncodingChanged && Common.localStorage.setItem("de-settings-open-encoding", encoding);
} else if (this.type === Common.Utils.importTextType.CSV) { // only for csv files
this._isDelimChanged && Common.localStorage.setItem("sse-settings-csv-delimiter", delimiter === null ? -1 : delimiter);
this._isDelimCharChanged && Common.localStorage.setItem("sse-settings-csv-delimiter-char", delimiterChar || '');
this._isEncodingChanged && Common.localStorage.setItem("sse-settings-csv-encoding", encoding);
} else if (this.type === Common.Utils.importTextType.Paste || this.type === Common.Utils.importTextType.Columns || this.type === Common.Utils.importTextType.Data) {
this._isDelimChanged && Common.localStorage.setItem("sse-settings-data-delimiter", delimiter === null ? -1 : delimiter);
this._isDelimCharChanged && Common.localStorage.setItem("sse-settings-data-delimiter-char", delimiterChar || '');
this._isEncodingChanged && Common.localStorage.setItem("sse-settings-data-encoding", encoding);
}

var decimal = this.separatorOptions ? this.separatorOptions.decimal : undefined,
Expand All @@ -286,7 +289,7 @@ define([
},

initCodePages: function () {
var i, c, codepage, encodedata = [], listItems = [], length = 0, lcid_width = 0;
var i, c, codepage, encodedata = [], listItems = [], length = 0, lcid_width = 0, utf8 = 0;

if (this.codepages) {
encodedata = [];
Expand All @@ -296,6 +299,7 @@ define([
c[0] = codepage.asc_getCodePage();
c[1] = codepage.asc_getCodePageName();
c[2] = codepage.asc_getLcid();
(c[2]===65001) && (utf8 = i);

encodedata.push(c);
}
Expand Down Expand Up @@ -337,17 +341,22 @@ define([
});

this.cmbEncoding.setDisabled(false);
var encoding = (this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : encodedata[0][0];
if (!this.closable && this.type == Common.Utils.importTextType.TXT) { // only for opening txt files
var value = Common.localStorage.getItem("de-settings-open-encoding");
value && (encoding = parseInt(value));
} else if (this.type === Common.Utils.importTextType.CSV) { // only for csv files
var value = Common.localStorage.getItem("sse-settings-csv-encoding");
value && (encoding = parseInt(value));
var encoding = (this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : encodedata[utf8][0];
if (encoding===-1) {
if (this.type == Common.Utils.importTextType.TXT) { // only for opening txt files
var value = Common.localStorage.getItem("de-settings-open-encoding");
value && (encoding = parseInt(value));
} else if (this.type === Common.Utils.importTextType.CSV) { // only for csv files
var value = Common.localStorage.getItem("sse-settings-csv-encoding");
value && (encoding = parseInt(value));
} else if (this.type === Common.Utils.importTextType.Data) {
var value = Common.localStorage.getItem("sse-settings-data-encoding");
value && (encoding = parseInt(value));
}
(encoding===-1) && (encoding = encodedata[utf8][0]);
}
this.cmbEncoding.setValue(encoding);
if (this.preview)
this.cmbEncoding.on('selected', _.bind(this.onCmbEncodingSelect, this));
this.cmbEncoding.on('selected', _.bind(this.onCmbEncodingSelect, this));

var ul = this.cmbEncoding.cmpEl.find('ul'),
a = ul.find('li:nth(0) a'),
Expand All @@ -358,14 +367,12 @@ define([
if (this.type == Common.Utils.importTextType.CSV || this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns || this.type == Common.Utils.importTextType.Data) {
var delimiter = this.settings && this.settings.asc_getDelimiter() ? this.settings.asc_getDelimiter() : 4,
delimiterChar = this.settings && this.settings.asc_getDelimiterChar() ? this.settings.asc_getDelimiterChar() : '';
if (this.type == Common.Utils.importTextType.CSV) { // only for csv files
var value = Common.localStorage.getItem("sse-settings-csv-delimiter");
if (value) {
value = parseInt(value);
if (!isNaN(value)) {
delimiter = value;
(delimiter===-1) && (delimiterChar = Common.localStorage.getItem("sse-settings-csv-delimiter-char") || '');
}
var value = Common.localStorage.getItem(this.type == Common.Utils.importTextType.CSV ? "sse-settings-csv-delimiter" : "sse-settings-data-delimiter");
if (value) {
value = parseInt(value);
if (!isNaN(value)) {
delimiter = value;
(delimiter===-1) && (delimiterChar = Common.localStorage.getItem(this.type == Common.Utils.importTextType.CSV ? "sse-settings-csv-delimiter-char" : "sse-settings-data-delimiter-char") || '');
}
}

Expand Down Expand Up @@ -396,8 +403,7 @@ define([
value: delimiterChar
});
this.inputDelimiter.setVisible(delimiter===-1);
if (this.preview)
this.inputDelimiter.on ('changing', _.bind(this.updatePreview, this));
this.inputDelimiter.on ('changing', _.bind(this.onInputCharChanging, this));

if (this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns || this.type == Common.Utils.importTextType.Data) {
this.btnAdvanced = new Common.UI.Button({
Expand Down Expand Up @@ -538,10 +544,17 @@ define([
setTimeout(function(){me.inputDelimiter.focus();}, 10);
if (this.preview)
this.updatePreview();
this._isDelimChanged = true;
},

onInputCharChanging: function(){
this.preview && this.updatePreview();
this._isDelimCharChanged = true;
},

onCmbEncodingSelect: function(combo, record){
this.updatePreview();
this.preview && this.updatePreview();
this._isEncodingChanged = true;
},

onAdvancedClick: function() {
Expand Down

0 comments on commit 98cba42

Please sign in to comment.