From fe2826ca76cb3963c2fdaaedeb751049824813cc Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 7 Jan 2014 11:11:39 -0500 Subject: [PATCH] Draft: Improve error handling when attaching files --- UI/Common/English.lproj/Localizable.strings | 1 + UI/MailerUI/English.lproj/Localizable.strings | 3 +++ UI/WebServerResources/UIxMailEditor.js | 24 +++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/UI/Common/English.lproj/Localizable.strings b/UI/Common/English.lproj/Localizable.strings index bfbc4b968..4b60dc35b 100644 --- a/UI/Common/English.lproj/Localizable.strings +++ b/UI/Common/English.lproj/Localizable.strings @@ -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."; diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 761f0b6d8..9f13115ea 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -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."; diff --git a/UI/WebServerResources/UIxMailEditor.js b/UI/WebServerResources/UIxMailEditor.js index cc493d53e..debe65db1 100644 --- a/UI/WebServerResources/UIxMailEditor.js +++ b/UI/WebServerResources/UIxMailEditor.js @@ -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("/");