[SSE] Optimize loading of formulas

This commit is contained in:
Julia Radzhabova 2019-08-12 14:48:20 +03:00
parent 66b9884086
commit e25baee4cc
2 changed files with 18 additions and 8 deletions

View file

@ -286,6 +286,7 @@ define([
if ( $tp.length ) { if ( $tp.length ) {
$tp.addClass('active'); $tp.addClass('active');
} }
this.fireEvent('tab:active', [tab]);
} }
}, },

View file

@ -83,7 +83,8 @@ define([
'function:apply': this.applyFunction 'function:apply': this.applyFunction
}, },
'Toolbar': { 'Toolbar': {
'function:apply': this.applyFunction 'function:apply': this.applyFunction,
'tab:active': this.onTabActive
} }
}); });
}, },
@ -114,7 +115,7 @@ define([
if (this.formulasGroups && this.api) { if (this.formulasGroups && this.api) {
Common.Utils.InternalSettings.set("sse-settings-func-last", Common.localStorage.getItem("sse-settings-func-last")); 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; var me = this;
@ -155,7 +156,7 @@ define([
this.appOptions.lang = data.config.lang; this.appOptions.lang = data.config.lang;
}, },
reloadTranslations: function (lang) { reloadTranslations: function (lang, suppressEvent) {
var me = this; var me = this;
lang = (lang || 'en').split(/[\-_]/)[0].toLowerCase(); lang = (lang || 'en').split(/[\-_]/)[0].toLowerCase();
@ -178,18 +179,18 @@ define([
} }
if (me.langDescJson[lang]) if (me.langDescJson[lang])
me.loadingFormulas(me.langDescJson[lang]); me.loadingFormulas(me.langDescJson[lang], suppressEvent);
else { else {
Common.Utils.loadConfig('resources/formula-lang/' + lang + '_desc.json', Common.Utils.loadConfig('resources/formula-lang/' + lang + '_desc.json',
function (config) { function (config) {
if ( config != 'error' ) { if ( config != 'error' ) {
me.langDescJson[lang] = config; me.langDescJson[lang] = config;
me.loadingFormulas(config); me.loadingFormulas(config, suppressEvent);
} else { } else {
Common.Utils.loadConfig('resources/formula-lang/en_desc.json', Common.Utils.loadConfig('resources/formula-lang/en_desc.json',
function (config) { function (config) {
me.langDescJson[lang] = (config != 'error') ? config : null; 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; return functions;
}, },
loadingFormulas: function (descrarr) { loadingFormulas: function (descrarr, suppressEvent) {
var i = 0, j = 0, var i = 0, j = 0,
ascGroupName, ascGroupName,
ascFunctions, ascFunctions,
@ -342,8 +343,16 @@ define([
_.sortBy(allFunctions, function (model) {return model.get('name'); })); _.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', sCategoryAll: 'All',
sCategoryLast10: '10 last used', sCategoryLast10: '10 last used',
sCategoryLogical: 'Logical', sCategoryLogical: 'Logical',