2015-01-23 13:09:30 +00:00
|
|
|
|
2022-06-06 12:49:18 +00:00
|
|
|
var Component = require('vn/component');
|
2016-09-26 09:28:47 +00:00
|
|
|
|
2019-05-27 13:38:06 +00:00
|
|
|
module.exports = new Class({
|
2022-06-06 12:49:18 +00:00
|
|
|
Extends: Component
|
2022-05-30 01:30:33 +00:00
|
|
|
,Implements: Vn.ParamIface
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'htk-field'
|
|
|
|
,Child: 'param'
|
2022-05-30 01:30:33 +00:00
|
|
|
,Properties: {
|
2019-05-27 13:38:06 +00:00
|
|
|
value: {
|
2015-07-03 05:49:45 +00:00
|
|
|
type: String
|
2019-05-27 13:38:06 +00:00
|
|
|
,set: function(x) {
|
|
|
|
if (Vn.Value.compare(x, this._value))
|
2015-01-23 13:09:30 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (x instanceof Date)
|
2019-05-27 13:38:06 +00:00
|
|
|
x = x.clone();
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2019-05-27 13:38:06 +00:00
|
|
|
this.valueChanged(x);
|
|
|
|
this.putValue(x);
|
2022-05-30 01:30:33 +00:00
|
|
|
this._notifyChanges();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2022-05-30 01:30:33 +00:00
|
|
|
,get: function() {
|
2015-01-23 13:09:30 +00:00
|
|
|
return this._value;
|
|
|
|
}
|
|
|
|
},
|
2019-05-27 13:38:06 +00:00
|
|
|
param: {
|
2022-05-30 01:30:33 +00:00
|
|
|
type: Vn.ParamIface
|
2019-05-27 13:38:06 +00:00
|
|
|
,set: function(x) {
|
2022-05-30 01:30:33 +00:00
|
|
|
this._setParam(x);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2019-05-27 13:38:06 +00:00
|
|
|
,get: function() {
|
2015-01-23 13:09:30 +00:00
|
|
|
return this._param;
|
|
|
|
}
|
|
|
|
},
|
2022-05-30 01:30:33 +00:00
|
|
|
lot: {
|
|
|
|
type: Vn.LotIface
|
|
|
|
,set: function(x) {
|
|
|
|
this._setLot(x);
|
|
|
|
}
|
|
|
|
,get: function() {
|
|
|
|
return this._lot;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
type: String
|
|
|
|
,set: function(x) {
|
|
|
|
this._setName(x);
|
|
|
|
}
|
|
|
|
,get: function() {
|
|
|
|
return this._name;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
oneWay: {
|
|
|
|
type: Boolean
|
|
|
|
,set: function(x) {
|
|
|
|
this._oneWay = x;
|
|
|
|
}
|
|
|
|
,get: function() {
|
|
|
|
return this._oneWay;
|
|
|
|
}
|
|
|
|
},
|
2022-10-03 12:49:41 +00:00
|
|
|
oneTime: {
|
|
|
|
type: Boolean
|
|
|
|
,set: function(x) {
|
|
|
|
this._oneTime = x;
|
|
|
|
}
|
|
|
|
,get: function() {
|
|
|
|
return this._oneTime;
|
|
|
|
}
|
|
|
|
},
|
2019-05-27 13:38:06 +00:00
|
|
|
editable: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: Boolean
|
2019-05-27 13:38:06 +00:00
|
|
|
,set: function(x) {
|
|
|
|
if (x != this._editable) {
|
2015-01-23 13:09:30 +00:00
|
|
|
this._editable = x;
|
2019-05-27 13:38:06 +00:00
|
|
|
this.setEditable(x);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-27 13:38:06 +00:00
|
|
|
,get: function() {
|
2015-01-23 13:09:30 +00:00
|
|
|
return this._editable;
|
|
|
|
}
|
|
|
|
},
|
2019-05-27 13:38:06 +00:00
|
|
|
form: {
|
2015-11-19 13:57:23 +00:00
|
|
|
type: Db.Iterator
|
2019-05-27 13:38:06 +00:00
|
|
|
,set: function(x) {
|
2022-05-30 01:30:33 +00:00
|
|
|
this.lot = x;
|
2019-05-27 13:38:06 +00:00
|
|
|
}
|
|
|
|
,get: function() {
|
2022-05-30 01:30:33 +00:00
|
|
|
return this._lot;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
},
|
2019-05-27 13:38:06 +00:00
|
|
|
column: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: String
|
2019-05-27 13:38:06 +00:00
|
|
|
,set: function(x) {
|
2022-05-30 01:30:33 +00:00
|
|
|
this.name = x;
|
2019-05-27 13:38:06 +00:00
|
|
|
}
|
|
|
|
,get: function() {
|
2022-05-30 01:30:33 +00:00
|
|
|
return this._name;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
},
|
2019-05-27 13:38:06 +00:00
|
|
|
conditionalFunc: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: Function
|
|
|
|
,value: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_editable: true
|
2022-05-30 01:30:33 +00:00
|
|
|
,_lockField: false
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
,_setValue: function(newValue) {
|
|
|
|
if (!this._putValue(newValue))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!this._lockField)
|
|
|
|
this.putValue(newValue);
|
|
|
|
|
|
|
|
if (this.conditionalFunc)
|
|
|
|
this.conditionalFunc(this, newValue);
|
|
|
|
|
2022-06-06 08:53:59 +00:00
|
|
|
const node = this.node;
|
|
|
|
if (node && node.nodeType === Node.ELEMENT_NODE)
|
|
|
|
node.classList.toggle('filled', newValue !== undefined);
|
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
this._notifyChanges();
|
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
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
2022-05-30 01:30: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.
|
|
|
|
*
|
|
|
|
* @param {Object} value The new value for the entry
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
2022-05-30 01:30: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.
|
|
|
|
*
|
|
|
|
* @param {Object} value The new entry value
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
2019-05-27 13:38:06 +00:00
|
|
|
,valueChanged: function(value) {
|
2022-05-30 01:30:33 +00:00
|
|
|
this._lockField = true;
|
|
|
|
this._setValue(value);
|
|
|
|
this._lockField = false;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|