Commit 8fa21733 authored by Boris Kocherov's avatar Boris Kocherov

fix render_textarea support view objects if schema changed

parent 83a457e1
...@@ -101,13 +101,13 @@ ...@@ -101,13 +101,13 @@
return input; return input;
} }
function render_textarea(json_field, default_value, data_format) { function render_textarea(json_document, data_format) {
var input = document.createElement("textarea"); var input = document.createElement("textarea");
if (default_value !== undefined) { if (json_document !== undefined) {
if (default_value instanceof Array) { if (typeof json_document === "object") {
input.value = default_value.join("\n"); input.value = JSON.stringify(json_document, null, 2);
} else { } else {
input.value = default_value; input.value = json_document;
} }
} }
input["data-format"] = data_format; input["data-format"] = data_format;
...@@ -674,11 +674,11 @@ ...@@ -674,11 +674,11 @@
if (!input && ["string", "integer", "number"].indexOf(type) >= 0) { if (!input && ["string", "integer", "number"].indexOf(type) >= 0) {
if (json_field.contentMediaType === "text/plain") { if (json_field.contentMediaType === "text/plain") {
input = render_textarea(json_field, default_value, "string"); input = render_textarea(default_value, "string");
} else { } else {
input = document.createElement("input"); input = document.createElement("input");
if (default_value !== undefined) { if (default_value !== undefined) {
if (["object", "array"].indexOf(getDocumentType(default_value)) >= 0) { if (typeof default_value === "object") {
default_value = JSON.stringify(default_value); default_value = JSON.stringify(default_value);
} }
input.value = default_value; input.value = default_value;
......
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