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,12 +676,11 @@ ...@@ -676,12 +676,11 @@
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)) {
return;
}
d = d[kk];
} }
if (!d.hasOwnProperty(kk)) {
return;
}
d = d[kk];
} }
} }
...@@ -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) { .push(function (ret) {
gadget = ret.gadget; gadget = ret;
return gadget.getContent(); });
}
if (opt.path) {
queue
.push(function () {
if (!gadget) {
gadget = g.props.form_gadget;
}
return gadget.getGadgetByPath(opt.path);
}) })
.push(function (value) { .push(function (ret) {
return gadget.rerender({ gadget = ret.gadget;
schema: schema,
value: value
})
.push(function () {
return gadget.reValidate(value, schema);
});
}); });
} }
return queue
.push(function () {
return gadget.getContent();
})
.push(function (value) {
return gadget.rerender({
schema: opt.schema,
value: value,
ignore_incorrect: opt.ignore_incorrect
})
.push(function () {
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