Commit 5819ba7b authored by Boris Kocherov's avatar Boris Kocherov

getContent can be return part of json document

parent b2706afe
...@@ -648,6 +648,23 @@ ...@@ -648,6 +648,23 @@
.push(schema_arr_marker); .push(schema_arr_marker);
} }
function convertOnMultiLevel(d, key) {
var ii,
kk,
key_list = key.split("/");
for (ii = 1; ii < key_list.length; ii += 1) {
kk = decodeJsonPointer(key_list[ii]);
if (ii === key_list.length - 1) {
return d[kk];
} else {
if (!d.hasOwnProperty(kk)) {
return;
}
d = d[kk];
}
}
}
rJS(window) rJS(window)
.ready(function () { .ready(function () {
var g = this; var g = this;
...@@ -925,7 +942,7 @@ ...@@ -925,7 +942,7 @@
} }
}, 500) }, 500)
.declareMethod('getContent', function () { .declareMethod('getContent', function (sub_path) {
var g = this; var g = this;
if (g.state.editable) { if (g.state.editable) {
return g.props.form_gadget.getContent() return g.props.form_gadget.getContent()
...@@ -935,6 +952,9 @@ ...@@ -935,6 +952,9 @@
// its parent call render with the same value // its parent call render with the same value
// (as ERP5 does in case of formulator error) // (as ERP5 does in case of formulator error)
g.state.value = JSON.stringify(value); g.state.value = JSON.stringify(value);
if (sub_path) {
value = convertOnMultiLevel(value, sub_path);
}
if (g.state.key) { if (g.state.key) {
var form_data = {}; var form_data = {};
value = JSON.stringify(value); value = JSON.stringify(value);
......
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