mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-12 15:05:29 +00:00
Fix handling of recipient addresses in mail editor
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
data-ng-options="identity for identity in identities"><!-- from --></select></label>
|
||||
<label><var:string label:value="To"/>
|
||||
<tags-input type="text" name="to"
|
||||
ng-model="message.editable.to"><!-- to --></tags-input></label>
|
||||
ng-model="message.editable.to"
|
||||
label:placeholder="Add a recipient"><!-- to --></tags-input></label>
|
||||
<label><var:string label:value="Subject"/>
|
||||
<input type="text" name="subject" ng-model="message.editable.subject"/></label>
|
||||
<textarea name="content" var:class="editorClass" ng-model="message.editable.text"/>
|
||||
|
||||
@@ -151,8 +151,7 @@
|
||||
// Fetch draft initial data
|
||||
Account.$$resource.fetch(message.id, 'edit').then(function(data) {
|
||||
Account.$log.debug('New message: ' + JSON.stringify(data, undefined, 2));
|
||||
angular.extend(message, data);
|
||||
message.$formatFullAddresses();
|
||||
message.editable = data;
|
||||
deferred.resolve(message);
|
||||
}, function(data) {
|
||||
deferred.reject(data);
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
/**
|
||||
* @function $formatFullAddresses
|
||||
* @memberof Message.prototype
|
||||
* @desc Preformat all sender and recipients addresses with a complete description (name <email>).
|
||||
* @desc Format all sender and recipients addresses with a complete description (name <email>).
|
||||
*/
|
||||
Message.prototype.$formatFullAddresses = function() {
|
||||
var _this = this;
|
||||
@@ -114,10 +114,31 @@
|
||||
return Message.$sce.trustAs('html', this.content);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $editableContent
|
||||
* @memberof Message.prototype
|
||||
* @desc Fetch the editable message body along with other metadat such as the recipients.
|
||||
* @returns the HTML representation of the body
|
||||
*/
|
||||
Message.prototype.$editableContent = function() {
|
||||
var _this = this,
|
||||
deferred = Message.$q.defer();
|
||||
|
||||
Message.$$resource.fetch(this.$absolutePath({asDraft: true}), 'edit').then(function(data) {
|
||||
Message.$log.debug('editable = ' + JSON.stringify(data, undefined, 2));
|
||||
_this.editable = data;
|
||||
deferred.resolve(data.text);
|
||||
}, function(data) {
|
||||
deferred.reject();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $update
|
||||
* @memberof Message.prototype
|
||||
* @desc Fetch the message body along with other metadata such as the list of attachments.
|
||||
* @desc Fetch the viewable message body along with other metadata such as the list of attachments.
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Message.prototype.$update = function() {
|
||||
@@ -128,17 +149,44 @@
|
||||
return this.$unwrap(futureMessageData);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $save
|
||||
* @memberof Message.prototype
|
||||
* @desc Save the message to the server.
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Message.prototype.$save = function() {
|
||||
var data = this.$omit();
|
||||
Message.$log.debug(JSON.stringify(data, undefined, 2));
|
||||
var data = this.editable;
|
||||
|
||||
// Flatten recipient addresses
|
||||
_.each(['to', 'cc', 'bcc', 'reply-to'], function(type) {
|
||||
if (data[type]) {
|
||||
data[type] = _.pluck(data[type], 'text');
|
||||
}
|
||||
});
|
||||
Message.$log.debug('save = ' + JSON.stringify(data, undefined, 2));
|
||||
|
||||
return Message.$$resource.save(this.$absolutePath({asDraft: true}), data);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $send
|
||||
* @memberof Message.prototype
|
||||
* @desc Send the message.
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Message.prototype.$send = function() {
|
||||
var data = this.$omit(),
|
||||
var data = angular.copy(this.editable),
|
||||
deferred = Message.$q.defer();
|
||||
|
||||
// Flatten recipient addresses
|
||||
_.each(['to', 'cc', 'bcc', 'reply-to'], function(type) {
|
||||
if (data[type]) {
|
||||
data[type] = _.pluck(data[type], 'text');
|
||||
}
|
||||
});
|
||||
Message.$log.debug('send = ' + JSON.stringify(data, undefined, 2));
|
||||
|
||||
Message.$$resource.post(this.$absolutePath({asDraft: true}), 'send', data).then(function(data) {
|
||||
if (data.status == 'success') {
|
||||
deferred.resolve(data);
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
};
|
||||
}])
|
||||
|
||||
.controller('MessageEditorCtrl', ['$scope', '$rootScope', '$stateParams', 'stateAccounts', 'stateMessage', '$timeout', '$modal', 'sgFocus', 'sgDialog', 'sgAccount', 'sgMailbox', function($scope, $rootScope, $stateParams, stateAccounts, stateMessage, $timeout, $modal, focus, Dialog, Account, Mailbox) {
|
||||
.controller('MessageEditorCtrl', ['$scope', '$rootScope', '$stateParams', '$state', 'stateAccounts', 'stateMessage', '$timeout', '$modal', 'sgFocus', 'sgDialog', 'sgAccount', 'sgMailbox', function($scope, $rootScope, $stateParams, $state, stateAccounts, stateMessage, $timeout, $modal, focus, Dialog, Account, Mailbox) {
|
||||
if (angular.isDefined(stateMessage)) {
|
||||
$scope.message = stateMessage;
|
||||
}
|
||||
@@ -237,7 +237,7 @@
|
||||
$scope.send = function(message) {
|
||||
message.$send().then(function(data) {
|
||||
$rootScope.message = null;
|
||||
$state.go('mail.account.mailbox', { accountId: stateAccount.id, mailboxId: encodeUriFilter(stateMailbox.path) });
|
||||
$state.go('mail');
|
||||
}, function(data) {
|
||||
console.debug('failure ' + JSON.stringify(data, undefined, 2));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user