0
1
Fork 0
hedera-web-mindshore/js/db/calc-sum.js

53 lines
699 B
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
var Calc = require ('./calc');
/**
* Computes a sum of data in the model.
2016-12-20 09:32:17 +00:00
*/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Calc
,Tag: 'db-calc-sum'
,getRowValue: function (row)
{
var value;
if (this._func)
{
this._set.row = row;
value = this._func (this._set);
}
else
value = this._model.getByIndex (row, this.columnIndex);
return value;
}
,before: function (row)
{
var value = this.getRowValue (row)
if (value !== null)
2016-05-06 12:09:15 +00:00
this._sum -= value;
}
,after: function (row)
{
var value = this.getRowValue (row);
if (value !== null)
2016-05-06 12:09:15 +00:00
this._sum += value;
}
,init: function ()
{
2016-05-06 12:09:15 +00:00
this._sum = 0;
}
,done: function ()
{
2016-05-06 12:09:15 +00:00
this.value = this._sum;
}
});