Commit 9301f06e authored by Tomáš Peterka's avatar Tomáš Peterka

[erp5_web_renderjs_ui] Remove useless IF in editable-form-validation

parent fa9cc706
...@@ -155,8 +155,9 @@ ...@@ -155,8 +155,9 @@
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
if (error.target !== undefined) { if (error.target !== undefined) {
var error_text, var error_text = 'Encountered an unknown error. Try to resubmit',
promise; promise;
// improve error message if we can
if (error.target.status === 400) { if (error.target.status === 400) {
error_text = 'Input data has errors'; error_text = 'Input data has errors';
} else if (error.target.status === 403) { } else if (error.target.status === 403) {
...@@ -164,22 +165,19 @@ ...@@ -164,22 +165,19 @@
} else if (error.target.status === 0) { } else if (error.target.status === 0) {
// no/default=0 status means a network connection problem // no/default=0 status means a network connection problem
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 {
// display "unknown error" rather than destroying user's form data (throwing an error)
error_text = 'Encountered an unknown error. Try to resubmit';
}
if (error_text !== undefined) {
promise = form_gadget.notifySubmitted()
.push(function () {
return form_gadget.translate(error_text);
})
.push(function (message) {
return form_gadget.notifyChange(message + '.');
});
} }
// display translated error_text to user
promise = form_gadget.notifySubmitted()
.push(function () {
return form_gadget.translate(error_text);
})
.push(function (message) {
return form_gadget.notifyChange(message + '.');
});
// if server validation of form data failed (indicated by response code 400)
// we parse out field errors and display them to the user
if (error.target.status === 400) { if (error.target.status === 400) {
// server validation of form data failed (indicated by reponse code 400)
// we parse out field errors and display them to the user
promise promise
.push(function () { .push(function () {
// when the server-side validation returns the error description // when the server-side validation returns the error description
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>960.32649.42585.31078</string> </value> <value> <string>960.32738.59764.37853</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>1499158937.47</float> <float>1499161198.51</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