mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-03 14:16:23 +00:00
Webmail: add reply button
This commit is contained in:
@@ -48,6 +48,10 @@
|
||||
return Mailbox; // return constructor
|
||||
}];
|
||||
|
||||
/**
|
||||
* @module SOGo.MailerUI
|
||||
* @desc Factory registration of Card in Angular module.
|
||||
*/
|
||||
angular.module('SOGo.MailerUI')
|
||||
/* Factory constants */
|
||||
.constant('sgMailbox_PRELOAD', {
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
this.uid = uid;
|
||||
this.id = this.$absolutePath();
|
||||
if (oldUID > -1) {
|
||||
// For new messages, $mailbox doesn't exist
|
||||
this.$mailbox.uidsMap[uid] = this.$mailbox.uidsMap[oldUID];
|
||||
this.$mailbox.uidsMap[oldUID] = null;
|
||||
}
|
||||
@@ -170,6 +171,39 @@
|
||||
return this.$unwrap(futureMessageData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @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}
|
||||
* @returns a promise of the HTTP operations
|
||||
*/
|
||||
Message.prototype.$reply = function() {
|
||||
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));
|
||||
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.editable = data;
|
||||
deferred.resolve(message);
|
||||
}, function(data) {
|
||||
deferred.reject(data);
|
||||
});
|
||||
}, function(data) {
|
||||
deferred.reject(data);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $save
|
||||
* @memberof Message.prototype
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
stateMessage: ['$stateParams', '$state', 'stateMailbox', 'stateMessages', function($stateParams, $state, stateMailbox, stateMessages) {
|
||||
stateMessage: ['encodeUriFilter', '$stateParams', '$state', 'stateMailbox', 'stateMessages', function(encodeUriFilter, $stateParams, $state, stateMailbox, stateMessages) {
|
||||
var message = _.find(stateMessages, function(messageObject) {
|
||||
return messageObject.uid == $stateParams.messageId;
|
||||
});
|
||||
@@ -105,11 +105,12 @@
|
||||
if (message)
|
||||
return message.$reload();
|
||||
else
|
||||
// Message not found
|
||||
$state.go('mail.account.mailbox', { accountId: stateMailbox.$account.id, mailboxId: encodeUriFilter(stateMailbox.path) });
|
||||
}]
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox.message.editMessage', {
|
||||
.state('mail.account.mailbox.message.edit', {
|
||||
url: '/edit',
|
||||
views: {
|
||||
'mailbox@mail': {
|
||||
@@ -123,6 +124,15 @@
|
||||
}]
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox.message.reply', {
|
||||
url: '/reply',
|
||||
views: {
|
||||
'mailbox@mail': {
|
||||
templateUrl: 'editorTemplate', // UI/Templates/MailerUI/UIxMailEditor.wox
|
||||
controller: 'MessageEditorCtrl'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('mail.newMessage', {
|
||||
url: '/new',
|
||||
views: {
|
||||
@@ -243,7 +253,12 @@
|
||||
}])
|
||||
|
||||
.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 (angular.isDefined(stateMessage)) {
|
||||
if ($state.current.url == '/reply') {
|
||||
stateMessage.$reply().then(function(msgObject) {
|
||||
$scope.message = msgObject;
|
||||
});
|
||||
}
|
||||
else if (angular.isDefined(stateMessage)) {
|
||||
$scope.message = stateMessage;
|
||||
}
|
||||
$scope.identities = _.pluck(_.flatten(_.pluck(stateAccounts, 'identities')), 'full');
|
||||
|
||||
Reference in New Issue
Block a user