From 59997a0212b5bcef4ac5b52f2bc159e73b0a314e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 18 Apr 2019 11:39:58 +0300 Subject: [PATCH] [SSE] Disable parsing text for multiselect, add error for empty source --- apps/common/main/lib/view/OpenDialog.js | 6 ++++-- .../main/app/controller/Main.js | 7 ++++++- .../main/app/view/CellSettings.js | 18 +++++++++++++++++- apps/spreadsheeteditor/main/locale/en.json | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index e6c5ea5fc..79b608529 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -144,6 +144,7 @@ define([ this.handler = _options.handler; this.type = _options.type; this.preview = _options.preview; + this.previewData = _options.previewData; this.warning = _options.warning || false; this.closable = _options.closable; this.codepages = _options.codepages; @@ -188,8 +189,9 @@ define([ }); } else { this.initCodePages(); - if (this.preview) - this.updatePreview(); + if (this.preview) { + (this.previewData) ? this.previewCallback(this.previewData) : this.updatePreview(); + } } this.onPrimary = function() { me._handleInput('ok'); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index ab08089e4..c0e66f3d9 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1365,6 +1365,10 @@ define([ config.msg = this.errorEmailClient; break; + case Asc.c_oAscError.ID.NoDataToParse: + config.msg = this.errorNoDataToParse; + break; + default: config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id); break; @@ -2495,7 +2499,8 @@ define([ errorEmailClient: 'No email client could be found', txtPrintArea: 'Print_Area', txtTable: 'Table', - textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.
Please contact our Sales Department to get a quote.' + textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.
Please contact our Sales Department to get a quote.', + errorNoDataToParse: 'No data was selected to parse.' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/app/view/CellSettings.js b/apps/spreadsheeteditor/main/app/view/CellSettings.js index 07520e2ec..8fed6edaf 100644 --- a/apps/spreadsheeteditor/main/app/view/CellSettings.js +++ b/apps/spreadsheeteditor/main/app/view/CellSettings.js @@ -71,11 +71,13 @@ define([ this._state = { BackColor: undefined, DisabledControls: true, - CellAngle: undefined + CellAngle: undefined, + CSVOptions: new Asc.asc_CCSVAdvancedOptions(0, 4, '') }; this.lockedControls = []; this._locked = true; this.isEditCell = false; + this.isMultiSelect = false; this.BorderType = 1; this.render(); @@ -140,12 +142,20 @@ define([ }, onTextToColumn: function() { + this.api.asc_TextImport(this._state.CSVOptions, _.bind(this.onTextToColumnCallback, this), false); + }, + + onTextToColumnCallback: function(data) { + if (!data || !data.length) return; + var me = this; (new Common.Views.OpenDialog({ title: me.txtImportWizard, closable: true, type: Common.Utils.importTextType.Columns, preview: true, + previewData: data, + settings: this._state.CSVOptions, api: me.api, handler: function (result, encoding, delimiter, delimiterChar) { if (result == 'ok') { @@ -168,6 +178,7 @@ define([ this.api = o; if (o) { this.api.asc_registerCallback('asc_onEditCell', this.onApiEditCell.bind(this)); + this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onApiSelectionChanged, this)); } return this; }, @@ -358,6 +369,10 @@ define([ this.disableControls(this._locked); }, + onApiSelectionChanged: function(info) { + this.isMultiSelect = info.asc_getFlags().asc_getMultiselect() || info.asc_getSelectedColsCount()>1; + }, + setLocked: function (locked) { this._locked = locked; }, @@ -372,6 +387,7 @@ define([ item.setDisabled(disable); }); } + this.btnTextToColumn.setDisabled(disable || this.isMultiSelect); }, textBorders: 'Border\'s Style', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 0dcac7cb2..f27301a55 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -725,6 +725,7 @@ "SSE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider purchasing a commercial license.", "SSE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider purchasing a commercial license.", "SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", + "SSE.Controllers.Main.errorNoDataToParse": "No data was selected to parse.", "SSE.Controllers.Print.strAllSheets": "All Sheets", "SSE.Controllers.Print.textWarning": "Warning", "SSE.Controllers.Print.txtCustom": "Custom",