var Form = require ('./form'); module.exports = 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: Form ,set: function (x) { this.link ({_set: x}, { 'change': this.onSetChange }); this.refresh (); } ,get: function () { return this._set; } }, /** * 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 ,_set: null ,_setLock: false ,_oneWay: false ,_setValue: null ,initialize: function (props) { this.parent (props); this.on ('changed', this.onChange, this); } ,refresh: function () { if (this._set) this.onSetChange (); } ,onSetChange: function () { this._setLock = true; var formValue = this._set.get (this._columnName); this.value = formValue; this._setLock = false; } ,onChange: function () { if (!this._setLock && this._columnName && !this.oneWay) this._set.set (this._columnName, this._value); } });