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

state modification catcher fixed

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