Commit ea3510f6 authored by Boris Kocherov's avatar Boris Kocherov

make possible use complex schema_arr fields as array items

parent b4d52192
......@@ -178,13 +178,16 @@
return input;
}
function render_enum_with_title(g, schema_arr, json_document) {
function render_enum_with_title(g, schema_arr, json_document, selected_schema) {
var input = document.createElement("select"),
option,
i,
ser_value,
selected = false;
input.size = 1;
if (json_document === undefined && selected_schema !== undefined) {
json_document = selected_schema.schema.const;
}
if (schema_arr[0].schema.default) {
if (json_document === undefined) {
json_document = schema_arr[0].schema.default;
......@@ -333,6 +336,7 @@
type: options.type,
required: options.required,
delete_button: options.delete_button,
selected_schema: options.selected_schema,
schema_arr: options.schema_arr,
document: options.json_document,
display_label: options.parent_type !== "array",
......@@ -797,7 +801,8 @@
gadget: gadget,
parent_type: 'array',
type: value.type,
schema_arr: [value]
selected_schema: value,
schema_arr: schema_arr
})
.push(element_append);
}));
......@@ -824,7 +829,8 @@
gadget: gadget,
parent_type: 'array',
type: value.type,
schema_arr: [value]
selected_schema: value,
schema_arr: schema_arr
})
.push(element_append);
}));
......@@ -858,8 +864,12 @@
type_changed,
queue = RSVP.Queue();
// XXX if (ret_arr.length > 1) notify user
schema_ob = schemaArrFilteredByDocument(schema_arr, json_document)[0];
if (options.selected_schema) {
schema_ob = options.selected_schema;
} else {
// XXX if (ret_arr.length > 1) notify user
schema_ob = schemaArrFilteredByDocument(schema_arr, json_document)[0];
}
schema = schema_ob.schema;
schema_path = schema_ob.schema_path;
......@@ -941,7 +951,7 @@
.join(" ")
// use non-breaking hyphen
.replace(/-/g, "");
if (label_text) {
if (property_name || options.top) {
if (options.top) {
label = document.createElement("span");
label.textContent = label_text;
......@@ -961,7 +971,7 @@
// render input begin
if (!input && schema_arr[0].is_arr_of_const) {
input = render_enum_with_title(gadget, schema_arr, json_document);
input = render_enum_with_title(gadget, schema_arr, json_document, options.selected_schema);
}
if (!input && schema.const !== undefined) {
input = render_const(gadget, schema, json_document);
......@@ -1850,6 +1860,7 @@
options.document, root,
{
type: options.type,
selected_schema: options.selected_schema,
required: options.required,
delete_button: options.delete_button,
top: options.top
......
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