mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Handle different form responses
This commit is contained in:
parent
9927b597c3
commit
52952a8a8b
@ -532,10 +532,49 @@ function submitFormData(fields, options) {
|
|||||||
error: function(xhr, status, thrownError) {
|
error: function(xhr, status, thrownError) {
|
||||||
|
|
||||||
switch (xhr.status) {
|
switch (xhr.status) {
|
||||||
case 400: // Bad request
|
case 400: // Bad request
|
||||||
handleFormErrors(xhr.responseJSON, fields, options);
|
handleFormErrors(xhr.responseJSON, fields, options);
|
||||||
break;
|
break;
|
||||||
|
case 0: // No response
|
||||||
|
$(options.modal).modal('hide');
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "No Response" %}',
|
||||||
|
'{% trans "No response from the InvenTree server" %}',
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 401: // Not authenticated
|
||||||
|
$(options.modal).modal('hide');
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Error 401: Not Authenticated" %}',
|
||||||
|
'{% trans "Authentication credentials not supplied" %}',
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 403: // Permission denied
|
||||||
|
$(options.modal).modal('hide');
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Error 403: Permission Denied" %}',
|
||||||
|
'{% trans "You do not have the required permissions to access this function" %}',
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 404: // Resource not found
|
||||||
|
$(options.modal).modal('hide');
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Error 404: Resource Not Found" %}',
|
||||||
|
'{% trans "The requested resource could not be located on the server" %}',
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 408: // Timeout
|
||||||
|
$(options.modal).modal('hide');
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Error 408: Timeout" %}',
|
||||||
|
'{% trans "Connection timeout while requesting data from server" %}',
|
||||||
|
);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
$(options.modal).modal('hide');
|
||||||
|
|
||||||
|
showAlertDialog('{% trans "Error requesting form data" %}', renderErrorMessage(xhr));
|
||||||
|
|
||||||
console.log(`WARNING: Unhandled response code - ${xhr.status}`);
|
console.log(`WARNING: Unhandled response code - ${xhr.status}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user