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

84 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
2023-01-16 12:59:11 +00:00
},
2022-05-30 01:30:33 +00:00
/**
* Shortcut for params property.
*/
2023-01-16 12:59:11 +00:00
$: {
2022-05-30 01:30:33 +00:00
type: Object
2023-01-16 12:59:11 +00:00
}
},
2022-05-30 01:30:33 +00:00
/**
* Gets a value from the lot.
*
* @param {string} field The field name
* @return {*} The field value
*/
2023-01-16 12:59:11 +00:00
get(field) {
return this.params[field];
},
2022-05-30 01:30:33 +00:00
/**
* Sets a value on the lot.
*
* @param {string} field The field name
* @param {*} value The new field value
*/
2023-01-16 12:59:11 +00:00
set(field, value) {
this.assign({[field]: value});
},
unset(field) {
this.assign({[field]: undefined});
},
2022-05-30 01:30:33 +00:00
/**
* Returns an array with the lot keys.
*
* @return {Array} The lot keys
*/
2023-01-16 12:59:11 +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
*/
2023-01-16 12:59:11 +00:00
changed(changes) {
this.emit('change', changes);
},
2022-05-30 01:30:33 +00:00
/**
* Copies all values from another lot.
*
* @param {Object} object The source object
*/
2023-01-16 12:59:11 +00:00
assign() {},
2022-05-30 01:30:33 +00:00
/**
* Copies all values from another lot.
*
* @param {LotIface} lot The source lot
*/
2023-01-16 12:59:11 +00:00
assignLot(lot) {
this.assign(lot.$);
},
2022-05-30 01:30:33 +00:00
/**
* Resets all values.
*/
2023-01-16 12:59:11 +00:00
reset() {
this.params = {};
}
2022-05-30 01:30:33 +00:00
});