Commit 4d093c6c authored by Boris Kocherov's avatar Boris Kocherov

getContent use empty string "" value only for required fields

parent 899c03a6
......@@ -980,6 +980,7 @@
function getFormValuesAsJSONDict(g) {
var multi_level_dict = {"": {}},
count_of_values = 0,
scope,
options = g.props,
array,
......@@ -998,6 +999,7 @@
if (ii === key_list.length - 1) {
if (value !== undefined) {
d[kk] = value;
count_of_values += 1;
} else {
return d[kk];
}
......@@ -1019,6 +1021,9 @@
return gadget.getContent();
})
.push(function (jdict) {
if (jdict === undefined) {
return;
}
convertOnMultiLevel(multi_level_dict, path, jdict);
});
}
......@@ -1032,6 +1037,9 @@
return gadget.getContent();
})
.push(function (jdict) {
if (jdict === undefined) {
return;
}
var arr = convertOnMultiLevel(multi_level_dict, parent_path);
if (!(arr instanceof Array)) {
arr = [];
......@@ -1077,7 +1085,7 @@
var json_dict = {},
k;
g.props.inputs.forEach(function (input) {
if (input.name === "" || input.value !== "") {
if (input.required || input.value !== "") {
if (input.type === 'number') {
json_dict[input.name] = parseInt(input.value, 10);
} else if (input.value === "true") {
......@@ -1100,6 +1108,9 @@
convertOnMultiLevel(multi_level_dict, k, json_dict[k]);
}
}
if (count_of_values === 0) {
return;
}
return multi_level_dict[""];
});
}
......
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