From 1dadc5f465d124f934b95810e55b1c80ae5dad0a Mon Sep 17 00:00:00 2001 From: tdakanalis Date: Mon, 11 Apr 2016 09:42:47 +0300 Subject: [PATCH] -Removed the ability to use the non standard json schema element 'enumLabels' in order to define the labels of the drop downs. The values will be used instead. This feature will be re-implemented using the tree editor's options. --- src/js/Node.js | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/js/Node.js b/src/js/Node.js index 8addb45..25b3c7e 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -1274,11 +1274,11 @@ Node.prototype._updateDomValue = function () { this.dom.select.option.innerHTML = '--'; this.dom.select.appendChild(this.dom.select.option); - //Itterate all the enum values and add all the values as options + //Iterate all enum values and add them as options for(var i = 0; i < this.enum.enum.length; i++) { this.dom.select.option = document.createElement('option'); this.dom.select.option.value = this.enum.enum[i]; - this.dom.select.option.innerHTML = this.enum.enumLabels[i]; + this.dom.select.option.innerHTML = this.enum.enum[i]; if(this.dom.select.option.value == this.value){ this.dom.select.option.selected = true; } @@ -1294,6 +1294,7 @@ Node.prototype._updateDomValue = function () { if(this.schema !== undefined && ( !this.schema.hasOwnProperty("oneOf") && !this.schema.hasOwnProperty("anyOf") && + !this.schema.hasOwnProperty("anyOf") && !this.schema.hasOwnProperty("allOf")) ) { this.valueFieldHTML = this.dom.tdValue.innerHTML; @@ -1928,29 +1929,19 @@ Node.prototype.updateDom = function (options) { domField.innerHTML = this._escapeHTML(field); } - //Locating the schema of the node and checking for enum type + //Locating the schema of the node and checking for any enum type if(this.editor && this.editor.options) { - //Search for the element with 'name' equals to the name of the current field. - //Store the schema of the node in the schema attribute. Hereafter, wherever you have acces in the node - //you will have also access in its own schema + //Search for the schema element of the current node and store it in the schema attribute. + //Hereafter, wherever you have access in the node you will have also access in its own schema. this.schema = this._getJsonObject(this.editor.options.schema, 'name', field)[0]; if(!this.schema) { this.schema = this._getJsonObject(this.editor.options.schema, field)[0]; } - //Try now to locate any enumerations inside the schema of the field + //Search for any enumeration type in the schema of the current node. + //Enum types can be also be part of a composite type. if(this.schema){ - //We check here some different cases in order to locate any defined enum field in the schema of the field if(this.schema.hasOwnProperty('enum')){ - if(Array.isArray(this.schema.enum)){ - //We expect in the enumLabels attribute of a json schema property the labels for the enum values - //in the same order as the respective elements in the enum array. Otherwise, use the enum values - //as labels. - var enumLabels = (this.schema.hasOwnProperty('enumLabels') && this.schema.enumLabels !== undefined) ? - this.schema.enumLabels : this.schema.enum; - this.enum = {'enum': this.schema.enum, 'enumLabels' : enumLabels}; - } else { - this.enum = this.schema.enum; - } + this.enum = this.schema.enum; } else if(this.schema.hasOwnProperty('oneOf')){ this.enum = this._getJsonObject(this.schema.oneOf, 'enum')[0]; } else if(this.schema.hasOwnProperty('anyOf')){ @@ -1960,10 +1951,6 @@ Node.prototype.updateDom = function (options) { } else { delete this.enum; } - - if(this.enum !== undefined && !this.enum.hasOwnProperty('enumLabels')){ - this.enum.enumLabels = this.enum.enum; - } } else { delete this.enum; }