Commit f785a2aa authored by Boris Kocherov's avatar Boris Kocherov

make compatible with gadget api

parent d99d9f2f
......@@ -498,6 +498,15 @@
})
.declareMethod('render', function (options) {
return this.changeState({
key: options.key,
value: options.value || "",
schema: options.schema,
schema_url: options.schema_url,
editable: options.editable === undefined ? true : options.editable
});
})
.onStateChange(function (options) {
var g = this;
g.props.toplevel = true;
// contain map of current normalized schema
......@@ -586,7 +595,25 @@
})
.declareMethod('getContent', function () {
return this.props.form_gadget.getContent();
var g = this;
if (g.state.editable) {
return g.props.form_gadget.getContent()
.push(function (value) {
// Change the value state in place
// 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;
if (g.state.key) {
var form_data = {};
value = JSON.stringify(value);
form_data[g.state.key] = value;
return form_data;
}
return value;
});
}
return {};
});
}(window, document, location, rJS, RSVP, jIO, tv4));
\ 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