Merge pull request #234 from ONLYOFFICE/feature/sse-calculate

Feature/sse calculate. Fix Bug 14482
This commit is contained in:
Julia Radzhabova 2019-08-28 11:16:32 +03:00 committed by GitHub
commit 2c582b15bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 2 deletions

View file

@ -80,7 +80,8 @@ define([
} }
}, },
'FormulaTab': { 'FormulaTab': {
'function:apply': this.applyFunction 'function:apply': this.applyFunction,
'function:calculate': this.onCalculate
}, },
'Toolbar': { 'Toolbar': {
'function:apply': this.applyFunction, 'function:apply': this.applyFunction,
@ -353,6 +354,13 @@ define([
} }
}, },
onCalculate: function(calc) {
var type = calc.type;
if (type === Asc.c_oAscCalculateType.All || type === Asc.c_oAscCalculateType.ActiveSheet) {
this.api && this.api.asc_calculate(type);
}
},
sCategoryAll: 'All', sCategoryAll: 'All',
sCategoryLast10: '10 last used', sCategoryLast10: '10 last used',
sCategoryLogical: 'Logical', sCategoryLogical: 'Logical',

View file

@ -172,6 +172,10 @@
<span class="btn-slot text x-huge" id="slot-btn-math"></span> <span class="btn-slot text x-huge" id="slot-btn-math"></span>
<span class="btn-slot text x-huge" id="slot-btn-more"></span> <span class="btn-slot text x-huge" id="slot-btn-more"></span>
</div> </div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-calculate"></span>
</div>
</section> </section>
<section class="panel" data-tab="data"> <section class="panel" data-tab="data">
<div class="group"> <div class="group">

View file

@ -57,6 +57,12 @@ define([
me.btnFormula.on('click', function(){ me.btnFormula.on('click', function(){
me.fireEvent('function:apply', [{name: 'more', origin: 'more'}]); me.fireEvent('function:apply', [{name: 'more', origin: 'more'}]);
}); });
me.btnCalculate.on('click', function () {
me.fireEvent('function:calculate', [{type: Asc.c_oAscCalculateType.All}]);
});
me.btnCalculate.menu.on('item:click', function (menu, item, e) {
me.fireEvent('function:calculate', [{type: item.value}]);
});
} }
return { return {
options: {}, options: {},
@ -214,6 +220,18 @@ define([
Common.Utils.injectComponent($host.find('#slot-btn-more'), this.btnMore); Common.Utils.injectComponent($host.find('#slot-btn-more'), this.btnMore);
this.lockedControls.push(this.btnMore); this.lockedControls.push(this.btnMore);
this.btnCalculate = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-cell-group',
caption: this.txtCalculation,
split: true,
menu: true,
disabled: true,
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth]
});
Common.Utils.injectComponent($host.find('#slot-btn-calculate'), this.btnCalculate);
this.lockedControls.push(this.btnCalculate);
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
}, },
@ -226,6 +244,17 @@ define([
(new Promise(function (accept, reject) { (new Promise(function (accept, reject) {
accept(); accept();
})).then(function(){ })).then(function(){
me.btnCalculate.updateHint([me.tipCalculateTheEntireWorkbook + Common.Utils.String.platformKey('F9'), me.tipCalculate]);
var _menu = new Common.UI.Menu({
items: [
{caption: me.textCalculateWorkbook, value: Asc.c_oAscCalculateType.All},
{caption: me.textCalculateCurrentSheet, value: Asc.c_oAscCalculateType.ActiveSheet},
//{caption: '--'},
//{caption: me.textAutomatic, value: '', toggleGroup: 'menuCalcMode', checkable: true, checked: true},
//{caption: me.textManual, value: '', toggleGroup: 'menuCalcMode', checkable: true, checked: false}
]
});
me.btnCalculate.setMenu(_menu);
setEvents.call(me); setEvents.call(me);
}); });
}, },
@ -480,7 +509,14 @@ define([
txtAdditional: 'Additional', txtAdditional: 'Additional',
txtFormula: 'Function', txtFormula: 'Function',
txtFormulaTip: 'Insert function', txtFormulaTip: 'Insert function',
txtMore: 'More functions' txtMore: 'More functions',
txtCalculation: 'Calculation',
tipCalculate: 'Calculate',
textCalculateWorkbook: 'Calculate workbook',
textCalculateCurrentSheet: 'Calculate current sheet',
textAutomatic: 'Automatic',
textManual: 'Manual',
tipCalculateTheEntireWorkbook: 'Calculate the entire workbook'
} }
}()), SSE.Views.FormulaTab || {})); }()), SSE.Views.FormulaTab || {}));
}); });

View file

@ -1633,6 +1633,13 @@
"SSE.Views.FormulaTab.txtFormulaTip": "Insert function", "SSE.Views.FormulaTab.txtFormulaTip": "Insert function",
"SSE.Views.FormulaTab.txtMore": "More functions", "SSE.Views.FormulaTab.txtMore": "More functions",
"SSE.Views.FormulaTab.txtRecent": "Recently used", "SSE.Views.FormulaTab.txtRecent": "Recently used",
"SSE.Views.FormulaTab.txtCalculation": "Calculation",
"SSE.Views.FormulaTab.tipCalculate": "Calculate",
"SSE.Views.FormulaTab.textCalculateWorkbook": "Calculate workbook",
"SSE.Views.FormulaTab.textCalculateCurrentSheet": "Calculate current sheet",
"SSE.Views.FormulaTab.textAutomatic": "Automatic",
"SSE.Views.FormulaTab.textManual": "Manual",
"SSE.Views.FormulaTab.tipCalculateTheEntireWorkbook": "Calculate the entire workbook",
"SSE.Views.GroupDialog.cancelButtonText": "Cancel", "SSE.Views.GroupDialog.cancelButtonText": "Cancel",
"SSE.Views.GroupDialog.okButtonText": "OK", "SSE.Views.GroupDialog.okButtonText": "OK",
"SSE.Views.GroupDialog.textColumns": "Columns", "SSE.Views.GroupDialog.textColumns": "Columns",