From be5540272d6e39c49fbcad87945211462dcc780d Mon Sep 17 00:00:00 2001 From: Lisa Junger Date: Mon, 8 Dec 2014 16:23:25 +0100 Subject: issue #172 adopted behavior of send button to monitored ajax calls. --- web-ui/app/js/mail_view/data/mail_sender.js | 3 ++- web-ui/app/js/mail_view/ui/send_button.js | 6 ++++++ web-ui/app/js/page/events.js | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'web-ui') diff --git a/web-ui/app/js/mail_view/data/mail_sender.js b/web-ui/app/js/mail_view/data/mail_sender.js index f769c262..a5a28209 100644 --- a/web-ui/app/js/mail_view/data/mail_sender.js +++ b/web-ui/app/js/mail_view/data/mail_sender.js @@ -48,11 +48,12 @@ define( contextMessage = context + ': '; } - if (xhr.responseJSON.message) { + if (xhr && xhr.responseJSON && xhr.responseJSON.message) { on.trigger(document, events.ui.userAlerts.displayMessage, {message: contextMessage + xhr.responseJSON.message}); } else { on.trigger(document, events.ui.userAlerts.displayMessage, {message: 'Ops! something went wrong, try again later.'}); } + on.trigger(document, events.mail.send_failed, {xhr: xhr, error:error}); }; } diff --git a/web-ui/app/js/mail_view/ui/send_button.js b/web-ui/app/js/mail_view/ui/send_button.js index 5454ab0a..442f1c00 100644 --- a/web-ui/app/js/mail_view/ui/send_button.js +++ b/web-ui/app/js/mail_view/ui/send_button.js @@ -84,6 +84,11 @@ define([ }; + this.forceEnableButton = function () { + this.enableButton(); + this.$node.html(viewHelper.i18n('send-button')); + } + this.after('initialize', function () { this.attr.recipients = {}; this.attr.inputHasMail = {}; @@ -97,6 +102,7 @@ define([ this.on(document, events.dispatchers.rightPane.clear, this.teardown); this.on(document, events.ui.sendbutton.enable, this.enableButton); + this.on(document, events.mail.send_failed, this.forceEnableButton); this.disableButton(); }); diff --git a/web-ui/app/js/page/events.js b/web-ui/app/js/page/events.js index 76a6b7fa..ff9ed10a 100644 --- a/web-ui/app/js/page/events.js +++ b/web-ui/app/js/page/events.js @@ -101,6 +101,7 @@ define(function () { here: 'mail:here', want: 'mail:want', send: 'mail:send', + send_failed: 'mail:send_failed', sent: 'mail:sent', read: 'mail:read', unread: 'mail:unread', -- cgit v1.2.3