0
1
Fork 0
hedera-web-mindshore/js/vn/iterator.js

76 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-05-30 01:30:33 +00:00
var Lot = require('./lot');
var IteratorIface = require('./iterator-iface');
var ModelIface = require('./model-iface');
/**
* A light iterator for models. It assumes that its row and model properties
* are always valid.
*/
module.exports = new Class({
Extends: Lot
,Implements: IteratorIface
,Properties: {
model: {
type: ModelIface
,set: function(x) {
this._model = x;
}
,get: function() {
return this._model;
}
},
row: {
type: Number
,set: function(x) {
this._row = x;
this.rowChanged();
}
,get: function() {
return this._row;
}
},
numRows: {
type: Number
,get: function() {
return this._model ?
this._model.numRows : 0;
}
},
ready: {
type: Boolean
,get: function() {
return this._model ?
this._model.ready : false;
}
}
}
,_model: null
,initialize: function(props) {
Object.assign(this, {
_row: -1
,_rowLock: false
});
2022-06-06 16:02:17 +00:00
Lot.prototype.initialize.call(this, props);
2022-05-30 01:30:33 +00:00
}
,_paramsChanged: function(diff) {
if (!this._rowLock)
for (var key in diff)
this._model.set(this._row, key, diff[key]);
}
,rowChanged: function() {
var row;
if (this._model)
row = this._model.getObject(this._row);
this._rowLock = true;
this.params = row != null ? row : {};
this._rowLock = false;
}
});