From e25baee4cc9bd61f09ac728a653ab705e7b93331 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 12 Aug 2019 14:48:20 +0300 Subject: [PATCH] [SSE] Optimize loading of formulas --- apps/common/main/lib/component/Mixtbar.js | 1 + .../main/app/controller/FormulaDialog.js | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/common/main/lib/component/Mixtbar.js b/apps/common/main/lib/component/Mixtbar.js index ba690d3ec..96169d94e 100644 --- a/apps/common/main/lib/component/Mixtbar.js +++ b/apps/common/main/lib/component/Mixtbar.js @@ -286,6 +286,7 @@ define([ if ( $tp.length ) { $tp.addClass('active'); } + this.fireEvent('tab:active', [tab]); } }, diff --git a/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js b/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js index 42994f29f..d80842a20 100644 --- a/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js +++ b/apps/spreadsheeteditor/main/app/controller/FormulaDialog.js @@ -83,7 +83,8 @@ define([ 'function:apply': this.applyFunction }, 'Toolbar': { - 'function:apply': this.applyFunction + 'function:apply': this.applyFunction, + 'tab:active': this.onTabActive } }); }, @@ -114,7 +115,7 @@ define([ if (this.formulasGroups && this.api) { Common.Utils.InternalSettings.set("sse-settings-func-last", Common.localStorage.getItem("sse-settings-func-last")); - this.reloadTranslations(Common.localStorage.getItem("sse-settings-func-locale") || this.appOptions.lang ); + this.reloadTranslations(Common.localStorage.getItem("sse-settings-func-locale") || this.appOptions.lang, true); var me = this; @@ -155,7 +156,7 @@ define([ this.appOptions.lang = data.config.lang; }, - reloadTranslations: function (lang) { + reloadTranslations: function (lang, suppressEvent) { var me = this; lang = (lang || 'en').split(/[\-_]/)[0].toLowerCase(); @@ -178,18 +179,18 @@ define([ } if (me.langDescJson[lang]) - me.loadingFormulas(me.langDescJson[lang]); + me.loadingFormulas(me.langDescJson[lang], suppressEvent); else { Common.Utils.loadConfig('resources/formula-lang/' + lang + '_desc.json', function (config) { if ( config != 'error' ) { me.langDescJson[lang] = config; - me.loadingFormulas(config); + me.loadingFormulas(config, suppressEvent); } else { Common.Utils.loadConfig('resources/formula-lang/en_desc.json', function (config) { me.langDescJson[lang] = (config != 'error') ? config : null; - me.loadingFormulas(me.langDescJson[lang]); + me.loadingFormulas(me.langDescJson[lang], suppressEvent); }); } }); @@ -258,7 +259,7 @@ define([ return functions; }, - loadingFormulas: function (descrarr) { + loadingFormulas: function (descrarr, suppressEvent) { var i = 0, j = 0, ascGroupName, ascFunctions, @@ -342,8 +343,16 @@ define([ _.sortBy(allFunctions, function (model) {return model.get('name'); })); } } - this.formulaTab && this.formulaTab.fillFunctions(); + !suppressEvent && this.formulaTab && this.formulaTab.fillFunctions(); }, + + onTabActive: function (tab) { + if ( tab == 'formula' && !this._formulasInited && this.formulaTab) { + this.formulaTab.fillFunctions(); + this._formulasInited = true; + } + }, + sCategoryAll: 'All', sCategoryLast10: '10 last used', sCategoryLogical: 'Logical',