forked from verdnatura/hedera-web
84 lines
1.4 KiB
JavaScript
84 lines
1.4 KiB
JavaScript
/**
|
|
* 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
|
|
*/
|
|
get(field) {
|
|
return this.params[field];
|
|
},
|
|
|
|
/**
|
|
* Sets a value on the lot.
|
|
*
|
|
* @param {string} field The field name
|
|
* @param {*} value The new field value
|
|
*/
|
|
set(field, value) {
|
|
this.assign({[field]: value});
|
|
},
|
|
|
|
unset(field) {
|
|
this.assign({[field]: undefined});
|
|
},
|
|
|
|
/**
|
|
* Returns an array with the lot keys.
|
|
*
|
|
* @return {Array} The lot keys
|
|
*/
|
|
keys() {},
|
|
|
|
/**
|
|
* Emits the 'change' signal on the lot.
|
|
*
|
|
* @param {Object} changes The changed params and its values
|
|
*/
|
|
changed(changes) {
|
|
this.emit('change', changes);
|
|
},
|
|
|
|
/**
|
|
* Copies all values from another lot.
|
|
*
|
|
* @param {Object} object The source object
|
|
*/
|
|
assign() {},
|
|
|
|
/**
|
|
* Copies all values from another lot.
|
|
*
|
|
* @param {LotIface} lot The source lot
|
|
*/
|
|
assignLot(lot) {
|
|
this.assign(lot.$);
|
|
},
|
|
|
|
/**
|
|
* Resets all values.
|
|
*/
|
|
reset() {
|
|
this.params = {};
|
|
}
|
|
});
|
|
|