Commit fa45756e authored by Boris Kocherov's avatar Boris Kocherov

support `default` value worked with `enum`

parent ed436c28
......@@ -111,24 +111,30 @@
function render_selection(schema, json_document) {
var input = document.createElement("select"),
option = document.createElement("option"),
option_index,
optionz;
option,
option_index;
input.size = 1;
if (schema.default) {
if (json_document === undefined) {
json_document = schema.default;
}
} else {
option = document.createElement("option");
option.value = "";
if (json_document === undefined) {
option.selected = "selected";
}
input.appendChild(option);
}
for (option_index in schema['enum']) {
if (schema['enum'].hasOwnProperty(option_index)) {
optionz = document.createElement("option");
optionz.value = schema['enum'][option_index];
optionz.textContent = schema['enum'][option_index];
option = document.createElement("option");
option.value = schema['enum'][option_index];
option.textContent = schema['enum'][option_index];
if (schema['enum'][option_index] === json_document) {
optionz.selected = "selected";
option.selected = "selected";
}
input.appendChild(optionz);
input.appendChild(option);
}
}
return input;
......
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