forked from verdnatura/hedera-web
51 lines
908 B
JavaScript
51 lines
908 B
JavaScript
|
|
module.exports = new Class({
|
|
Extends: Htk.Column
|
|
,Tag: 'htk-column-text'
|
|
,Properties: {
|
|
/**
|
|
* Format that applies to the value.
|
|
*/
|
|
format:{
|
|
type: String
|
|
,set(x) {
|
|
this._format = _(x);
|
|
}
|
|
,get() {
|
|
return this._format;
|
|
}
|
|
}
|
|
}
|
|
|
|
,_format: null
|
|
|
|
,initialize(props) {
|
|
this._cssClass = 'cell-text';
|
|
Htk.Column.prototype.initialize.call(this, props);
|
|
}
|
|
|
|
,render(tr) {
|
|
var node;
|
|
|
|
if (this.editable) {
|
|
var value = this.value ? this.value : '';
|
|
|
|
node = this.createElement('input');
|
|
node.type = 'text';
|
|
node.value = value;
|
|
node.addEventListener('changed',
|
|
this.inputChanged.bind(this, tr, node));
|
|
} else
|
|
node = this.createTextNode(
|
|
Vn.Value.format(this.value, this._format));
|
|
|
|
var td = Htk.Column.prototype.render.call(this, tr);
|
|
td.appendChild(node);
|
|
return td;
|
|
}
|
|
|
|
,inputChanged(tr, node) {
|
|
this.changed(tr, node.value);
|
|
}
|
|
});
|