Commit f3caa368 authored by Boris Kocherov's avatar Boris Kocherov

add render_boolean() and use default value from schema

parent 4603653d
...@@ -140,6 +140,26 @@ ...@@ -140,6 +140,26 @@
return input; return input;
} }
function render_boolean(schema, json_document) {
var input,
schema_for_selection = {
type: "boolean",
enum: [true, false]
};
// XXX change json_document on open is not correct @bk
if (json_document === "true") {
json_document = true;
}
if (json_document === "false") {
json_document = false;
}
if (getDocumentType(schema.default) === "boolean") {
schema_for_selection.default = schema.default;
}
input = render_selection(schema_for_selection, json_document);
return input;
}
function render_textarea(json_field, default_value, data_format) { function render_textarea(json_field, default_value, data_format) {
var input = document.createElement("textarea"); var input = document.createElement("textarea");
if (default_value !== undefined) { if (default_value !== undefined) {
...@@ -676,16 +696,7 @@ ...@@ -676,16 +696,7 @@
} }
if (type === "boolean") { if (type === "boolean") {
if (default_value === "true") { input = render_boolean(json_field, default_value);
default_value = true;
}
if (default_value === "false") {
default_value = false;
}
input = render_selection({
type: "boolean",
enum: [true, false]
}, default_value);
} }
if (!input && ["string", "integer", "number"].indexOf(type) >= 0) { if (!input && ["string", "integer", "number"].indexOf(type) >= 0) {
......
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