Commit 4615cc05 authored by Boris Kocherov's avatar Boris Kocherov

[erp5_json_form] update from https://lab.nexedi.com/bk/rjs_json_form

parent a7042255
...@@ -1030,14 +1030,10 @@ ...@@ -1030,14 +1030,10 @@
}) })
.push(function (value) { .push(function (value) {
opt.value = value; opt.value = value;
g.props.init_value = value;
return gadget.rerender(opt) return gadget.rerender(opt)
.push(function () { .push(function () {
if (gadget.props.changed.length > 0) { delete g.props.init_value;
value = undefined;
}
return gadget.reValidate(value, opt.schema);
})
.push(function () {
return gadget.props.changed; return gadget.props.changed;
}); });
}); });
......
...@@ -2102,6 +2102,7 @@ ...@@ -2102,6 +2102,7 @@
}) })
.declareMethod('rerender', function (opt) { .declareMethod('rerender', function (opt) {
this.props.rerender = true;
var g = this, var g = this,
for_delete, for_delete,
root = g.element.querySelector('[data-json-path="/"]'); root = g.element.querySelector('[data-json-path="/"]');
...@@ -2143,9 +2144,10 @@ ...@@ -2143,9 +2144,10 @@
} }
return el; return el;
}); });
return g.checkValidity(value); return g.checkValidity(value, opt.schema);
}) })
.push(function () { .push(function () {
g.props.rerender = false;
return g.element; return g.element;
}); });
}) })
...@@ -2196,21 +2198,25 @@ ...@@ -2196,21 +2198,25 @@
.declareMethod('getSchema', function (json_document) { .declareMethod('getSchema', function (json_document) {
var g = this, var g = this,
schema_arr = g.props.schema_arr, schema_arr = g.props.schema_arr,
schema_path; schema;
// XXX complex need simplify
if (g.props.render_opt.selected_schema) { if (g.props.render_opt.selected_schema) {
schema_path = g.props.render_opt.selected_schema.schema_path; schema = g.props.render_opt.selected_schema;
} else { } else {
if (json_document !== undefined && !g.props.render_opt.top) { if (json_document !== undefined && !g.props.render_opt.top) {
schema_path = schemaArrFilteredByDocument(schema_arr, json_document)[0].schema_path; schema = schemaArrFilteredByDocument(schema_arr, json_document)[0];
} else if (schema_arr.schema_path) { } else if (schema_arr.schema_path && !schema_arr.external_reference) {
schema_path = schema_arr.schema_path; schema = schema_arr;
} else if (json_document !== undefined) { } else if (json_document !== undefined) {
schema_path = schemaArrFilteredByDocument(schema_arr, json_document)[0].schema_path; schema = schemaArrFilteredByDocument(schema_arr, json_document)[0];
} else { } else {
schema_path = schema_arr[0].schema_path; schema = schema_arr[0];
} }
} }
return g.rootGetSchema(schema_path); if (schema_arr && schema_arr.external_reference) {
return schema;
}
return g.rootGetSchema(schema.schema_path);
}) })
.declareMethod('checkValidity', function (json_document, schema) { .declareMethod('checkValidity', function (json_document, schema) {
...@@ -2301,7 +2307,7 @@ ...@@ -2301,7 +2307,7 @@
}) })
.onLoop(function () { .onLoop(function () {
if (this.props.needValidate) { if (this.props.needValidate && !this.props.rerender) {
return this.reValidate(); return this.reValidate();
} }
}, 500) }, 500)
......
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