Commit 3e65d87c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: ensure getContent is called before re-render the form

   This ensure data is saved before render a new form.
parent 49b6f64a
...@@ -499,6 +499,10 @@ ...@@ -499,6 +499,10 @@
.declareMethod("validateJSON", function (schema_url, generated_json) { .declareMethod("validateJSON", function (schema_url, generated_json) {
return this.getDeclaredGadget('json_form_load_schema') return this.getDeclaredGadget('json_form_load_schema')
.push(function (gadget) { .push(function (gadget) {
if (schema_url === undefined) {
// Skip validation if no schema is provided.
return {errors: []};
}
return gadget.validateJSON(undefined, schema_url, generated_json); return gadget.validateJSON(undefined, schema_url, generated_json);
}); });
}) })
......
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1007.63610.61612.6246</string> </value> <value> <string>1008.808.61596.8721</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -302,7 +302,7 @@ ...@@ -302,7 +302,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1682455523.98</float> <float>1682619529.51</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -153,14 +153,13 @@ ...@@ -153,14 +153,13 @@
div_error, div_error,
textarea, textarea,
show_text_button = g.element.querySelector("button.slapos-show-raw-parameter"), show_text_button = g.element.querySelector("button.slapos-show-raw-parameter"),
show_form_button = g.element.querySelector("button.slapos-show-form");; show_form_button = g.element.querySelector("button.slapos-show-form");
show_text_button.disabled = 1; show_text_button.disabled = 1;
show_text_button.classList.remove("ui-icon-code"); show_text_button.classList.remove("ui-icon-code");
show_text_button.classList.add("ui-icon-spinner"); show_text_button.classList.add("ui-icon-spinner");
show_form_button.disabled = 0; show_form_button.disabled = 0;
if (error_text) { if (error_text) {
div_error = domsugar('div', { div_error = domsugar('div', {
'class': 'error' 'class': 'error'
...@@ -412,16 +411,24 @@ ...@@ -412,16 +411,24 @@
'text/xml' 'text/xml'
).querySelector("parameter[id='_']"); ).querySelector("parameter[id='_']");
if (parameter_entry !== null) { parameter_list = parseDocumentStringOrFail(
throw new Error("The current parameter values should NOT contains _ parameter (xml).");
}
parseDocumentStringOrFail(
parameter_xml, parameter_xml,
'text/xml' 'text/xml'
).querySelectorAll("parameter") ).querySelectorAll("parameter");
.forEach(function (element, index) {
parameter_dict[element.id] = element.textContent; if (parameter_entry !== null) {
}); if (parameter_entry.textContent !== "{}") {
throw new Error("The current parameter values should NOT contains _ parameter (xml).");
}
}
parameter_list.forEach(
function (element, index) {
if (!((element.id === "_") && (element.textContent === "{}"))) {
parameter_dict[element.id] = element.textContent;
}
}
);
} else { } else {
throw new Error("Unknown serialisation: " + serialisation); throw new Error("Unknown serialisation: " + serialisation);
} }
...@@ -455,6 +462,8 @@ ...@@ -455,6 +462,8 @@
.fail(function (error) { .fail(function (error) {
console.warn(error); console.warn(error);
console.log(error.stack); console.log(error.stack);
show_form_button.classList.remove("ui-icon-spinner");
show_form_button.classList.add("ui-icon-th-list");
return renderDisplayRawXml(gadget, error.toString()); return renderDisplayRawXml(gadget, error.toString());
}); });
} }
...@@ -549,11 +558,15 @@ ...@@ -549,11 +558,15 @@
if (evt.target === software_type_element) { if (evt.target === software_type_element) {
parameter_shared.value = software_type_element.selectedOptions[0]["data-shared"]; parameter_shared.value = software_type_element.selectedOptions[0]["data-shared"];
return gadget.changeState({ // call get content to ensure data is saved.
softwareindex: software_type_element.selectedOptions[0]["data-id"], return gadget.getContent()
// Force refresh in any case .push(function () {
render_timestamp: new Date().getTime() return gadget.changeState({
}); softwareindex: software_type_element.selectedOptions[0]["data-id"],
// Force refresh in any case
render_timestamp: new Date().getTime()
});
});
} }
}, false, false) }, false, false)
......
...@@ -284,7 +284,7 @@ ...@@ -284,7 +284,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1007.63580.6957.21418</string> </value> <value> <string>1007.64857.33700.1467</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -304,7 +304,7 @@ ...@@ -304,7 +304,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1682453675.95</float> <float>1682532947.32</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