Commit 32de851f authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Tomáš Peterka

[renderjs_ui] Dialog shows custom portal_message if included in HTTP500

/reviewed-on !570
parent 51b90925
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
.push(undefined, function (error) { .push(undefined, function (error) {
if (error.target !== undefined) { if (error.target !== undefined) {
var error_text = 'Encountered an unknown error. Try to resubmit', var error_text = 'Encountered an unknown error. Try to resubmit',
promise; promise_queue = new RSVP.Queue();
// if we know what the error was, try to precise it for the user // if we know what the error was, try to precise it for the user
if (error.target.status === 400) { if (error.target.status === 400) {
error_text = 'Input data has errors'; error_text = 'Input data has errors';
...@@ -189,9 +189,21 @@ ...@@ -189,9 +189,21 @@
error_text = 'You do not have the permissions to edit the object'; error_text = 'You do not have the permissions to edit the object';
} else if (error.target.status === 0) { } else if (error.target.status === 0) {
error_text = 'Document was not saved! Resubmit when you are online or the document accessible'; error_text = 'Document was not saved! Resubmit when you are online or the document accessible';
} else if (error.target.status === 500 && error.target.response.type === "application/json") {
promise_queue
.push(function () {
return jIO.util.readBlobAsText(error.target.response);
})
.push(function (response_text) {
var response = JSON.parse(response_text.target.result);
error_text = response.portal_status_message;
});
} }
// display translated error_text to user // display translated error_text to user
promise = form_gadget.notifySubmitted() promise_queue
.push(function () {
return form_gadget.notifySubmitted();
})
.push(function () { .push(function () {
return form_gadget.translate(error_text); return form_gadget.translate(error_text);
}) })
...@@ -204,7 +216,7 @@ ...@@ -204,7 +216,7 @@
// if server validation of form data failed (indicated by response code 400) // if server validation of form data failed (indicated by response code 400)
// we parse out field errors and display them to the user // we parse out field errors and display them to the user
if (error.target.status === 400) { if (error.target.status === 400) {
promise promise_queue
.push(function () { .push(function () {
// when the server-side validation returns the error description // when the server-side validation returns the error description
if (error.target.responseType === "blob") { if (error.target.responseType === "blob") {
...@@ -217,7 +229,7 @@ ...@@ -217,7 +229,7 @@
return form_gadget.displayFormulatorValidationError(JSON.parse(event.target.result)); return form_gadget.displayFormulatorValidationError(JSON.parse(event.target.result));
}); });
} }
return promise; return promise_queue;
} }
throw error; throw error;
}); });
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.10338.33096.47104</string> </value> <value> <string>965.13214.39160.9318</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1517305313.45</float> <float>1517480919.98</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