0
1
Fork 0
hedera-web-mindshore/js/vn/lot-iface.js

92 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-04-10 16:23:40 +00:00
2017-04-19 06:16:37 +00:00
/**
2017-04-24 07:47:56 +00:00
* Holds a plain key-value javascript object and monitorizes changes over it.
2017-04-19 06:16:37 +00:00
*/
2017-04-10 16:23:40 +00:00
module.exports = new Class
({
Properties:
{
/**
2017-04-24 07:47:56 +00:00
* The internal object with the params, this is the lot internal object
* and should be used for read-only purposes.
2017-04-10 16:23:40 +00:00
*/
params:
{
type: Object
}
2017-04-24 07:47:56 +00:00
/**
* Shortcut for params property.
*/
,$:
{
type: Object
}
2017-04-10 16:23:40 +00:00
}
/**
2017-07-05 09:50:42 +00:00
* Gets a value from the lot.
2017-04-10 16:23:40 +00:00
*
2017-04-21 10:53:15 +00:00
* @param {string} field The field name
2017-04-10 16:23:40 +00:00
* @return {*} The field value
*/
2017-04-24 07:47:56 +00:00
,get: function (field)
{
return this.params[field];
}
2017-04-10 16:23:40 +00:00
/**
2017-07-05 09:50:42 +00:00
* Sets a value on the lot.
2017-04-10 16:23:40 +00:00
*
2017-04-21 10:53:15 +00:00
* @param {string} field The field name
2017-04-10 16:23:40 +00:00
* @param {*} value The new field value
*/
2017-04-24 07:47:56 +00:00
,set: function (field, value)
{
var params = {};
params[field] = value;
2017-05-22 07:08:21 +00:00
this.assign (params);
2017-04-24 07:47:56 +00:00
}
2017-04-10 16:23:40 +00:00
/**
2017-07-05 09:50:42 +00:00
* Returns an array with the lot keys.
2017-04-10 16:23:40 +00:00
*
2017-07-05 09:50:42 +00:00
* @return {Array} The lot keys
2017-04-10 16:23:40 +00:00
*/
,keys: function () {}
/**
2017-07-05 09:50:42 +00:00
* Emits the 'change' signal on the lot.
2017-04-21 10:53:15 +00:00
*
* @param {Object} changes The changed params and its values
2017-04-10 16:23:40 +00:00
*/
2017-04-21 10:53:15 +00:00
,changed: function (changes)
2017-04-10 16:23:40 +00:00
{
2017-04-21 10:53:15 +00:00
this.emit ('change', changes);
2017-04-10 16:23:40 +00:00
}
/**
2017-07-05 09:50:42 +00:00
* Copies all values from another lot.
2017-04-10 16:23:40 +00:00
*
* @param {Object} object The source object
*/
2017-04-24 07:47:56 +00:00
,assign: function () {}
2017-04-10 16:23:40 +00:00
2017-04-19 06:16:37 +00:00
/**
* Copies all values from another lot.
*
* @param {LotIface} lot The source lot
*/
2017-04-10 16:23:40 +00:00
,assignLot: function (lot)
{
this.assign (lot.params);
}
2017-04-24 07:47:56 +00:00
/**
* Resets all values.
*/
,reset: function ()
{
this.params = {};
}
2017-04-10 16:23:40 +00:00
});