From 8a928b81793c216e92aef2739d0c1cfe8c206bbd Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 6 Jan 2015 12:09:14 -0500 Subject: [PATCH] Webmail: Add forward button to messages --- UI/Templates/MailerUI/UIxMailViewTemplate.wox | 6 ++- .../js/Mailer/message-model.js | 45 ++++++++++++++++--- UI/WebServerResources/js/MailerUI.js | 16 +++++-- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/UI/Templates/MailerUI/UIxMailViewTemplate.wox b/UI/Templates/MailerUI/UIxMailViewTemplate.wox index 43292256c..9ebf36eb4 100644 --- a/UI/Templates/MailerUI/UIxMailViewTemplate.wox +++ b/UI/Templates/MailerUI/UIxMailViewTemplate.wox @@ -23,7 +23,11 @@
+ data-ui-sref="mail.account.mailbox.message.action({accountId: account.id, mailboxId: (mailbox.path | encodeUri), messageId: message.uid, actionName: 'reply'})"> + + diff --git a/UI/WebServerResources/js/Mailer/message-model.js b/UI/WebServerResources/js/Mailer/message-model.js index 5a81a2c1c..6192cc436 100644 --- a/UI/WebServerResources/js/Mailer/message-model.js +++ b/UI/WebServerResources/js/Mailer/message-model.js @@ -174,24 +174,59 @@ /** * @function $reply * @memberof Message.prototype - * @desc Prepare a new Message object as the reply of the current message and associated to the draft mailbox. - * @see {@link Account.$newMessage} + * @desc Prepare a new Message object as a reply to the sender. * @returns a promise of the HTTP operations */ Message.prototype.$reply = function() { + return this.$newDraft('reply'); + }; + + /** + * @function $replyAll + * @memberof Message.prototype + * @desc Prepare a new Message object as a reply to the sender and all recipients. + * @returns a promise of the HTTP operations + */ + Message.prototype.$replyAll = function() { + return this.$newDraft('replyall'); + }; + + /** + * @function $forward + * @memberof Message.prototype + * @desc Prepare a new Message object as a forward. + * @returns a promise of the HTTP operations + */ + Message.prototype.$forward = function() { + return this.$newDraft('forward'); + }; + + /** + * @function $newDraft + * @memberof Message.prototype + * @desc Prepare a new Message object as a reply or a forward of the current message and associated + * to the draft mailbox. + * @see {@link Account.$newMessage} + * @see {@link Message.$editableContent} + * @see {@link Message.$reply} + * @see {@link Message.$replyAll} + * @see {@link Message.$forwad} + * @returns a promise of the HTTP operations + */ + Message.prototype.$newDraft = function(action) { var _this = this, deferred = Message.$q.defer(), mailbox, message; // Query server for draft folder and draft UID - Message.$$resource.fetch(this.id, 'reply').then(function(data) { - Message.$log.debug('New reply: ' + JSON.stringify(data, undefined, 2)); + Message.$$resource.fetch(this.id, action).then(function(data) { + Message.$log.debug('New ' + action + ': ' + JSON.stringify(data, undefined, 2)); mailbox = _this.$mailbox.$account.$getMailboxByPath(data.mailboxPath); message = new Message(data.accountId, mailbox, data); // Fetch draft initial data Message.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) { - Message.$log.debug('New reply: ' + JSON.stringify(data, undefined, 2)); + Message.$log.debug('New ' + action + ': ' + JSON.stringify(data, undefined, 2)); message.editable = data; deferred.resolve(message); }, function(data) { diff --git a/UI/WebServerResources/js/MailerUI.js b/UI/WebServerResources/js/MailerUI.js index 7952774ed..64bcce5aa 100644 --- a/UI/WebServerResources/js/MailerUI.js +++ b/UI/WebServerResources/js/MailerUI.js @@ -124,8 +124,8 @@ }] } }) - .state('mail.account.mailbox.message.reply', { - url: '/reply', + .state('mail.account.mailbox.message.action', { + url: '/{actionName:(?:reply|replyall|forward)}', views: { 'mailbox@mail': { templateUrl: 'editorTemplate', // UI/Templates/MailerUI/UIxMailEditor.wox @@ -253,11 +253,21 @@ }]) .controller('MessageEditorCtrl', ['$scope', '$rootScope', '$stateParams', '$state', '$q', 'FileUploader', 'stateAccounts', 'stateMessage', '$timeout', '$modal', 'sgFocus', 'sgDialog', 'sgAccount', 'sgMailbox', 'sgAddressBook', function($scope, $rootScope, $stateParams, $state, $q, FileUploader, stateAccounts, stateMessage, $timeout, $modal, focus, Dialog, Account, Mailbox, AddressBook) { - if ($state.current.url == '/reply') { + if ($stateParams.actionName == 'reply') { stateMessage.$reply().then(function(msgObject) { $scope.message = msgObject; }); } + else if ($stateParams.actionName == 'replyall') { + stateMessage.$replyAll().then(function(msgObject) { + $scope.message = msgObject; + }); + } + else if ($stateParams.actionName == 'forward') { + stateMessage.$forward().then(function(msgObject) { + $scope.message = msgObject; + }); + } else if (angular.isDefined(stateMessage)) { $scope.message = stateMessage; }