[SSE] Formula dialog: add 10 last used functions. Refactoring.
This commit is contained in:
parent
2e16e770e8
commit
1acd9be0d8
|
@ -82,6 +82,8 @@ define([
|
|||
this.api = api;
|
||||
|
||||
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 );
|
||||
|
||||
|
@ -93,7 +95,8 @@ define([
|
|||
formulasGroups : this.formulasGroups,
|
||||
handler : function (func) {
|
||||
if (func) {
|
||||
me.api.asc_insertFormula(func, Asc.c_oAscPopUpSelectorType.Func);
|
||||
me.api.asc_insertFormula(func.name, Asc.c_oAscPopUpSelectorType.Func);
|
||||
me.updateLast10Formulas(func.origin);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -180,7 +183,6 @@ define([
|
|||
|
||||
if (this.formulas.$window) {
|
||||
this.formulas.fillFormulasGroups();
|
||||
this.formulas.fillFunctions('All');
|
||||
}
|
||||
}
|
||||
this.formulas.show();
|
||||
|
@ -192,6 +194,40 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
updateLast10Formulas: function(formula) {
|
||||
var arr = Common.Utils.InternalSettings.get("sse-settings-func-last") || 'SUM;AVERAGE;IF;HYPERLINK;COUNT;MAX;SIN;SUMIF;PMT;STDEV';
|
||||
arr = arr.split(';');
|
||||
var idx = _.indexOf(arr, formula);
|
||||
arr.splice((idx<0) ? arr.length-1 : idx, 1);
|
||||
arr.unshift(formula);
|
||||
var val = arr.join(';');
|
||||
Common.localStorage.setItem("sse-settings-func-last", val);
|
||||
Common.Utils.InternalSettings.set("sse-settings-func-last", val);
|
||||
|
||||
if (this.formulasGroups) {
|
||||
var group = this.formulasGroups.findWhere({name : 'Last10'});
|
||||
group && group.set('functions', this.loadingLast10Formulas(this.getDescription(Common.Utils.InternalSettings.get("sse-settings-func-locale"))));
|
||||
}
|
||||
},
|
||||
|
||||
loadingLast10Formulas: function(descrarr) {
|
||||
var arr = (Common.Utils.InternalSettings.get("sse-settings-func-last") || 'SUM;AVERAGE;IF;HYPERLINK;COUNT;MAX;SIN;SUMIF;PMT;STDEV').split(';'),
|
||||
separator = this.api.asc_getFunctionArgumentSeparator(),
|
||||
functions = [];
|
||||
for (var j = 0; j < arr.length; j++) {
|
||||
var funcname = arr[j];
|
||||
functions.push(new SSE.Models.FormulaModel({
|
||||
index : j,
|
||||
group : 'Last10',
|
||||
name : this.api.asc_getFormulaLocaleName(funcname),
|
||||
origin: funcname,
|
||||
args : ((descrarr && descrarr[funcname]) ? descrarr[funcname].a : '').replace(/[,;]/g, separator),
|
||||
desc : (descrarr && descrarr[funcname]) ? descrarr[funcname].d : ''
|
||||
}));
|
||||
}
|
||||
return functions;
|
||||
},
|
||||
|
||||
loadingFormulas: function (descrarr) {
|
||||
var i = 0, j = 0,
|
||||
ascGroupName,
|
||||
|
@ -204,20 +240,33 @@ define([
|
|||
info = null,
|
||||
allFunctions = [],
|
||||
allFunctionsGroup = null,
|
||||
last10FunctionsGroup = null,
|
||||
separator = this.api.asc_getFunctionArgumentSeparator();
|
||||
|
||||
if (store) {
|
||||
ascGroupName = 'Last10';
|
||||
last10FunctionsGroup = new SSE.Models.FormulaGroup ({
|
||||
name : ascGroupName,
|
||||
index : index,
|
||||
store : store
|
||||
});
|
||||
if (last10FunctionsGroup) {
|
||||
last10FunctionsGroup.set('functions', this.loadingLast10Formulas(descrarr));
|
||||
store.push(last10FunctionsGroup);
|
||||
index += 1;
|
||||
}
|
||||
|
||||
allFunctionsGroup = new SSE.Models.FormulaGroup ({
|
||||
name : 'All',
|
||||
index : index,
|
||||
store : store
|
||||
});
|
||||
if (allFunctionsGroup) {
|
||||
store.push(allFunctionsGroup);
|
||||
index += 1;
|
||||
}
|
||||
|
||||
if (allFunctionsGroup) {
|
||||
index += 1;
|
||||
|
||||
store.push(allFunctionsGroup);
|
||||
|
||||
info = this.api.asc_getFormulasInfo();
|
||||
|
||||
for (i = 0; i < info.length; i += 1) {
|
||||
|
@ -240,6 +289,7 @@ define([
|
|||
index : funcInd,
|
||||
group : ascGroupName,
|
||||
name : ascFunctions[j].asc_getLocaleName(),
|
||||
origin: funcname,
|
||||
args : ((descrarr && descrarr[funcname]) ? descrarr[funcname].a : '').replace(/[,;]/g, separator),
|
||||
desc : (descrarr && descrarr[funcname]) ? descrarr[funcname].d : ''
|
||||
});
|
||||
|
|
|
@ -54,6 +54,7 @@ define([
|
|||
index : 0,
|
||||
group : null,
|
||||
name : null,
|
||||
origin : null,
|
||||
args : null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ define([
|
|||
|
||||
var name = '', translate = '',
|
||||
descriptions = ['All', 'Cube', 'Database', 'DateAndTime', 'Engineering', 'Financial', 'Information',
|
||||
'Logical', 'LookupAndReference', 'Mathematic', 'Statistical', 'TextAndData' ];
|
||||
'Logical', 'LookupAndReference', 'Mathematic', 'Statistical', 'TextAndData', 'Last10' ];
|
||||
for (var i=0; i<descriptions.length; i++) {
|
||||
name = descriptions[i];
|
||||
translate = 'sCategory' + name;
|
||||
|
@ -122,7 +122,6 @@ define([
|
|||
}
|
||||
|
||||
this.fillFormulasGroups();
|
||||
this.fillFunctions('All');
|
||||
},
|
||||
show: function () {
|
||||
if (this.$window) {
|
||||
|
@ -149,6 +148,9 @@ define([
|
|||
this.mask.on('mousedown',_.bind(this.onUpdateFocus, this));
|
||||
this.$window.on('mousedown',_.bind(this.onUpdateFocus, this));
|
||||
|
||||
if (this.cmbFuncGroup.getValue() == 0)
|
||||
this.fillFunctions('Last10');
|
||||
|
||||
if (this.cmbListFunctions) {
|
||||
_.delay(function (me) {
|
||||
me.cmbListFunctions.$el.find('.listview').focus();
|
||||
|
@ -197,18 +199,9 @@ define([
|
|||
var funcId, functions, func;
|
||||
|
||||
if (this.formulasGroups) {
|
||||
funcId = record.get('id');
|
||||
if (!_.isUndefined(funcId)) {
|
||||
functions = this.formulasGroups.at(0).get('functions');
|
||||
if (functions) {
|
||||
func = _.find(functions, function (f) { if (f.get('index') === funcId) { return f; } return null; });
|
||||
if (func) {
|
||||
this.applyFunction = func.get('name');
|
||||
this.syntaxLabel.text(this.applyFunction + func.get('args'));
|
||||
this.descLabel.text(func.get('desc'));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.applyFunction = {name: record.get('value'), origin: record.get('origin')};
|
||||
this.syntaxLabel.text(this.applyFunction.name + record.get('args'));
|
||||
this.descLabel.text(record.get('desc'));
|
||||
}
|
||||
},
|
||||
onPrimary: function(list, record, event) {
|
||||
|
@ -258,6 +251,8 @@ define([
|
|||
this.cmbFuncGroup.setData(groupsListItems);
|
||||
}
|
||||
this.cmbFuncGroup.setValue(0);
|
||||
this.fillFunctions('Last10');
|
||||
|
||||
}
|
||||
},
|
||||
fillFunctions: function (name) {
|
||||
|
@ -297,13 +292,16 @@ define([
|
|||
id : functions[i].get('index'),
|
||||
selected : i < 1,
|
||||
allowSelected : true,
|
||||
value : functions[i].get('name')
|
||||
value : functions[i].get('name'),
|
||||
args : functions[i].get('args'),
|
||||
desc : functions[i].get('desc'),
|
||||
origin : functions[i].get('origin')
|
||||
}));
|
||||
}
|
||||
|
||||
this.applyFunction = functions[0].get('name');
|
||||
this.applyFunction = {name: functions[0].get('name'), origin: functions[0].get('origin')};
|
||||
|
||||
this.syntaxLabel.text(this.applyFunction + functions[0].get('args'));
|
||||
this.syntaxLabel.text(this.applyFunction.name + functions[0].get('args'));
|
||||
this.descLabel.text(functions[0].get('desc'));
|
||||
this.cmbListFunctions.scroller.update({
|
||||
minScrollbarLength : 40,
|
||||
|
@ -401,6 +399,7 @@ define([
|
|||
cancelButtonText: 'Cancel',
|
||||
okButtonText: 'Ok',
|
||||
sCategoryAll: 'All',
|
||||
sCategoryLast10: '10 last used',
|
||||
sCategoryLogical: 'Logical',
|
||||
sCategoryCube: 'Cube',
|
||||
sCategoryDatabase: 'Database',
|
||||
|
@ -416,6 +415,7 @@ define([
|
|||
textListDescription: 'Select Function',
|
||||
sDescription: 'Description',
|
||||
sCategoryAll_de: 'Alle',
|
||||
sCategoryLast10_de: '10 zuletzt verwendete',
|
||||
sCategoryCube_de: 'Cube',
|
||||
sCategoryDatabase_de: 'Datenbank',
|
||||
sCategoryDateAndTime_de: 'Datum und Uhrzeit',
|
||||
|
@ -428,6 +428,7 @@ define([
|
|||
sCategoryStatistical_de: 'Statistik',
|
||||
sCategoryTextAndData_de: 'Text und Daten',
|
||||
sCategoryAll_ru: 'Все',
|
||||
sCategoryLast10_ru: '10 недавно использовавшихся',
|
||||
sCategoryCube_ru: 'Кубические',
|
||||
sCategoryDatabase_ru: 'Базы данных',
|
||||
sCategoryDateAndTime_ru: 'Дата и время',
|
||||
|
@ -441,6 +442,7 @@ define([
|
|||
sCategoryTextAndData_ru: 'Текст и данные',
|
||||
txtTitle: 'Insert Function',
|
||||
sCategoryAll_es: 'Todo',
|
||||
sCategoryLast10_es: '10 últimas utilizadas',
|
||||
sCategoryLogical_es: 'Lógico',
|
||||
sCategoryCube_es: 'Cubo',
|
||||
sCategoryDatabase_es: 'Base de Datos',
|
||||
|
@ -453,6 +455,7 @@ define([
|
|||
sCategoryStatistical_es: 'Estadístico',
|
||||
sCategoryTextAndData_es: 'Texto y datos',
|
||||
sCategoryAll_fr: 'Tout',
|
||||
sCategoryLast10_fr: '10 dernières utilisées',
|
||||
sCategoryLogical_fr: 'Logique',
|
||||
sCategoryCube_fr: 'Cube',
|
||||
sCategoryDatabase_fr: 'Base de données',
|
||||
|
@ -465,6 +468,7 @@ define([
|
|||
sCategoryStatistical_fr: 'Statistiques',
|
||||
sCategoryTextAndData_fr: 'Texte et données',
|
||||
sCategoryAll_pl: 'Wszystko',
|
||||
sCategoryLast10_pl: '10 ostatnio używanych',
|
||||
sCategoryLogical_pl: 'Logiczny',
|
||||
sCategoryCube_pl: 'Sześcian',
|
||||
sCategoryDatabase_pl: 'Baza danych',
|
||||
|
|
Loading…
Reference in a new issue