2022-05-30 01:30:33 +00:00
|
|
|
|
|
|
|
var VnObject = require('./object');
|
|
|
|
var LotIface = require('./lot-iface');
|
|
|
|
var Value = require('./value');
|
|
|
|
|
|
|
|
module.exports = new Class({
|
|
|
|
Extends: VnObject
|
|
|
|
,Implements: LotIface
|
|
|
|
,Tag: 'vn-lot'
|
|
|
|
,Properties: {
|
2022-06-06 12:49:18 +00:00
|
|
|
$: {
|
2022-05-30 01:30:33 +00:00
|
|
|
type: Object
|
|
|
|
,set: function(x) {
|
|
|
|
this.setAll(x);
|
|
|
|
}
|
|
|
|
,get: function() {
|
|
|
|
return this._params;
|
|
|
|
}
|
|
|
|
}
|
2022-06-06 12:49:18 +00:00
|
|
|
,params: {
|
2022-05-30 01:30:33 +00:00
|
|
|
type: Object
|
|
|
|
,set: function(x) {
|
2022-06-06 12:49:18 +00:00
|
|
|
this.$ = x;
|
2022-05-30 01:30:33 +00:00
|
|
|
}
|
|
|
|
,get: function() {
|
2022-06-06 12:49:18 +00:00
|
|
|
return this.$;
|
2022-05-30 01:30:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,initialize: function(props) {
|
|
|
|
this._params = {};
|
|
|
|
this.parent(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
,keys: function() {
|
|
|
|
return Object.keys(this._params);
|
|
|
|
}
|
|
|
|
|
|
|
|
,assign: function(params) {
|
|
|
|
var diff = Value.partialDiff(this._params, params);
|
|
|
|
this._assign(diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
,setAll: function(params) {
|
|
|
|
var diff = Value.diff(this._params, params);
|
|
|
|
this._assign(diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
,_assign: function(diff) {
|
|
|
|
if (diff) {
|
|
|
|
Object.assign(this._params, diff);
|
|
|
|
this._paramsChanged(diff);
|
|
|
|
this.changed(diff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when lot params changes, can be implemented by child classes to be
|
|
|
|
* notified about changes.
|
|
|
|
*
|
|
|
|
* @param {Object} diff Changed parameters and its new values
|
|
|
|
*/
|
|
|
|
,_paramsChanged: function() {}
|
|
|
|
});
|