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