(js) Make use of 'controllerAs' in Mailer module

This commit is contained in:
Francis Lachapelle
2015-07-13 15:22:58 -04:00
parent 7c6716784e
commit aee229e700
12 changed files with 543 additions and 503 deletions
@@ -197,27 +197,21 @@
* @returns a promise of the HTTP operations
*/
Account.prototype.$newMessage = function() {
var _this = this,
deferred = Account.$q.defer(),
message;
var _this = this;
// Query account for draft folder and draft UID
Account.$$resource.fetch(this.id.toString(), 'compose').then(function(data) {
return Account.$$resource.fetch(this.id.toString(), 'compose').then(function(data) {
Account.$log.debug('New message: ' + JSON.stringify(data, undefined, 2));
message = new Account.$Message(data.accountId, _this.$getMailboxByPath(data.mailboxPath), data);
var message = new Account.$Message(data.accountId, _this.$getMailboxByPath(data.mailboxPath), data);
return message;
}).then(function(message) {
// Fetch draft initial data
Account.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) {
return Account.$$resource.fetch(message.$absolutePath({asDraft: true}), 'edit').then(function(data) {
Account.$log.debug('New message: ' + JSON.stringify(data, undefined, 2));
angular.extend(message.editable, data);
deferred.resolve(message);
}, function(data) {
deferred.reject(data);
return message;
});
}, function(data) {
deferred.reject(data);
});
return deferred.promise;
};
/**