Commit 77a9d42d authored by Jérome Perrin's avatar Jérome Perrin

jsplumb cleanups

parent 700db8e7
......@@ -385,7 +385,7 @@
// 2 here is for #/
var i, ref_path = ref.substr(2, ref.length),
parts = ref_path.split("/");
for (i = 0 ; i < parts.length; i++) {
for (i = 0 ; i < parts.length; i += 1) {
schema = schema[parts[i]];
}
return schema;
......@@ -396,15 +396,12 @@
// references
// XXX this should probably be moved to fieldset ( and not handle
// class_definition here)
// XXX known limitation: we do not expand refs inside oneOf
var property, referenced, i,
var referenced, i,
expanded_class_definition = {properties:
class_definition.properties || {}};
console.log('expandSchema', class_definition);
// expand direct ref
if (class_definition.$ref) {
console.log('DI', class_definition.$ref);
referenced = expandSchema(resolveReference(class_definition.$ref,
full_schema.class_definition),
full_schema);
......@@ -412,25 +409,8 @@
delete referenced.properties;
}
$.extend(expanded_class_definition, referenced);
console.log("after direct expand", Object.create(referenced));
}
/*
// expand refs inside properties
for (property in expanded_class_definition.properties) {
if (expanded_class_definition.properties.hasOwnProperty(property)) {
referenced = expanded_class_definition.properties[property];
if (referenced.$ref) {
if (!expanded_class_definition.properties[property]){
expanded_class_definition.properties[property] = {};
}
$.extend(expanded_class_definition.properties[property], expandSchema(
resolveReference(referenced.$ref, full_schema.class_definition),
full_schema));
}
}
}
*/
if (class_definition.oneOf) {
expanded_class_definition.oneOf = [];
for (i = 0; i < class_definition.oneOf.length; i += 1) {
......@@ -443,7 +423,9 @@
for (i = 0; i < class_definition.allOf.length; i += 1) {
referenced = expandSchema(class_definition.allOf[i], full_schema);
if (referenced.properties) {
$.extend(expanded_class_definition.properties, referenced.properties);
$.extend(
expanded_class_definition.properties,
referenced.properties);
delete referenced.properties;
}
$.extend(expanded_class_definition, referenced);
......@@ -452,50 +434,7 @@
if (expanded_class_definition.$ref) {
delete expanded_class_definition.$ref;
}
console.log('R', expanded_class_definition);
return Object.create(expanded_class_definition);
// expand refs directly in allOf
if (class_definition.xallOf) {
for (i = 0; i < class_definition.allOf.length; i += 1) {
referenced = class_definition.allOf[i];
if (referenced.$ref) {
referenced = Object.create(referenced);
$.extend(referenced, expandSchema(
resolveReference(referenced.$ref, full_schema.class_definition),
full_schema));
}
if (referenced.properties) {
for (property in referenced.properties) {
if (referenced.properties.hasOwnProperty(property)) {
//console.log('property2', property, referenced.properties[property]);
// and in allOf references. XXX I guess this can be merged with
// "expand ref inside properties"
if (referenced.properties[property].$ref) {
expanded_class_definition.properties[property] =
referenced.properties[property];
$.extend(expanded_class_definition.properties[property],
expandSchema(
resolveReference(referenced.properties[property].$ref,
full_schema.class_definition),
full_schema));
}
if (referenced.properties[property].type) {
if (! expanded_class_definition.properties[property] ) {
expanded_class_definition.properties[property] = {};
}
$.extend(expanded_class_definition.properties[property],
referenced.properties[property]);
}
}
}
}
}
}
return expanded_class_definition;
}
function openEdgeEditionDialog(gadget, connection) {
......@@ -615,7 +554,6 @@
gadget.props.data.class_definition[node_data._class],
gadget.props.data
);
console.log('editing node with', schema);
if (node_edit_popup.length !== 0) {
node_edit_popup.remove();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment