From 3799f6ecdb3a876e273a979f5d00b64df6ff5c7c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 18 May 2020 20:01:28 +0300 Subject: [PATCH] [SSE] Fix formula arguments --- .../main/app/view/FormulaWizard.js | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js index 3717d4f13..f19c4ec1c 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js @@ -259,25 +259,12 @@ define([ validateOnChange: true, validateOnBlur: false }).on('changed:after', function(input, newValue, oldValue, e) { - if (newValue == oldValue) return; }).on('changing', function(input, newValue, oldValue, e) { if (newValue == oldValue) return; - var index = input.options.index, - arg = me.args[index]; - var res = me.api.asc_insertArgumentsInFormula(me.getArgumentsValue(), index, arg.argType), - argres = res ? res.asc_getArgumentsResult() : undefined; - argres = argres ? argres[index] : undefined; - arg.lblValue.html('= '+ (argres!==null && argres !==undefined ? argres : '' + arg.argTypeName + '' )); - - var result = res ? res.asc_getFunctionResult() : undefined; - me.lblFunctionResult.html('= ' + ((result!==undefined && result!==null)? result : '')); - result = res ? res.asc_getFormulaResult() : undefined; - me.lblFormulaResult.html('' + me.textValue + ': ' + ((result!==undefined && result!==null)? result : '')); - - }); + me.onInputChanging(input, newValue, oldValue); + }).on('button:click', _.bind(this.onSelectData, this)); txt.setValue((argval!==undefined && argval!==null) ? argval : ''); txt._input.on('focus', _.bind(this.onSelectArgument, this, txt)); - txt.on('button:click', _.bind(this.onSelectData, this)); me.args.push({ index: argcount, @@ -296,6 +283,21 @@ define([ me.args[argcount].lblValue.html('= '+ ( argres!==null && argres!==undefined ? argres : '' + me.args[argcount].argTypeName + '')); }, + onInputChanging: function(input, newValue, oldValue, e) { + var me = this, + index = input.options.index, + arg = me.args[index]; + var res = me.api.asc_insertArgumentsInFormula(me.getArgumentsValue(), index, arg.argType), + argres = res ? res.asc_getArgumentsResult() : undefined; + argres = argres ? argres[index] : undefined; + arg.lblValue.html('= '+ (argres!==null && argres !==undefined ? argres : '' + arg.argTypeName + '' )); + + var result = res ? res.asc_getFunctionResult() : undefined; + me.lblFunctionResult.html('= ' + ((result!==undefined && result!==null)? result : '')); + result = res ? res.asc_getFormulaResult() : undefined; + me.lblFormulaResult.html('' + me.textValue + ': ' + ((result!==undefined && result!==null)? result : '')); + }, + getArgumentsValue: function() { var res = [], len = this.args.length, @@ -346,15 +348,18 @@ define([ var me = this; if (me.api) { + var changedValue = input.getValue(); var handlerDlg = function(dlg, result) { if (result == 'ok') { - input.setValue(dlg.getSettings()); + changedValue = dlg.getSettings(); } }; var win = new SSE.Views.CellRangeDialog({ handler: handlerDlg }).on('close', function() { + input.setValue(changedValue); + me.onInputChanging(input); me.show(); });