Commit 8a1f11f1 authored by Boris Kocherov's avatar Boris Kocherov

correctly return empty json_documents

parent b7bdafad
......@@ -1411,7 +1411,7 @@
if (input.hasAttribute('data-origin-value')) {
json_dict[input.name] = JSON.parse(input.getAttribute('data-origin-value'));
} else {
if (input.required || input.value !== "") {
if (input.value !== "") {
var type = input.getAttribute('data-json-type');
if (input.tagName === "SELECT" && input.value) {
// selection used for enums
......@@ -1445,10 +1445,18 @@
}
if (count_of_values === 0) {
switch (g.props.type) {
case "string":
return "";
case "number":
return null;
case "boolean":
return null;
case "array":
return [];
case "object":
return {};
default:
return null;
return;
}
}
return multi_level_dict[""];
......@@ -1635,7 +1643,7 @@
property_name = g.element.getAttribute('data-json-property-name'),
schema = options.schema,
root;
g.props.change = false;
g.props.changed = false;
g.props.saveOrigValue = options.saveOrigValue;
g.props.inputs = [];
g.props.add_buttons = [];
......@@ -1661,9 +1669,8 @@
options.type = guessSchemaType(schema);
}
// used for empty document generation
g.props.type = getDocumentType(options.document) ||
(schema && typeof schema.type === "string" && schema.type) ||
options.type;
g.props.type = (schema && typeof schema.type === "string" && schema.type) ||
options.type || getDocumentType(options.document);
while (root.firstChild) {
root.removeChild(root.firstChild);
}
......
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