(feat) compose mail with clicked email address

This commit is contained in:
Ludovic Marcotte
2015-08-09 10:36:54 -04:00
parent ad9b969d6d
commit dd7b929f17
5 changed files with 32 additions and 9 deletions
@@ -21,7 +21,9 @@
<var:string label:value="From"/>
</label>
<div class="pseudo-input-field">
<a ng-href="mailto:{{viewer.message.from[0].email}}" ng-bind="viewer.message.from[0].full"><!-- from --></a>
<a href="#"
ng-bind="viewer.message.from[0].full"
ng-click="viewer.newMessage($event, viewer.message.from[0])"><!-- from --></a>
</div>
</div>
@@ -30,7 +32,9 @@
<var:string label:value="To"/>
</label>
<div class="pseudo-input-field">
<a ng-href="mailto:{{viewer.message.to[0].email}}" ng-bind="viewer.message.to[0].full"><!-- to --></a>
<a href="#"
ng-bind="viewer.message.to[0].full"
ng-click="viewer.newMessage($event, viewer.message.to[0])"><!-- to --></a>
</div>
</div>
@@ -210,13 +210,13 @@
// Query account for draft folder and draft UID
return Account.$$resource.fetch(this.id.toString(), 'compose').then(function(data) {
Account.$log.debug('New message: ' + JSON.stringify(data, undefined, 2));
Account.$log.debug('New message (compose): ' + JSON.stringify(data, undefined, 2));
var message = new Account.$Message(data.accountId, _this.$getMailboxByPath(data.mailboxPath), data);
return message;
}).then(function(message) {
// Fetch draft initial data
return Account.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) {
Account.$log.debug('New message: ' + JSON.stringify(data, undefined, 2));
Account.$log.debug('New message (edit): ' + JSON.stringify(data, undefined, 2));
angular.extend(message.editable, data);
return message;
});
@@ -97,6 +97,8 @@
}
function newMessage($event) {
var message = vm.account.$newMessage();
$mdDialog.show({
parent: angular.element(document.body),
targetEvent: $event,
@@ -107,7 +109,8 @@
controllerAs: 'editor',
locals: {
stateAccounts: vm.accounts,
stateMessage: vm.account.$newMessage()
stateMessage: message,
stateRecipients: []
}
});
}
@@ -21,6 +21,7 @@
vm.replyAll = replyAll;
vm.forward = forward;
vm.edit = edit;
vm.newMessage = newMessage;
vm.viewRawSource = viewRawSource;
// Watch the message model "flags" attribute to remove on-the-fly a tag from the IMAP message
@@ -46,7 +47,11 @@
});
}
function showMailEditor($event, message) {
function showMailEditor($event, message, recipients) {
if (!angular.isDefined(recipients))
recipients = [];
$mdDialog.show({
parent: angular.element(document.body),
targetEvent: $event,
@@ -57,7 +62,8 @@
controllerAs: 'editor',
locals: {
stateAccounts: vm.accounts,
stateMessage: message
stateMessage: message,
stateRecipients: recipients
}
});
}
@@ -83,6 +89,12 @@
});
}
function newMessage($event, recipient) {
var message = vm.account.$newMessage();
showMailEditor($event, message, [recipient]);
}
function viewRawSource($event) {
Message.$$resource.post(vm.message.id, "viewsource").then(function(data) {
$mdDialog.show({
@@ -6,8 +6,8 @@
/**
* @ngInject
*/
MessageEditorController.$inject = ['$stateParams', '$state', '$q', '$mdDialog', 'FileUploader', 'stateAccounts', 'stateMessage', '$timeout', 'encodeUriFilter', 'sgFocus', 'Dialog', 'Account', 'Mailbox', 'AddressBook', 'Preferences'];
function MessageEditorController($stateParams, $state, $q, $mdDialog, FileUploader, stateAccounts, stateMessage, $timeout, encodeUriFilter, focus, Dialog, Account, Mailbox, AddressBook, Preferences) {
MessageEditorController.$inject = ['$stateParams', '$state', '$q', '$mdDialog', 'FileUploader', 'stateAccounts', 'stateMessage', 'stateRecipients', '$timeout', 'encodeUriFilter', 'sgFocus', 'Dialog', 'Account', 'Mailbox', 'AddressBook', 'Preferences'];
function MessageEditorController($stateParams, $state, $q, $mdDialog, FileUploader, stateAccounts, stateMessage, stateRecipients, $timeout, encodeUriFilter, focus, Dialog, Account, Mailbox, AddressBook, Preferences) {
var vm = this;
vm.autocomplete = {to: {}, cc: {}, bcc: {}};
@@ -66,6 +66,10 @@
vm.message = stateMessage;
}
if (angular.isDefined(stateRecipients)) {
vm.message.editable.to = _.union(vm.message.editable.to, _.pluck(stateRecipients, 'full'));
}
function cancel() {
// TODO: delete draft?
if (vm.autosave)