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