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