forked from verdnatura/hedera-web
92 lines
1.4 KiB
JavaScript
92 lines
1.4 KiB
JavaScript
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
,_columnName: null
|
||
|
,_form: null
|
||
|
,formLock: false
|
||
|
,columnIndex: -1
|
||
|
|
||
|
,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)
|
||
|
this.columnIndex = this._form.getColumnIndex (this._columnName);
|
||
|
}
|
||
|
|
||
|
,onIterChange: function ()
|
||
|
{
|
||
|
this.formLock = true;
|
||
|
|
||
|
if (this.columnIndex != -1)
|
||
|
this.value = this._form.getByIndex (this.columnIndex);
|
||
|
else
|
||
|
this.value = undefined;
|
||
|
|
||
|
this.formLock = false;
|
||
|
}
|
||
|
|
||
|
,onChange: function ()
|
||
|
{
|
||
|
if (!this.formLock && this.columnIndex != -1)
|
||
|
this._form.setByIndex (this.columnIndex, this._value);
|
||
|
}
|
||
|
});
|
||
|
|