Commit cff0e2ce authored by Boris Kocherov's avatar Boris Kocherov Committed by Romain Courteaud

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

parent 4d2855f2
...@@ -272,7 +272,7 @@ ...@@ -272,7 +272,7 @@
hash = url.hash; hash = url.hash;
url = url.href; url = url.href;
if (download_url.startsWith("urn:jio:")) { if (download_url.startsWith("urn:jio:")) {
external_reference = true; external_reference = download_url;
queue = RSVP.Queue() queue = RSVP.Queue()
.push(function () { .push(function () {
return g.resolveExternalReference(download_url, schema_path, path); return g.resolveExternalReference(download_url, schema_path, path);
...@@ -706,6 +706,31 @@ ...@@ -706,6 +706,31 @@
this.props.errors[arr[1]] = arr[0]; this.props.errors[arr[1]] = arr[0];
} }
}) })
.declareMethod('getSubGadget', function (scope) {
// recursive getDeclaredGadget
// work only if subgadget scope contain parent
// scope as prefix
// example:
// gadget: scope1234
// subgadet: scope1234_subgadgetscope1
// subsubgadet: scope1234_subgadgetscope1_subsubgadetscope
var i,
gadget = this,
scope_arr = scope.split('_'),
queue = RSVP.Queue()
.push(function () {
return gadget.props.form_gadget;
});
function getDeclaredGadget(scope) {
return function (g) {
return g.getDeclaredGadget(scope);
};
}
for (i = 2; i <= scope_arr.length; i += 1) {
queue.push(getDeclaredGadget(scope_arr.slice(0, i).join('_')));
}
return queue;
})
.declareMethod('getGadgetByPath', function (path) { .declareMethod('getGadgetByPath', function (path) {
return this.props.form_gadget.getGadgetByPath(path || "/"); return this.props.form_gadget.getGadgetByPath(path || "/");
}) })
......
...@@ -347,6 +347,15 @@ ...@@ -347,6 +347,15 @@
saveOrigValue: g.props.saveOrigValue, saveOrigValue: g.props.saveOrigValue,
ignore_incorrect: g.props.ignore_incorrect, ignore_incorrect: g.props.ignore_incorrect,
scope: scope scope: scope
})
.push(function () {
if (options.schema_arr.external_reference) {
return form_gadget.rootNotifyChange({
scope: scope,
action: "render",
path: "/"
});
}
}) })
.push(function () { .push(function () {
if (form_gadget.props.changed) { if (form_gadget.props.changed) {
...@@ -535,6 +544,7 @@ ...@@ -535,6 +544,7 @@
return schema_arr; return schema_arr;
} }
ret_arr[0].circular = circular; ret_arr[0].circular = circular;
ret_arr.external_reference = schema_arr.external_reference;
return ret_arr; return ret_arr;
} }
return schema_arr; return schema_arr;
...@@ -1818,6 +1828,7 @@ ...@@ -1818,6 +1828,7 @@
scope: v.scope || g.element.getAttribute("data-gadget-scope"), scope: v.scope || g.element.getAttribute("data-gadget-scope"),
rel_path: v.path, rel_path: v.path,
path: p, path: p,
ref: g.props.schema_arr.external_reference,
action: v.action action: v.action
}); });
}); });
...@@ -1833,6 +1844,7 @@ ...@@ -1833,6 +1844,7 @@
); );
} }
tasks.push(g.notifyInvalid([], g.element.getAttribute("data-gadget-scope"))); tasks.push(g.notifyInvalid([], g.element.getAttribute("data-gadget-scope")));
g.props.deleted = true;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return RSVP.all(tasks); return RSVP.all(tasks);
...@@ -2315,6 +2327,9 @@ ...@@ -2315,6 +2327,9 @@
.declareMethod('getContent', function () { .declareMethod('getContent', function () {
var g = this; var g = this;
if (g.props.deleted) {
return;
}
return getFormValuesAsJSONDict(g) return getFormValuesAsJSONDict(g)
.push(function (data) { .push(function (data) {
if (g.props.updatePropertySelectors) { if (g.props.updatePropertySelectors) {
......
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