hedera-web/js/db/param.js

98 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
var Form = require ('./form');
module.exports = new Class
({
Extends: Vn.Param
,Tag: 'db-param'
,Parent: 'form'
,Properties:
{
/**
* The form field referenced by this param.
2016-12-20 09:32:17 +00:00
*/
column:
{
type: String
,set: function (x)
{
this._columnName = x;
this.refresh ();
}
,get: function ()
{
this._columnName;
}
},
/**
* The form referenced by this param.
2016-12-20 09:32:17 +00:00
*/
form:
{
2016-09-26 09:28:47 +00:00
type: Form
,set: function (x)
{
2017-03-30 11:44:53 +00:00
this.link ({_set: x},
{
2017-03-30 11:44:53 +00:00
'change': this.onSetChange
});
this.refresh ();
}
,get: function ()
{
2017-03-30 11:44:53 +00:00
return this._set;
}
2015-07-03 05:49:45 +00:00
},
/**
* Determines whether the link to the form is unidirectional, ie, a
* change in the form updates the parameter but not vice versa.
2016-12-20 09:32:17 +00:00
*/
2015-07-03 05:49:45 +00:00
oneWay:
{
type: Boolean
,set: function (x)
{
this._oneWay = x;
}
,get: function ()
{
return this._oneWay;
}
}
}
,_columnName: null
2017-03-30 11:44:53 +00:00
,_set: null
,_setLock: false
2015-07-03 05:49:45 +00:00
,_oneWay: false
2017-03-30 11:44:53 +00:00
,_setValue: null
,initialize: function (props)
{
this.parent (props);
this.on ('changed', this.onChange, this);
}
,refresh: function ()
{
2017-03-30 11:44:53 +00:00
if (this._set)
this.onSetChange ();
}
2017-03-30 11:44:53 +00:00
,onSetChange: function ()
{
2017-03-30 11:44:53 +00:00
this._setLock = true;
var formValue = this._set.get (this._columnName);
this.value = formValue;
this._setLock = false;
}
,onChange: function ()
{
2017-03-30 11:44:53 +00:00
if (!this._setLock && this._columnName && !this.oneWay)
this._set.set (this._columnName, this._value);
}
});