Commit 0b866318 authored by Boris Kocherov's avatar Boris Kocherov

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

parent d0e41b15
/*jslint nomen: true, maxlen: 200, indent: 2, maxerr: 100*/ /*jslint nomen: true, maxlen: 200, indent: 2, maxerr: 100*/
/*global window, document, URL, rJS, RSVP, jIO, tv4, Blob */ /*global window, document, URL, rJS, RSVP, jIO, Blob */
(function (window, document, Blob, rJS, RSVP, jIO) { (function (window, document, Blob, rJS, RSVP, jIO) {
"use strict"; "use strict";
...@@ -676,14 +676,13 @@ ...@@ -676,14 +676,13 @@
kk = decodeJsonPointer(key_list[ii]); kk = decodeJsonPointer(key_list[ii]);
if (ii === key_list.length - 1) { if (ii === key_list.length - 1) {
return d[kk]; return d[kk];
} else { }
if (!d.hasOwnProperty(kk)) { if (!d.hasOwnProperty(kk)) {
return; return;
} }
d = d[kk]; d = d[kk];
} }
} }
}
rJS(window) rJS(window)
.ready(function () { .ready(function () {
...@@ -967,25 +966,48 @@ ...@@ -967,25 +966,48 @@
console.error(err); console.error(err);
}); });
}) })
.declareMethod('rerender', function (path, schema) { .declareMethod('rerender', function (opt) {
var g = this, var g = this,
gadget; gadget,
if (path) { queue = RSVP.Queue();
return g.props.form_gadget.getGadgetByPath(path) if (opt.scope) {
queue
.push(function () {
return g.props.form_gadget.getDeclaredGadget(opt.scope);
})
.push(function (ret) {
gadget = ret;
});
}
if (opt.path) {
queue
.push(function () {
if (!gadget) {
gadget = g.props.form_gadget;
}
return gadget.getGadgetByPath(opt.path);
})
.push(function (ret) { .push(function (ret) {
gadget = ret.gadget; gadget = ret.gadget;
});
}
return queue
.push(function () {
return gadget.getContent(); return gadget.getContent();
}) })
.push(function (value) { .push(function (value) {
return gadget.rerender({ return gadget.rerender({
schema: schema, schema: opt.schema,
value: value value: value,
ignore_incorrect: opt.ignore_incorrect
}) })
.push(function () { .push(function () {
return gadget.reValidate(value, schema); if (gadget.props.changed) {
value = undefined;
}
return gadget.reValidate(value, opt.schema);
}); });
}); });
}
}) })
.allowPublicAcquisition("expandSchema", function (arr) { .allowPublicAcquisition("expandSchema", function (arr) {
......
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