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

correctly return empty json_documents

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