Commit 41a31511 authored by Boris Kocherov's avatar Boris Kocherov

render_const() notify if document was undefined and changed after render()

parent 1be336de
...@@ -199,12 +199,15 @@ ...@@ -199,12 +199,15 @@
return input; return input;
} }
function render_const(schema, json_document) { function render_const(g, schema, json_document) {
var input = document.createElement("input"), var input = document.createElement("input"),
ser_doc = JSON.stringify(json_document), ser_doc = JSON.stringify(json_document),
ser_const = JSON.stringify(schema.const); ser_const = JSON.stringify(schema.const);
input.setAttribute('readonly', true); input.setAttribute('readonly', true);
if (json_document === undefined || deepEqual(json_document, schema.const)) { if (json_document === undefined || deepEqual(json_document, schema.const)) {
if (json_document === undefined) {
g.props.changed = true;
}
input.setAttribute('data-origin-value', ser_const); input.setAttribute('data-origin-value', ser_const);
input.value = ser_const; input.value = ser_const;
} else { } else {
...@@ -880,7 +883,7 @@ ...@@ -880,7 +883,7 @@
div_input.setAttribute("class", "input"); div_input.setAttribute("class", "input");
if (json_field.const !== undefined) { if (json_field.const !== undefined) {
input = render_const(json_field, default_value); input = render_const(gadget, json_field, default_value);
} else if (json_field.enum !== undefined) { } else if (json_field.enum !== undefined) {
input = render_enum(gadget, json_field, default_value); input = render_enum(gadget, json_field, default_value);
// XXX take in account existing type with enum // XXX take in account existing type with enum
...@@ -888,7 +891,7 @@ ...@@ -888,7 +891,7 @@
} }
if (!input && type === "null") { if (!input && type === "null") {
input = render_const({const: null}, default_value); input = render_const(gadget, {const: null}, default_value);
} }
if (!input && type === "boolean") { if (!input && type === "boolean") {
......
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