From fdf875fb734a72807170f5b66953e640524a498e Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 11 Dec 2014 09:15:33 -0500 Subject: [PATCH] Change key for envelope addresses metadata --- UI/MailerUI/UIxEnvelopeAddressFormatter.m | 2 +- .../js/Mailer/message-model.js | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/UI/MailerUI/UIxEnvelopeAddressFormatter.m b/UI/MailerUI/UIxEnvelopeAddressFormatter.m index 71be98aa3..8ac7d4d3a 100644 --- a/UI/MailerUI/UIxEnvelopeAddressFormatter.m +++ b/UI/MailerUI/UIxEnvelopeAddressFormatter.m @@ -89,7 +89,7 @@ static Class StrClass = Nil; meta = [NSMutableDictionary dictionary]; s = [_address baseEMail]; - if (s) [meta setObject: s forKey: @"address"]; + if (s) [meta setObject: s forKey: @"email"]; s = [_address personalName]; if (s) [meta setObject: s forKey: @"name"]; diff --git a/UI/WebServerResources/js/Mailer/message-model.js b/UI/WebServerResources/js/Mailer/message-model.js index f862a052f..77b7ed690 100644 --- a/UI/WebServerResources/js/Mailer/message-model.js +++ b/UI/WebServerResources/js/Mailer/message-model.js @@ -18,6 +18,7 @@ //console.debug(JSON.stringify(futureMessageData, undefined, 2)); angular.extend(this, futureMessageData); this.id = this.$absolutePath(); + this.$formatFullAddresses(); } else { // The promise will be unwrapped first @@ -52,18 +53,42 @@ * @desc Build the path of the message * @returns a string representing the path relative to the mail module */ - Message.prototype.$absolutePath = function() { + Message.prototype.$absolutePath = function(options) { var path; path = _.map(this.mailboxPath.split('/'), function(component) { return 'folder' + component.asCSSIdentifier(); }); path.splice(0, 0, this.accountId); // insert account ID - path.push(this.uid); // add message UID + if (options && options.asDraft && this.draftId) { + path.push(this.draftId); // add draft ID + } + else { + path.push(this.uid); // add message UID + } return path.join('/'); }; + /** + * @function $formatFullAddresses + * @memberof Message.prototype + * @desc Preformat all sender and recipients addresses with a complete description (name ). + */ + Message.prototype.$formatFullAddresses = function() { + var _this = this; + + // Build long representation of email addresses + _.each(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) { + _.each(_this[type], function(data, i) { + if (data.name && data.name != data.email) + data.full = data.name + ' <' + data.email + '>'; + else + data.full = '<' + data.email + '>'; + }); + }); + }; + /** * @function $shortAddress * @memberof Message.prototype @@ -116,16 +141,8 @@ Message.$timeout(function() { angular.extend(_this, data); _this.id = _this.$absolutePath(); - // Build long representation of email addresses - _.each(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) { - _.each(_this[type], function(data, i) { - if (data.name && data.name != data.address) - data.full = data.name + ' <' + data.address + '>'; - else - data.full = '<' + data.address + '>'; - }); - }); - deferred.resolve(_this.content); + _this.$formatFullAddresses(); + deferred.resolve(_this); }); }, function(data) { angular.extend(_this, data);