From a35e5207999b47e95a238e2863a952b617bc96d4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 20 Apr 2020 19:14:48 +0300 Subject: [PATCH] [SSE] Show function arguments --- .../main/app/view/FormulaWizard.js | 131 +++++++++++++----- 1 file changed, 98 insertions(+), 33 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js index 150a23f0d..0656d210a 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js @@ -45,7 +45,8 @@ define([ SSE.Views.FormulaWizard = Common.UI.Window.extend(_.extend({ options: { - width: 400, + width: 420, + height: 460, header: true, style: 'min-width: 350px;', cls: 'modal-dlg', @@ -58,39 +59,14 @@ define([ }, options || {}); this.template = [ - '
', - '
', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', + '
', + '', + '
', + '
', - '', - '
', - '
', - '
', - '', - '
', - '', - '
', - '
', - '
', - '', - '
', '
', '
', - '', - '', + '', + '', '', '', '
', @@ -100,7 +76,9 @@ define([ this.options.tpl = _.template(this.template)(this.options); this.props = this.options.props; this.funcprops = this.options.funcprops; + this.api = this.options.api; this._noApply = false; + this.args = []; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -126,6 +104,13 @@ define([ $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); + this.scrollerY = new Common.UI.Scroller({ + el: $window.find('#formula-wizard-tbl-args').parent(), + minScrollbarLength : 20, + alwaysVisibleY: this.scrollAlwaysVisible + }); + this.scrollerY.scrollTop(0); + this.afterRender(); }, @@ -157,19 +142,99 @@ define([ props.desc ? $('#formula-wizard-desc').text(props.desc) : $('#formula-wizard-desc').addClass('hidden'); } if (this.props) { + var me = this; + // fill arguments var props = this.props; var result = props.asc_getFormulaResult(); $('#formula-wizard-value').html('' + this.textValue + ': ' + ((result!==undefined && result!==null)? result : '')); + $('#formula-wizard-name').html('' + this.textFunction + ': ' + props.name); + + var tbl = this.$window.find('#formula-wizard-tbl-args'); + var argtpl = '' + + '
' + + '
'; + var argmin = props.asc_getArgumentMin(), + argmax = props.asc_getArgumentMax(), + argres = props.asc_getArgumentsResult(), + argtype = props.asc_getArgumentsType(), + argcount = 0, + lasttype; + for (var i=0; i' + this.args[argcount].argName + ''); + else + this.args[argcount].lblName.html(this.args[argcount].argName); + this.args[argcount].lblValue.text(' = '+ (argres && (argres.length>argcount) && argres[argcount]!==null ? argres[argcount] : this.args[argcount].argType)); + argcount++; + } + if (i>=argmin && (typeof type == 'object')) // show only one repeatable argument + break; + } + this.scrollerY.update(); } }, + getArgType: function(type) { + var str = ''; + switch (type) { + case Asc.c_oAscFormulaArgumentType.number: + str = 'number'; + break; + case Asc.c_oAscFormulaArgumentType.text: + str = 'text'; + break; + case Asc.c_oAscFormulaArgumentType.reference: + str = 'reference'; + break; + case Asc.c_oAscFormulaArgumentType.any: + str = 'any'; + break; + case Asc.c_oAscFormulaArgumentType.logical: + str = 'logical'; + break; + } + return str; + }, + getSettings: function() { return {}; }, + close: function () { + Common.UI.Window.prototype.close.call(this); + this.api.asc_closeCellEditor(true); + }, + textTitle: 'Function Argumens', - textValue: 'Value' + textValue: 'Formula result', + textFunction: 'Function' }, SSE.Views.FormulaWizard || {})) }); \ No newline at end of file