Webmail: Add forward button to messages

This commit is contained in:
Francis Lachapelle
2015-01-06 12:09:14 -05:00
parent d048d66cb5
commit 8a928b8179
3 changed files with 58 additions and 9 deletions
@@ -23,7 +23,11 @@
<div class="buttonsToolbar">
<span>
<a class="button tiny radius"
data-ui-sref="mail.account.mailbox.message.reply({accountId: account.id, mailboxId: (mailbox.path | encodeUri), messageId: message.uid})"><i class="icon-reply"><!-- reply --></i></a>
data-ui-sref="mail.account.mailbox.message.action({accountId: account.id, mailboxId: (mailbox.path | encodeUri), messageId: message.uid, actionName: 'reply'})"><i class="icon-reply"><!-- reply --></i></a>
<a class="button tiny radius"
data-ui-sref="mail.account.mailbox.message.action({accountId: account.id, mailboxId: (mailbox.path | encodeUri), messageId: message.uid, actionName: 'replyall'})"><i class="icon-reply"><!-- reply all --></i></a>
<a class="button tiny radius"
data-ui-sref="mail.account.mailbox.message.action({accountId: account.id, mailboxId: (mailbox.path | encodeUri), messageId: message.uid, actionName: 'forward'})"><i class="icon-reply"><!-- forward --></i></a>
<a class="button tiny radius"
data-ui-sref="mail.account.mailbox.message.edit({accountId: account.id, mailboxId: (mailbox.path | encodeUri), messageId: message.uid})"
data-ng-show="message.isDraft"><i class="icon-pencil"><!-- edit --></i></a>
@@ -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) {
+13 -3
View File
@@ -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;
}