From 7b36d55cd14ba4dd81cf2b27d110068fecca28fd Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Sep 2021 14:43:50 +0300 Subject: [PATCH 1/2] [SSE] Add text import settings --- apps/common/main/lib/view/OpenDialog.js | 15 +++++++--- .../main/app/view/AdvancedSeparatorDialog.js | 29 +++++++++++++++++-- apps/spreadsheeteditor/main/locale/en.json | 2 ++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index 313d4ad2f..750f2b4aa 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -291,10 +291,12 @@ define([ } var decimal = this.separatorOptions ? this.separatorOptions.decimal : undefined, - thousands = this.separatorOptions ? this.separatorOptions.thousands : undefined; + thousands = this.separatorOptions ? this.separatorOptions.thousands : undefined, + qualifier = this.separatorOptions ? this.separatorOptions.qualifier : undefined; var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar); decimal && options.asc_setNumberDecimalSeparator(decimal); thousands && options.asc_setNumberGroupSeparator(thousands); + qualifier && options.asc_setTextQualifier(qualifier); this.handler.call(this, state, { textOptions: options, range: this.txtDestRange ? this.txtDestRange.getValue() : '', @@ -433,6 +435,7 @@ define([ if (this.separatorOptions) { options.asc_setNumberDecimalSeparator(this.separatorOptions.decimal); options.asc_setNumberGroupSeparator(this.separatorOptions.thousands); + options.asc_setTextQualifier(this.separatorOptions.qualifier); } this.api.asc_TextImport(options, _.bind(this.previewCallback, this), this.type == Common.Utils.importTextType.Paste); break; @@ -441,6 +444,7 @@ define([ if (this.separatorOptions) { options.asc_setNumberDecimalSeparator(this.separatorOptions.decimal); options.asc_setNumberGroupSeparator(this.separatorOptions.thousands); + options.asc_setTextQualifier(this.separatorOptions.qualifier); } this.api.asc_decodeBuffer(this.preview, options, _.bind(this.previewCallback, this)); break; @@ -536,17 +540,20 @@ define([ var me = this, decimal = this.api.asc_getDecimalSeparator(), - thousands = this.api.asc_getGroupSeparator(); + thousands = this.api.asc_getGroupSeparator(), + qualifier = this.settings ? this.settings.asc_getTextQualifier() : '"'; (new SSE.Views.AdvancedSeparatorDialog({ props: { decimal: decimal, - thousands: thousands + thousands: thousands, + qualifier: qualifier }, handler: function(result, value) { if (result == 'ok') { me.separatorOptions = { decimal: (value.decimal.length > 0) ? value.decimal : decimal, - thousands: (value.thousands.length > 0) ? value.thousands : thousands + thousands: (value.thousands.length > 0) ? value.thousands : thousands, + qualifier: (value.qualifier.length > 0) ? value.qualifier : qualifier }; } } diff --git a/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js b/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js index 63a0e3d74..7a4d41e53 100644 --- a/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js +++ b/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js @@ -66,6 +66,12 @@ define([ '
', '
', '
', + '
', + '', + '
', + '
', + '
', + '
', '' ].join(''); @@ -92,6 +98,19 @@ define([ validateOnBlur: false }); + this.cmbQualifier = new Common.UI.ComboBox({ + el: $('#id-adv-separator-qualifier'), + style: 'width: 100px;', + menuStyle: 'min-width: 100px;', + cls: 'input-group-nr', + data: [ + {value: '"', displayValue: '"'}, + {value: '\'', displayValue: '\''}, + {value: null, displayValue: this.txtNone}], + editable: false, + takeFocusOnClose: true + }); + var $window = this.getChild(); $window.find('.btn').on('click', _.bind(this.onBtnClick, this)); @@ -99,7 +118,7 @@ define([ }, getFocusedComponents: function() { - return [this.inputDecimalSeparator, this.inputThousandsSeparator]; + return [this.inputDecimalSeparator, this.inputThousandsSeparator, this.cmbQualifier]; }, getDefaultFocusableComponent: function () { @@ -114,6 +133,7 @@ define([ if (props) { this.inputDecimalSeparator.setValue(props.decimal || ''); this.inputThousandsSeparator.setValue(props.thousands || ''); + this.cmbQualifier.setValue(props.qualifier || null); } }, @@ -128,7 +148,8 @@ define([ _handleInput: function(state) { if (this.options.handler) { - this.options.handler.call(this, state, {decimal: this.inputDecimalSeparator.getValue(), thousands: this.inputThousandsSeparator.getValue()}); + this.options.handler.call(this, state, {decimal: this.inputDecimalSeparator.getValue(), thousands: this.inputThousandsSeparator.getValue(), + qualifier: this.cmbQualifier.getValue()}); } this.close(); @@ -137,7 +158,9 @@ define([ textTitle: 'Advanced Settings', textLabel: 'Settings used to recognize numeric data', strDecimalSeparator: 'Decimal separator', - strThousandsSeparator: 'Thousands separator' + strThousandsSeparator: 'Thousands separator', + txtNone: '(none)', + textQualifier: 'Text qualifier' }, SSE.Views.AdvancedSeparatorDialog || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 0a8faae97..4018673a4 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1432,6 +1432,8 @@ "SSE.Views.AdvancedSeparatorDialog.strThousandsSeparator": "Thousands separator", "SSE.Views.AdvancedSeparatorDialog.textLabel": "Settings used to recognize numeric data", "SSE.Views.AdvancedSeparatorDialog.textTitle": "Advanced Settings", + "SSE.Views.AdvancedSeparatorDialog.txtNone": "(none)", + "SSE.Views.AdvancedSeparatorDialog.textQualifier": "Text qualifier", "SSE.Views.AutoFilterDialog.btnCustomFilter": "Custom Filter", "SSE.Views.AutoFilterDialog.textAddSelection": "Add current selection to filter", "SSE.Views.AutoFilterDialog.textEmptyItem": "{Blanks}", From 10db0f2bf54b132754aa76d0c62a1587fd0e973b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 24 Sep 2021 00:30:05 +0300 Subject: [PATCH 2/2] [SSE] Fix applying separator --- apps/common/main/lib/view/OpenDialog.js | 4 ++-- .../main/app/view/AdvancedSeparatorDialog.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index 750f2b4aa..47846abdb 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -292,7 +292,7 @@ define([ var decimal = this.separatorOptions ? this.separatorOptions.decimal : undefined, thousands = this.separatorOptions ? this.separatorOptions.thousands : undefined, - qualifier = this.separatorOptions ? this.separatorOptions.qualifier : undefined; + qualifier = this.separatorOptions ? this.separatorOptions.qualifier : '"'; var options = new Asc.asc_CTextOptions(encoding, delimiter, delimiterChar); decimal && options.asc_setNumberDecimalSeparator(decimal); thousands && options.asc_setNumberGroupSeparator(thousands); @@ -553,7 +553,7 @@ define([ me.separatorOptions = { decimal: (value.decimal.length > 0) ? value.decimal : decimal, thousands: (value.thousands.length > 0) ? value.thousands : thousands, - qualifier: (value.qualifier.length > 0) ? value.qualifier : qualifier + qualifier: value.qualifier }; } } diff --git a/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js b/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js index 7a4d41e53..0bf8e6a78 100644 --- a/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js +++ b/apps/spreadsheeteditor/main/app/view/AdvancedSeparatorDialog.js @@ -112,7 +112,7 @@ define([ }); var $window = this.getChild(); - $window.find('.btn').on('click', _.bind(this.onBtnClick, this)); + $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); this.afterRender(); },