From 709cf9fb792021f1a44aba64775ba3859f913bcc Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 18 May 2020 14:00:10 +0300 Subject: [PATCH] [SSE] Refactoring range selection --- .../main/app/controller/DocumentHolder.js | 4 ++-- .../main/app/view/CellRangeDialog.js | 13 ++++++++++--- .../main/app/view/FormulaWizard.js | 10 +++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 734445dfb..984e32387 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -258,7 +258,7 @@ define([ click: function(e) { if (me.api) { me.api.isTextAreaBlur = false; - if (e.target.localName == 'canvas' && !me.isEditFormula) { + if (e.target.localName == 'canvas' && (!me.isEditFormula || me.rangeSelectionMode)) { if (me._preventClick) me._preventClick = false; else @@ -2030,7 +2030,7 @@ define([ }, onFormulaCompleteMenu: function(funcarr) { - if (!this.documentHolder.funcMenu || Common.Utils.ModalWindow.isVisible()) return; + if (!this.documentHolder.funcMenu || Common.Utils.ModalWindow.isVisible() || this.rangeSelectionMode) return; if (funcarr) { var me = this, diff --git a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js index 8fbf065e6..151a76efa 100644 --- a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js +++ b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js @@ -103,11 +103,11 @@ define([ setSettings: function(settings) { var me = this; + this.settings = settings; this.inputRange.setValue(settings.range ? settings.range : ''); if (settings.type===undefined) settings.type = Asc.c_oAscSelectionDialogType.Chart; - this.type = settings.type; if (settings.api) { me.api = settings.api; @@ -122,12 +122,16 @@ define([ if (settings.validation) { return settings.validation.call(me, value); } else { + if (settings.type === Asc.c_oAscSelectionDialogType.Function) { + settings.argvalues[settings.argindex] = value; + me.api.asc_insertArgumentsInFormula(settings.argvalues); + } var isvalid = (settings.type === Asc.c_oAscSelectionDialogType.Function) || me.api.asc_checkDataRange(settings.type, value, false); return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true; } }; - if (me.type == Asc.c_oAscSelectionDialogType.Function) { + if (settings.type == Asc.c_oAscSelectionDialogType.Function) { _.delay(function(){ me.inputRange._input.focus(); if (settings.selection) { @@ -147,7 +151,7 @@ define([ }, onApiRangeChanged: function(name) { - if (this.type == Asc.c_oAscSelectionDialogType.Function) { + if (this.settings.type == Asc.c_oAscSelectionDialogType.Function) { var oldlen = this._addedTextLength || 0, val = this.inputRange.getValue(), input = this.inputRange._input[0], @@ -159,6 +163,9 @@ define([ val = val.substring(0, start) + add + name + val.substring(end, val.length); this.inputRange.setValue(val); input.selectionStart = input.selectionEnd = start + add.length + this._addedTextLength; + + this.settings.argvalues[this.settings.argindex] = val; + this.api.asc_insertArgumentsInFormula(this.settings.argvalues); } else this.inputRange.setValue(name); if (this.inputRange.cmpEl.hasClass('error')) diff --git a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js index ff9589c99..3717d4f13 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js @@ -263,10 +263,8 @@ define([ }).on('changing', function(input, newValue, oldValue, e) { if (newValue == oldValue) return; var index = input.options.index, - arg = me.args[index], - values = me.getArgumentsValue(); - (index' + arg.argTypeName + '' )); @@ -367,7 +365,9 @@ define([ api : me.api, range : !_.isEmpty(input.getValue()) ? input.getValue() : '', type : Asc.c_oAscSelectionDialogType.Function, - selection: {start: input._input[0].selectionStart, end: input._input[0].selectionEnd} + selection: {start: input._input[0].selectionStart, end: input._input[0].selectionEnd}, + argvalues : me.getArgumentsValue(), + argindex : input.options.index }); } },