Commit fea39d15 authored by Boris Kocherov's avatar Boris Kocherov

make code better understandable

parent ada8e633
......@@ -601,17 +601,17 @@
});
}
function render_array(gadget, json_field, default_array, root, path, schema_path) {
function render_array(gadget, schema, json_document, root, path, schema_path) {
var queue = RSVP.Queue(),
div,
div_input,
input,
item_schema,
i,
maxItems = json_field.maxItems;
maxItems = schema.maxItems;
div = document.createElement("div");
div.setAttribute("class", "subfield");
div.title = json_field.description;
div.title = schema.description;
div_input = document.createElement("div");
div_input.setAttribute("class", "input");
......@@ -622,7 +622,7 @@
}
}
item_schema = json_field.items;
item_schema = schema.items;
queue
.push(function () {
return expandSchema(gadget, item_schema, schema_path + '/items');
......@@ -643,15 +643,15 @@
.push(function (element) {
input = element;
// XXX update on every add/delete item
input.hidden = maxItems !== undefined && default_array.length >= maxItems;
input.hidden = maxItems !== undefined && json_document.length >= maxItems;
div_input.appendChild(input);
div.appendChild(div_input);
root.appendChild(div);
});
// XXX rewrite loading document for anyOf schema
if (default_array) {
for (i = 0; i < default_array.length; i = i + 1) {
if (json_document) {
for (i = 0; i < json_document.length; i = i + 1) {
queue
.push(
addSubForm.bind(gadget, {
......@@ -659,14 +659,14 @@
parent_type: 'array',
schema_path: schema_path + '/items',
schema_part: item_schema,
default_dict: default_array[i]
default_dict: json_document[i]
})
)
.push(element_append);
}
}
// XXX add failback rendering if default_array not array
// input = render_textarea(json_field, default_value, "array");
// XXX add failback rendering if json_document not array
// input = render_textarea(schema, default_value, "array");
return queue;
}
......
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