Commit 35492a16 authored by Boris Kocherov's avatar Boris Kocherov

notify about changes after rendering if document changed during render

parent 26024012
......@@ -684,6 +684,11 @@
.push(function () {
return g.checkValidity();
})
.push(function () {
if (g.props.form_gadget.props.changed) {
g.notifyChange();
}
})
.push(function () {
return g;
});
......
......@@ -121,7 +121,7 @@
return schema;
}
function render_enum(schema, json_document) {
function render_enum(g, schema, json_document) {
var input = document.createElement("select"),
option,
i,
......@@ -132,6 +132,7 @@
if (schema.default) {
if (json_document === undefined) {
json_document = schema.default;
g.props.changed = true;
}
} else {
option = document.createElement("option");
......@@ -177,7 +178,7 @@
return input;
}
function render_boolean(schema, json_document) {
function render_boolean(g, schema, json_document) {
var input,
schema_for_selection = {
type: "boolean",
......@@ -193,7 +194,7 @@
if (getDocumentType(schema.default) === "boolean") {
schema_for_selection.default = schema.default;
}
input = render_enum(schema_for_selection, json_document);
input = render_enum(g, schema_for_selection, json_document);
input.setAttribute('data-json-type', "boolean");
return input;
}
......@@ -274,7 +275,13 @@
document: options.default_dict,
display_label: options.parent_type !== "array",
scope: scope
});
})
.push(function () {
if (form_gadget.props.changed) {
g.props.changed = true;
}
return form_gadget.element;
});
});
}
......@@ -777,7 +784,7 @@
if (json_field.const !== undefined) {
input = render_const(json_field, default_value);
} else if (json_field.enum !== undefined) {
input = render_enum(json_field, default_value);
input = render_enum(gadget, json_field, default_value);
// XXX take in account existing type with enum
type_changed = false;
}
......@@ -787,7 +794,7 @@
}
if (!input && type === "boolean") {
input = render_boolean(json_field, default_value);
input = render_boolean(gadget, json_field, default_value);
}
if (!input && ["string", "integer", "number", "null"].indexOf(type) >= 0) {
......@@ -806,6 +813,7 @@
if (type === "integer" || type === "number") {
if (default_value === undefined && typeof json_field.default === "number") {
input.value = json_field.default;
gadget.props.changed = true;
}
input.setAttribute("data-json-type", type);
if (default_value === undefined || default_value === null ||
......@@ -827,6 +835,7 @@
} else {
if (default_value === undefined && typeof json_field.default === "string") {
input.value = json_field.default;
gadget.props.changed = true;
}
input.type = "text";
if (json_field.pattern) {
......@@ -1607,6 +1616,7 @@
property_name = g.element.getAttribute('data-json-property-name'),
schema = options.schema,
root;
g.props.change = false;
g.props.inputs = [];
g.props.add_buttons = [];
g.props.add_custom_data = {};
......
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