hedera-web/js/htk/field.js

153 lines
2.3 KiB
JavaScript
Raw Normal View History

2017-04-19 06:16:37 +00:00
/**
* Base class for graphical fields.
*/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2017-10-18 16:01:21 +00:00
Extends: Vn.Component
2017-04-19 06:16:37 +00:00
,Implements: Vn.ParamIface
,Tag: 'htk-field'
,Properties:
{
value:
{
2017-04-19 06:16:37 +00:00
type: null
,set: function (x)
{
2017-04-19 06:16:37 +00:00
this._setValue (x);
}
2017-04-05 14:06:07 +00:00
,get: function ()
{
return this._value;
}
},
2017-04-19 06:16:37 +00:00
type:
{
2017-04-19 06:16:37 +00:00
type: Type
,set: function (x)
{
2017-04-19 06:16:37 +00:00
this._setType (x);
}
,get: function ()
{
2017-04-19 06:16:37 +00:00
return this._type;
}
},
2017-04-19 06:16:37 +00:00
param:
{
2017-04-19 06:16:37 +00:00
type: Vn.ParamIface
,set: function (x)
{
2017-04-19 06:16:37 +00:00
this._setParam (x);
}
,get: function ()
{
2017-04-19 06:16:37 +00:00
return this._param;
}
},
2017-04-05 14:06:07 +00:00
lot:
{
2017-04-19 06:16:37 +00:00
type: Vn.LotIface
,set: function (x)
{
2017-04-19 06:16:37 +00:00
this._setLot (x);
}
,get: function ()
{
return this._lot;
}
},
2017-04-05 14:06:07 +00:00
name:
{
type: String
,set: function (x)
{
2017-04-21 10:53:15 +00:00
this._setName (x);
2017-04-19 06:16:37 +00:00
}
,get: function ()
{
return this._name;
}
},
oneWay:
{
type: Boolean
,set: function (x)
{
this._oneWay = x;
}
,get: function ()
{
return this._oneWay;
}
},
editable:
{
type: Boolean
,set: function (x)
{
if (x != this._editable)
{
this._editable = x;
this.setEditable (x);
}
}
,get: function ()
{
return this._editable;
}
},
conditionalFunc:
{
type: Function
,value: null
}
}
,_editable: true
2017-11-20 12:15:01 +00:00
,_lockField: false
2017-04-19 06:16:37 +00:00
,_setValue: function (newValue)
{
2017-11-20 12:15:01 +00:00
if (!this._putValue (newValue))
return;
2017-11-16 14:53:20 +00:00
2017-11-20 12:15:01 +00:00
if (!this._lockField)
this._putFieldValue (newValue);
2017-04-19 06:16:37 +00:00
if (this.conditionalFunc)
this.conditionalFunc (this, newValue);
2017-11-20 12:15:01 +00:00
this._notifyChanges ();
}
2017-04-19 06:16:37 +00:00
/**
* Protected method that should be called from class childs when the value
* on the associated entry changes.
*
* @param {*} value The new entry value
*/
2017-11-20 12:15:01 +00:00
,_notifyFieldChange: function (value)
{
2017-11-20 12:15:01 +00:00
this._lockField = true;
2017-04-19 06:16:37 +00:00
this._setValue (value);
2017-11-20 12:15:01 +00:00
this._lockField = false;
}
2017-11-20 12:15:01 +00:00
/**
* Virtual method that must be implemented by class childs to put the value
* on the associated entry.
*
* @param {*} value The new value for the entry
*/
,_putFieldValue: function () {}
/**
* Virtual method that must be implemented by class childs to set the entry
* editable.
*
2017-04-21 10:53:15 +00:00
* @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 () {}
});