Commit b98c187f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Fixup support for floats on the forms

   If the field is number the field is handled as float, and not as integer anymore.
parent 2e5320ef
......@@ -105,7 +105,6 @@
}
function render_field(json_field, default_value) {
if (json_field['enum'] !== undefined) {
return render_selection(json_field, default_value);
}
......@@ -133,27 +132,24 @@
return render_textarea(json_field, default_value, "string");
}
var value,
type;
var domsugar_input_dict = {};
if (default_value !== undefined) {
value = default_value;
domsugar_input_dict.value = default_value;
}
if (json_field.type === "integer") {
type = "number";
domsugar_input_dict.type = "number";
} else if (json_field.type === "number") {
type = "number";
domsugar_input_dict.type = "number";
domsugar_input_dict.step = "any";
} else if (json_field.type === "hidden") {
type = "hidden";
domsugar_input_dict.type = "hidden";
} else {
type = "text";
domsugar_input_dict.type = "text";
}
return domsugar('input', {
value: value,
type: type
});
return domsugar('input', domsugar_input_dict);
}
function render_subform(json_field, default_dict, root, path, restricted) {
......@@ -333,7 +329,7 @@
$(element.querySelectorAll(".slapos-parameter")).each(function (key, input) {
if (input.value !== "") {
if (input.type === 'number') {
json_dict[input.name] = parseInt(input.value, 10);
json_dict[input.name] = parseFloat(input.value);
} else if (input.value === "true") {
json_dict[input.name] = true;
} else if (input.value === "false") {
......
......@@ -280,7 +280,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.2322.46712.16657</string> </value>
<value> <string>1000.2445.60408.49186</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -298,7 +298,7 @@
</tuple>
<state>
<tuple>
<float>1651775757.92</float>
<float>1651782344.19</float>
<string>UTC</string>
</tuple>
</state>
......
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