Commit a68980fb authored by Boris Kocherov's avatar Boris Kocherov

use required html5 attribute

parent 42b8f77d
...@@ -598,8 +598,9 @@ ...@@ -598,8 +598,9 @@
return queue; return queue;
} }
function render_field(gadget, key, path, json_field, default_value, root, schema_path, type) { function render_field(gadget, key, path, json_field, default_value, root, schema_path, options) {
var div, var type,
div,
label, label,
div_input, div_input,
span_info, span_info,
...@@ -608,6 +609,9 @@ ...@@ -608,6 +609,9 @@
first_path, first_path,
queue = RSVP.Queue(); queue = RSVP.Queue();
options = options || {};
type = options.type;
if (path && key) { if (path && key) {
first_path = path + encodeJsonPointer(key); first_path = path + encodeJsonPointer(key);
} else { } else {
...@@ -719,6 +723,7 @@ ...@@ -719,6 +723,7 @@
// gadget.props.inputs not contain values // gadget.props.inputs not contain values
gadget.props.inputs.push(input); gadget.props.inputs.push(input);
input.name = first_path; input.name = first_path;
input.required = options.required;
// XXX for gui // XXX for gui
//input.setAttribute("class", "slapos-parameter"); //input.setAttribute("class", "slapos-parameter");
div_input.appendChild(input); div_input.appendChild(input);
...@@ -840,7 +845,7 @@ ...@@ -840,7 +845,7 @@
} }
queue queue
.push(render_field.bind(g, g, key, path, .push(render_field.bind(g, g, key, path,
json_field.properties[key], default_dict[key], root) json_field.properties[key], default_dict[key], root, schema_path, {required: true})
); );
} else if (default_dict.hasOwnProperty(key)) { } else if (default_dict.hasOwnProperty(key)) {
used_properties[key] = ""; used_properties[key] = "";
...@@ -1333,7 +1338,7 @@ ...@@ -1333,7 +1338,7 @@
root.appendChild(delete_button); root.appendChild(delete_button);
} }
return render_field(g, property_name, "", schema, return render_field(g, property_name, "", schema,
options.document, root, options.schema_path, options.type) options.document, root, options.schema_path, {type: options.type})
.push(function () { .push(function () {
g.listenEvents(); g.listenEvents();
return g.element; return g.element;
......
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