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