0
1
Fork 0
hedera-web-mindshore/web/js/db/param.js

113 lines
1.8 KiB
JavaScript
Raw Normal View History

Db.Param = new Class
({
Extends: Vn.Param
,Tag: 'db-param'
,Parent: 'form'
,Properties:
{
/**
* The form field referenced by this param.
**/
column:
{
type: String
,set: function (x)
{
this._columnName = x;
this.refresh ();
}
,get: function ()
{
this._columnName;
}
},
/**
* The form referenced by this param.
**/
form:
{
type: Db.Form
,set: function (x)
{
this.link ({_form: x},
{
'status-changed': this.onFormChange
,'iter-changed': this.onIterChange
});
this.refresh ();
}
,get: function ()
{
return this._form;
}
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.
**/
oneWay:
{
type: Boolean
,set: function (x)
{
this._oneWay = x;
}
,get: function ()
{
return this._oneWay;
}
}
}
,_columnName: null
,_form: null
2015-07-03 05:49:45 +00:00
,_formLock: false
,_columnIndex: -1
,_oneWay: false
,_formValue: null
,initialize: function (props)
{
this.parent (props);
this.on ('changed', this.onChange, this);
}
,refresh: function ()
{
if (this._form)
{
this.onFormChange ();
this.onIterChange ();
}
}
,onFormChange: function ()
{
if (this._columnName != null)
2015-07-03 05:49:45 +00:00
this._columnIndex = this._form.getColumnIndex (this._columnName);
}
,onIterChange: function ()
{
2015-07-03 05:49:45 +00:00
this._formLock = true;
var formValue;
2015-12-10 13:48:43 +00:00
if (this._columnIndex !== -1)
2015-07-03 05:49:45 +00:00
formValue = this._form.getByIndex (this._columnIndex);
else
2015-12-10 13:48:43 +00:00
formValue = undefined;
2015-12-10 13:48:43 +00:00
this.value = formValue;
2015-07-03 05:49:45 +00:00
this._formLock = false;
}
,onChange: function ()
{
2015-07-03 05:49:45 +00:00
if (!this._formLock && this._columnIndex != -1 && !this.oneWay)
this._form.setByIndex (this._columnIndex, this._value);
}
});