Some code reorganization

This commit is contained in:
jos 2016-05-23 20:52:00 +02:00
parent b67d683f1a
commit f7c9b7d9ff
1 changed files with 23 additions and 19 deletions

View File

@ -1264,8 +1264,17 @@ Node.prototype._updateDomValue = function () {
this.dom.checkbox.checked = this.value; this.dom.checkbox.checked = this.value;
} }
//If the node has an enum property and it is editable lets create the select element else {
else if (this.enum && this.editable.value) { // cleanup checkbox when displayed
if (this.dom.tdCheckbox) {
this.dom.tdCheckbox.parentNode.removeChild(this.dom.tdCheckbox);
delete this.dom.tdCheckbox;
delete this.dom.checkbox;
}
}
if (this.enum && this.editable.value) {
// create select box when this node has an enum object
if (!this.dom.select) { if (!this.dom.select) {
this.dom.select = document.createElement('select'); this.dom.select = document.createElement('select');
this.id = this.field + "_" + new Date().getUTCMilliseconds(); this.id = this.field + "_" + new Date().getUTCMilliseconds();
@ -1298,30 +1307,25 @@ Node.prototype._updateDomValue = function () {
if(this.schema !== undefined && ( if(this.schema !== undefined && (
!this.schema.hasOwnProperty("oneOf") && !this.schema.hasOwnProperty("oneOf") &&
!this.schema.hasOwnProperty("anyOf") && !this.schema.hasOwnProperty("anyOf") &&
!this.schema.hasOwnProperty("anyOf") &&
!this.schema.hasOwnProperty("allOf")) !this.schema.hasOwnProperty("allOf"))
) { ) {
this.valueFieldHTML = this.dom.tdValue.innerHTML; this.valueFieldHTML = this.dom.tdValue.innerHTML;
this.dom.tdValue.style.visibility = 'hidden'; this.dom.tdValue.style.visibility = 'hidden';
this.dom.tdValue.innerHTML = ''; this.dom.tdValue.innerHTML = '';
} else { } else {
delete this.valueFieldHTML; delete this.valueFieldHTML;
} }
} }
} }
else { else {
// cleanup checkbox when displayed // cleanup select box when displayed
if (this.dom.tdCheckbox) { if (this.dom.tdSelect) {
this.dom.tdCheckbox.parentNode.removeChild(this.dom.tdCheckbox); this.dom.tdSelect.parentNode.removeChild(this.dom.tdSelect);
delete this.dom.tdCheckbox; delete this.dom.tdSelect;
delete this.dom.checkbox; delete this.dom.select;
} else if (this.dom.tdSelect) { this.dom.tdValue.innerHTML = this.valueFieldHTML;
this.dom.tdSelect.parentNode.removeChild(this.dom.tdSelect); this.dom.tdValue.style.visibility = '';
delete this.dom.tdSelect; delete this.valueFieldHTML;
delete this.dom.select;
this.dom.tdValue.innerHTML = this.valueFieldHTML;
this.dom.tdValue.style.visibility = '';
delete this.valueFieldHTML;
} }
} }