forked from brutusin/json-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Piela
committed
Nov 27, 2018
1 parent
44f27b2
commit b83bb78
Showing
1 changed file
with
41 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* | ||
* @author Ignacio del Valle Alles [email protected] | ||
*/ | ||
|
||
|
@@ -161,7 +161,7 @@ if (typeof brutusin === "undefined") { | |
|
||
renderers["string"] = function (container, id, parentObject, propertyProvider, value) { | ||
/// TODO change the handler for when there is a 'media' | ||
/// specifier so it becomes a file element. | ||
/// specifier so it becomes a file element. | ||
var schemaId = getSchemaId(id); | ||
var parentId = getParentSchemaId(schemaId); | ||
var s = getSchema(schemaId); | ||
|
@@ -327,7 +327,7 @@ if (typeof brutusin === "undefined") { | |
// if (s.required) { | ||
// input.required = true; | ||
// } | ||
// | ||
// | ||
// if (s.minimum) { | ||
// input.min = s.minimum; | ||
// } | ||
|
@@ -349,7 +349,7 @@ if (typeof brutusin === "undefined") { | |
input = document.createElement("input"); | ||
input.type = "checkbox"; | ||
if (value === true || value !== false && s.default) { | ||
input.checked = true; | ||
input.checked = true; | ||
} | ||
} else { | ||
input = document.createElement("select"); | ||
|
@@ -438,6 +438,23 @@ if (typeof brutusin === "undefined") { | |
|
||
}; | ||
|
||
renderers["allOf"] = function (container, id, parentObject, propertyProvider, value) { | ||
var schemaId = getSchemaId(id); | ||
var s = getSchema(schemaId); | ||
for (var i = 0; i < s.allOf.length; i++) { | ||
var propId = schemaId + "." + i; | ||
var ss = getSchema(propId); | ||
if (!ss.hasOwnProperty("type")) { | ||
if (ss.hasOwnProperty("properties")) { | ||
ss.type = "object"; | ||
} | ||
} | ||
var schemaDiv = document.createElement("div"); | ||
render(null, schemaDiv, id + "." + i, parentObject, propertyProvider, value); | ||
appendChild(container, schemaDiv, ss); | ||
} | ||
}; | ||
|
||
renderers["object"] = function (container, id, parentObject, propertyProvider, value) { | ||
|
||
function createStaticPropertyProvider(propname) { | ||
|
@@ -978,6 +995,10 @@ if (typeof brutusin === "undefined") { | |
for (var i in schema.oneOf) { | ||
renameRequiredPropeties(schema.oneOf[i]); | ||
} | ||
} else if (schema.hasOwnProperty("allOf")) { | ||
for (i in schema.allOf) { | ||
renameRequiredPropeties(schema.allOf[i]); | ||
} | ||
} else if (schema.hasOwnProperty("$ref")) { | ||
var newSchema = getDefinition(schema["$ref"]); | ||
renameRequiredPropeties(newSchema); | ||
|
@@ -996,13 +1017,13 @@ if (typeof brutusin === "undefined") { | |
if (schema.patternProperties) { | ||
for (var pat in schema.patternProperties) { | ||
var s = schema.patternProperties[pat]; | ||
if (s.hasOwnProperty("type") || s.hasOwnProperty("$ref") || s.hasOwnProperty("oneOf")) { | ||
if (s.hasOwnProperty("type") || s.hasOwnProperty("$ref") || s.hasOwnProperty("oneOf") || s.hasOwnProperty("allOf")) { | ||
renameRequiredPropeties(schema.patternProperties[pat]); | ||
} | ||
} | ||
} | ||
if (schema.additionalProperties) { | ||
if (schema.additionalProperties.hasOwnProperty("type") || schema.additionalProperties.hasOwnProperty("oneOf")) { | ||
if (schema.additionalProperties.hasOwnProperty("type") || schema.additionalProperties.hasOwnProperty("oneOf") || schema.additionalProperties.hasOwnProperty("allOf")) { | ||
renameRequiredPropeties(schema.additionalProperties); | ||
|
||
} | ||
|
@@ -1027,6 +1048,14 @@ if (typeof brutusin === "undefined") { | |
pseudoSchema.oneOf[i] = childProp; | ||
populateSchemaMap(childProp, schema.oneOf[i]); | ||
} | ||
} else if (schema.hasOwnProperty("allOf")) { | ||
pseudoSchema.allOf = new Array(); | ||
pseudoSchema.type = "allOf"; | ||
for (i in schema.allOf) { | ||
childProp = name + "." + i; | ||
pseudoSchema.allOf[i] = childProp; | ||
populateSchemaMap(childProp, schema.allOf[i]); | ||
} | ||
} else if (schema.hasOwnProperty("$ref")) { | ||
var refSchema = getDefinition(schema["$ref"]); | ||
if (refSchema) { | ||
|
@@ -1070,7 +1099,7 @@ if (typeof brutusin === "undefined") { | |
var s = schema.patternProperties[pat]; | ||
|
||
if (s.hasOwnProperty("type") || s.hasOwnProperty("$ref") || | ||
s.hasOwnProperty("oneOf")) { | ||
s.hasOwnProperty("oneOf") || s.hasOwnProperty("allOf")) { | ||
populateSchemaMap(patChildProp, schema.patternProperties[pat]); | ||
} else { | ||
populateSchemaMap(patChildProp, SCHEMA_ANY); | ||
|
@@ -1081,7 +1110,8 @@ if (typeof brutusin === "undefined") { | |
var childProp = name + "[*]"; | ||
pseudoSchema.additionalProperties = childProp; | ||
if (schema.additionalProperties.hasOwnProperty("type") || | ||
schema.additionalProperties.hasOwnProperty("oneOf")) { | ||
schema.additionalProperties.hasOwnProperty("oneOf") || | ||
schema.additionalProperties.hasOwnProperty("allOf")) { | ||
populateSchemaMap(childProp, schema.additionalProperties); | ||
} else { | ||
populateSchemaMap(childProp, SCHEMA_ANY); | ||
|
@@ -1099,10 +1129,10 @@ if (typeof brutusin === "undefined") { | |
for (var i = 0; i < schema.dependsOn.length; i++) { | ||
if (!schema.dependsOn[i]) { | ||
arr[i] = "$"; | ||
// Relative cases | ||
// Relative cases | ||
} else if (schema.dependsOn[i].startsWith("$")) { | ||
arr[i] = schema.dependsOn[i]; | ||
// Relative cases | ||
// Relative cases | ||
} else if (name.endsWith("]")) { | ||
arr[i] = name + "." + schema.dependsOn[i]; | ||
} else { | ||
|
@@ -1255,7 +1285,7 @@ if (typeof brutusin === "undefined") { | |
return input.getValue(); | ||
} | ||
var value; | ||
|
||
if (input.tagName.toLowerCase() === "select") { | ||
value = input.options[input.selectedIndex].value; | ||
} else { | ||
|