Commit fea39d15 authored by Boris Kocherov's avatar Boris Kocherov

make code better understandable

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