Commit 255cf060 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_json_editor: Disable ajax and catch promise

   The JSONEditor relies on call async load for load promises. The current code waits for the promises to finish and throw errors explicitly.

    This allows the renderjs properly handle the error on the same chain of promises.
parent 5ba514bc
......@@ -221,7 +221,7 @@
.push(function (schema) {
return new JSONEditor(domsugar(json_editor_container), {
schema: schema,
ajax: true,
ajax: false,
theme: 'bootstrap5',
show_errors: 'always',
//iconlib: 'fontawesome5',
......@@ -249,6 +249,14 @@
// it seems to crash rjs somewhere. To check...
// https://lab.nexedi.com/nexedi/renderjs/blob/master/renderjs.js#L2070
//return editor;
// editor relies on async load function, so we need to await the promise
// to finish before continue, otherwise rendering errors wont throw Errors
// in the same stack as expected.
return editor.promise.catch();
})
.push(undefined, function (err) {
throw new Error(err);
});
})
.declareMethod('getContent', function () {
......
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