Commit 59e8ced8 authored by Boris Kocherov's avatar Boris Kocherov

state modification catcher fixed

parent 62279dd6
......@@ -500,14 +500,19 @@
.declareMethod('render', function (options) {
return this.changeState({
key: options.key,
value: options.value || "",
schema: options.schema,
value: JSON.stringify(options.value) || '""',
schema: JSON.stringify(options.schema),
schema_url: options.schema_url,
editable: options.editable === undefined ? true : options.editable
});
})
.onStateChange(function (options) {
var g = this;
.onStateChange(function () {
var g = this,
json_document = JSON.parse(g.state.value),
schema;
if (g.state.schema !== undefined) {
schema = JSON.parse(g.state.schema);
}
g.props.toplevel = true;
// contain map of current normalized schema
// json pointer and corresponding url
......@@ -537,11 +542,11 @@
}
})
.push(function () {
if (options.schema) {
return options.schema;
if (schema) {
return schema;
}
var schema_url = options.schema_url ||
(options.value && options.value.$schema);
var schema_url = g.state.schema_url ||
(json_document && json_document.$schema);
if (schema_url) {
return loadJSONSchema(g, schema_url)
.push(function (schema_arr) {
......@@ -551,11 +556,10 @@
return {};
})
.push(function (schema) {
g.options.schema = schema;
return g.props.form_gadget.renderForm({
schema: schema,
schema_path: "",
document: options.value,
document: json_document,
required: true,
top: true
});
......@@ -603,7 +607,7 @@
// This will prevent the gadget to be changed if
// its parent call render with the same value
// (as ERP5 does in case of formulator error)
g.state.value = value;
g.state.value = JSON.stringify(value);
if (g.state.key) {
var form_data = {};
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