Commit 48b4dabe authored by Boris Kocherov's avatar Boris Kocherov

save default value = empty object and use it for getContent if object does not have properties

parent e432b77c
......@@ -1104,6 +1104,7 @@
//input.setAttribute("class", "slapos-parameter");
div_input.appendChild(input);
} else {
div.setAttribute("data-parent-scope", gadget.element.getAttribute("data-gadget-scope"));
div.setAttribute("data-json-path", first_path + '/');
div.setAttribute("data-json-type", type);
}
......@@ -1325,6 +1326,11 @@
root.appendChild(child);
}
if (JSON.stringify(schema.default) === '{}') {
// save default value as attribute only for empty values
root.parentElement.setAttribute("data-default-value", '{}');
}
if (json_document === undefined) {
if (schema.hasOwnProperty('default')) {
json_document = schema.default;
......@@ -1588,6 +1594,18 @@
});
}
// set empty object if default value require this
array = g.element
.querySelectorAll("div[data-parent-scope='" +
g.element.getAttribute("data-gadget-scope") + "']");
for (i = 0; i < array.length; i += 1) {
path = array[i].getAttribute("data-json-path").slice(0, -1);
if (array[i].getAttribute("data-default-value") === "{}") {
convertOnMultiLevel(multi_level_dict, path, {});
}
}
for (path in options.arrays) {
if (options.arrays.hasOwnProperty(path)) {
array = options.arrays[path]
......
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