Commit ac03cab9 authored by Boris Kocherov's avatar Boris Kocherov

add saveOrigValue option for render()

now it's useful only for tests
parent 35492a16
......@@ -599,6 +599,7 @@
key: options.key,
value: JSON.stringify(options.value) || '""',
schema: JSON.stringify(options.schema),
saveOrigValue: options.saveOrigValue,
schema_url: options.schema_url,
editable: options.editable === undefined ? true : options.editable
});
......@@ -677,6 +678,7 @@
schema: schema,
schema_path: "",
document: json_document,
saveOrigValue: g.state.saveOrigValue,
required: true,
top: true
});
......
......@@ -274,6 +274,7 @@
schema_path: options.schema_path,
document: options.default_dict,
display_label: options.parent_type !== "array",
saveOrigValue: g.props.saveOrigValue,
scope: scope
})
.push(function () {
......@@ -720,6 +721,19 @@
if (getDocumentType(json_field.type) === "string") {
type = json_field.type;
} // else json_field.type is array so we use type
if (["object", "array"].indexOf(type) >= 0 &&
default_value !== undefined &&
getDocumentType(default_value) !== type) {
if (gadget.props.saveOrigValue) {
// XXX is not useful for user
// only for tests
json_field = {
const: default_value
};
} else {
gadget.props.changed = true;
}
}
if (type === undefined && default_value !== undefined) {
type = getDocumentType(default_value);
}
......@@ -1617,6 +1631,7 @@
schema = options.schema,
root;
g.props.change = false;
g.props.saveOrigValue = options.saveOrigValue;
g.props.inputs = [];
g.props.add_buttons = [];
g.props.add_custom_data = {};
......
......@@ -178,7 +178,8 @@
.push(function (g) {
var opt = {
key: key,
value: value
value: value,
saveOrigValue: true
};
gadget = g;
if (schema !== undefined) {
......
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