hedera-web/js/vn/lot-iface.js

83 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-05-30 01:30:33 +00:00
/**
* Holds a plain key-value javascript object and monitorizes changes over it.
*/
module.exports = new Class({
Properties: {
/**
* The internal object with the params, this is the lot internal object
* and should be used for read-only purposes.
*/
params: {
type: Object
}
/**
* Shortcut for params property.
*/
,$: {
type: Object
}
}
/**
* Gets a value from the lot.
*
* @param {string} field The field name
* @return {*} The field value
*/
2022-11-16 01:46:44 +00:00
,get(field) {
2022-05-30 01:30:33 +00:00
return this.params[field];
}
/**
* Sets a value on the lot.
*
* @param {string} field The field name
* @param {*} value The new field value
*/
2022-11-16 01:46:44 +00:00
,set(field, value) {
2022-05-30 01:30:33 +00:00
var params = {};
params[field] = value;
this.assign(params);
}
/**
* Returns an array with the lot keys.
*
* @return {Array} The lot keys
*/
2022-11-16 01:46:44 +00:00
,keys() {}
2022-05-30 01:30:33 +00:00
/**
* Emits the 'change' signal on the lot.
*
* @param {Object} changes The changed params and its values
*/
2022-11-16 01:46:44 +00:00
,changed(changes) {
2022-05-30 01:30:33 +00:00
this.emit('change', changes);
}
/**
* Copies all values from another lot.
*
* @param {Object} object The source object
*/
2022-11-16 01:46:44 +00:00
,assign() {}
2022-05-30 01:30:33 +00:00
/**
* Copies all values from another lot.
*
* @param {LotIface} lot The source lot
*/
2022-11-16 01:46:44 +00:00
,assignLot(lot) {
2022-05-30 01:30:33 +00:00
this.assign(lot.$);
}
/**
* Resets all values.
*/
2022-11-16 01:46:44 +00:00
,reset() {
2022-05-30 01:30:33 +00:00
this.params = {};
}
});