2015-01-23 13:09:30 +00:00
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
var Widget = require ('./widget');
|
|
|
|
|
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Widget
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'htk-field'
|
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
value:
|
|
|
|
{
|
2015-07-03 05:49:45 +00:00
|
|
|
type: String
|
2015-01-23 13:09:30 +00:00
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
if (Vn.Value.compare (x, this._value))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (x instanceof Date)
|
|
|
|
x = x.clone ();
|
|
|
|
|
|
|
|
this.valueChanged (x);
|
|
|
|
this.putValue (x);
|
|
|
|
}
|
2017-04-05 14:06:07 +00:00
|
|
|
,get: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
|
|
|
return this._value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
param:
|
|
|
|
{
|
|
|
|
type: Vn.Param
|
|
|
|
,set: function (x)
|
2015-03-27 19:10:49 +00:00
|
|
|
{
|
2015-01-23 13:09:30 +00:00
|
|
|
this.link ({_param: x}, {'changed': this.onParamChange});
|
|
|
|
this.onParamChange ();
|
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._param;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
editable:
|
|
|
|
{
|
|
|
|
type: Boolean
|
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
if (x != this._editable)
|
|
|
|
{
|
|
|
|
this._editable = x;
|
|
|
|
this.setEditable (x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._editable;
|
|
|
|
}
|
|
|
|
},
|
2017-04-05 14:06:07 +00:00
|
|
|
lot:
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2015-11-19 13:57:23 +00:00
|
|
|
type: Db.Iterator
|
2015-01-23 13:09:30 +00:00
|
|
|
,set: function (x)
|
|
|
|
{
|
2017-04-05 14:06:07 +00:00
|
|
|
this._lot = x;
|
|
|
|
this.bindToLot ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
},
|
2017-04-05 14:06:07 +00:00
|
|
|
name:
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,set: function (x)
|
2015-03-27 19:10:49 +00:00
|
|
|
{
|
2015-01-23 13:09:30 +00:00
|
|
|
this._paramName = x;
|
2017-04-05 14:06:07 +00:00
|
|
|
this.bindToLot ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
conditionalFunc:
|
|
|
|
{
|
|
|
|
type: Function
|
|
|
|
,value: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_value: undefined
|
|
|
|
,_param: null
|
|
|
|
,_editable: true
|
2015-06-30 12:06:19 +00:00
|
|
|
,_blockParamChange: false
|
|
|
|
,_blockValueChange: false
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,onParamChange: function ()
|
|
|
|
{
|
2015-06-30 12:06:19 +00:00
|
|
|
if (!this._blockValueChange)
|
|
|
|
{
|
|
|
|
this._blockParamChange = true;
|
|
|
|
this.value = this._param.value;
|
|
|
|
this._blockParamChange = false;
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 14:06:07 +00:00
|
|
|
,bindToLot: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2017-04-05 14:06:07 +00:00
|
|
|
if (this._lot && this._paramName)
|
|
|
|
this.param = new Vn.Param
|
2016-09-26 09:28:47 +00:00
|
|
|
({
|
2017-04-05 14:06:07 +00:00
|
|
|
lot: this._lot
|
|
|
|
,name: this._paramName
|
2016-09-26 09:28:47 +00:00
|
|
|
});
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual method that must be implemented by class childs to set the entry
|
|
|
|
* editable.
|
|
|
|
*
|
|
|
|
* @param {Boolean} editable Whether the user is allowed to edit the entry
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2017-04-07 11:00:33 +00:00
|
|
|
,setEditable: function () {}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual method that must be implemented by class childs to put the value
|
|
|
|
* on the associated entry.
|
|
|
|
*
|
2017-04-07 11:00:33 +00:00
|
|
|
* @param {*} value The new value for the entry
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2017-04-07 11:00:33 +00:00
|
|
|
,putValue: function () {}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Protected method that should be called from class childs when the value
|
|
|
|
* on the associated entry changes.
|
|
|
|
*
|
2017-04-07 11:00:33 +00:00
|
|
|
* @param {*} value The new entry value
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2015-01-23 13:09:30 +00:00
|
|
|
,valueChanged: function (value)
|
|
|
|
{
|
|
|
|
this._value = value;
|
|
|
|
|
|
|
|
if (this.conditionalFunc)
|
|
|
|
this.conditionalFunc (this, value);
|
|
|
|
|
2015-06-30 12:06:19 +00:00
|
|
|
if (this._param && !this._blockParamChange)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2015-06-30 12:06:19 +00:00
|
|
|
this._blockValueChange = true;
|
2015-01-23 13:09:30 +00:00
|
|
|
this._param.value = value;
|
2015-06-30 12:06:19 +00:00
|
|
|
this._blockValueChange = false;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.signalEmit ('changed');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|