Draft: Improve error handling when attaching files

This commit is contained in:
Francis Lachapelle
2014-01-07 11:11:39 -05:00
parent ff9ea3b779
commit fe2826ca76
3 changed files with 24 additions and 4 deletions

View File

@@ -69,6 +69,7 @@
"You cannot create a list in a shared address book."
= "You cannot create a list in a shared address book.";
"Warning" = "Warning";
"Can't contact server" = "An error occurred while contacting the server. Please try again later.";
"You are not allowed to access this module or this system. Please contact your system administrator."
= "You are not allowed to access this module or this system. Please contact your system administrator.";

View File

@@ -280,6 +280,9 @@
"error_missingsubject" = "The message has no subject. Are you sure you want to send it?";
"error_missingrecipients" = "Please specify at least one recipient.";
"Send Anyway" = "Send Anyway";
"Error while saving the draft:" = "Error while saving the draft:";
"Error while uploading the file \"%{0}\":" = "Error while uploading the file \"%{0}\":";
"There is an active file upload. Closing the window will interrupt it." = "There is an active file upload. Closing the window will interrupt it.";
/* Message sending */
"cannot send message: (smtp) all recipients discarded" = "Cannot send message: all recipients are invalid.";

View File

@@ -244,7 +244,7 @@ function clickedEditorSave() {
}
else {
var response = http.responseText.evalJSON(true);
showAlertDialog("Error while saving the draft: " + response.textStatus);
showAlertDialog(_("Error while saving the draft:") + " " + response.textStatus);
}
}
},
@@ -444,8 +444,14 @@ function configureAttachments() {
fail: function (e, data) {
var attachment = data.files[0].attachment;
var filename = data.files[0].name;
var response = data.xhr().response.evalJSON();
showAlertDialog("Error while uploading the file " + filename + ": " + response.textStatus);
var textStatus;
try {
var response = data.xhr().response.evalJSON();
textStatus = response.textStatus;
} catch (e) {}
if (!textStatus)
textStatus = _("Can't contact server");
showAlertDialog(_("Error while uploading the file \"%{0}\":").formatted(filename) + " " + textStatus);
attachment.remove();
},
dragover: function (e, data) {
@@ -685,8 +691,18 @@ function onWindowResize(event) {
}
function onMailEditorClose(event) {
if (window.shouldPreserve)
var e = event || window.event;
if (window.shouldPreserve) {
window.shouldPreserve = false;
if (jQuery('#fileUpload').fileupload('active') > 0) {
var msg = _("There is an active file upload. Closing the window will interrupt it.");
if (e) {
e.returnValue = msg;
}
return msg;
}
}
else {
var url = "" + window.location;
var parts = url.split("/");