Merge pull request #459 from hachichaud/fix/enum-dropdown-with-composite

Display a dropdown for enums inside composite schemas
This commit is contained in:
Jos de Jong 2017-09-12 21:52:04 +02:00 committed by GitHub
commit b6ce1c0653
1 changed files with 27 additions and 10 deletions

View File

@ -2040,18 +2040,35 @@ Node._findEnum = function (schema) {
*/
Node._findSchema = function (schema, path) {
var childSchema = schema;
var foundSchema = childSchema;
for (var i = 0; i < path.length && childSchema; i++) {
var key = path[i];
if (typeof key === 'string' && childSchema.properties) {
childSchema = childSchema.properties[key] || null
}
else if (typeof key === 'number' && childSchema.items) {
childSchema = childSchema.items
}
var allSchemas = schema.oneOf || schema.anyOf || schema.allOf;
if (!allSchemas) {
allSchemas = [schema];
}
return childSchema
for (var j = 0; j < allSchemas.length; j++) {
childSchema = allSchemas[j];
for (var i = 0; i < path.length && childSchema; i++) {
var key = path[i];
if (typeof key === 'string' && childSchema.properties) {
childSchema = childSchema.properties[key] || null;
if (childSchema) {
foundSchema = childSchema;
}
}
else if (typeof key === 'number' && childSchema.items) {
childSchema = childSchema.items;
if (childSchema) {
foundSchema = childSchema;
}
}
}
}
return foundSchema
};
/**
@ -3347,7 +3364,7 @@ Node.prototype.showContextMenu = function (anchor, onClose) {
});
}
// create insert button
var insertSubmenu = [