Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions dist/js/brutusin-json-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ if (typeof brutusin === "undefined") {
} else if (s.media) {
input = document.createElement("input");
input.type = "file";
appendChild(input, option, s);
// XXX TODO, encode the SOB properly.
} else if (s.enum) {
input = document.createElement("select");
Expand Down Expand Up @@ -205,7 +204,7 @@ if (typeof brutusin === "undefined") {
}
}
if (s.enum.length === 1)
input.selectedIndex = 1;
input.selectedIndex = 0;
else
input.selectedIndex = selectedIndex;
} else {
Expand All @@ -223,6 +222,10 @@ if (typeof brutusin === "undefined") {
// #46, problem in IE11. TODO polyfill?
input.type = "text";
}
} else if (s.format === "date") {
input.type = "date";
} else if (s.format === "time") {
input.type = "time";
} else if (s.format === "email") {
input.type = "email";
} else if (s.format === "text") {
Expand Down Expand Up @@ -345,8 +348,8 @@ if (typeof brutusin === "undefined") {
if (s.required) {
input = document.createElement("input");
input.type = "checkbox";
if (value === true) {
input.checked = true;
if (value === true || value !== false && s.default) {
input.checked = true;
}
} else {
input = document.createElement("select");
Expand Down Expand Up @@ -408,6 +411,11 @@ if (typeof brutusin === "undefined") {
var propId = schemaId + "." + i;
var ss = getSchema(propId);
var textNode = document.createTextNode(ss.title);

// If there is only 1 option render it by itself
if (s.oneOf.length === 1)
return render(null, container, propId, parentObject, propertyProvider, value);

option.value = s.oneOf[i];
appendChild(option, textNode, s);
appendChild(input, option, s);
Expand Down Expand Up @@ -747,6 +755,7 @@ if (typeof brutusin === "undefined") {
if (s.readOnly)
addButton.disabled = true;
addButton.setAttribute('type', 'button');
addButton.className = "addItem";
addButton.getValidationError = function () {
if (s.minItems && s.minItems > table.rows.length) {
return BrutusinForms.messages["minItems"].format(s.minItems);
Expand Down Expand Up @@ -827,8 +836,8 @@ if (typeof brutusin === "undefined") {

obj.getData = function () {
function removeEmptiesAndNulls(object, s) {
if (ss === null) {
ss = SCHEMA_ANY;
if (s === null) {
s = SCHEMA_ANY;
}
if (s.$ref) {
s = getDefinition(s.$ref);
Expand Down Expand Up @@ -1307,7 +1316,7 @@ if (typeof brutusin === "undefined") {

function cleanSchemaMap(schemaId) {
for (var prop in schemaMap) {
if (schemaId.startsWith(prop)) {
if (prop.startsWith(schemaId)) {
delete schemaMap[prop];
}
}
Expand Down
Loading