Commit 9de8dd26 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 18c77a5f
...@@ -311,6 +311,7 @@ ...@@ -311,6 +311,7 @@
pointed_a pointed_a
] ]
}; };
console.error(err);
return null; // schema part can't be null return null; // schema part can't be null
}) })
.push(function (schema_part) { .push(function (schema_part) {
...@@ -897,6 +898,7 @@ ...@@ -897,6 +898,7 @@
if (json_document !== undefined) { if (json_document !== undefined) {
json_document = JSON.parse(json_document); json_document = JSON.parse(json_document);
} }
g.props.init_value = json_document;
if (g.state.schema !== undefined) { if (g.state.schema !== undefined) {
schema = JSON.parse(g.state.schema); schema = JSON.parse(g.state.schema);
} }
...@@ -987,6 +989,7 @@ ...@@ -987,6 +989,7 @@
if (g.props.form_gadget.props.changed.length > 0) { if (g.props.form_gadget.props.changed.length > 0) {
g.notifyChange(); g.notifyChange();
} }
delete g.props.init_value;
}) })
.push(undefined, function (err) { .push(undefined, function (err) {
console.error(err); console.error(err);
...@@ -1044,10 +1047,19 @@ ...@@ -1044,10 +1047,19 @@
return expandSchemaForField(this, arr[0], arr[1], arr[2], arr[3]); return expandSchemaForField(this, arr[0], arr[1], arr[2], arr[3]);
}) })
.declareMethod('getContentMutex', function () {
return this.props.form_gadget.getContent();
}, {mutex: 'changestate'})
.declareMethod('getContent', function (sub_path) { .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 RSVP.Queue()
.push(function () {
if (g.props.init_value) {
return g.props.init_value;
}
return g.getContentMutex();
})
.push(function (value) { .push(function (value) {
// Change the value state in place // Change the value state in place
// This will prevent the gadget to be changed if // This will prevent the gadget to be changed if
...@@ -1067,6 +1079,6 @@ ...@@ -1067,6 +1079,6 @@
}); });
} }
return {}; return {};
}, {mutex: 'changestate'}); });
}(window, document, Blob, rJS, RSVP, jIO)); }(window, document, Blob, rJS, RSVP, jIO));
\ No newline at end of file
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