mirror of https://github.com/moparisthebest/mail
implemented get Email post message
This commit is contained in:
parent
da3dc17cb4
commit
3e7af24697
|
@ -21,12 +21,17 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
compose: function(userId, folder, messageId) {
|
compose: function(userId, folder, messageId) {
|
||||||
var composeView = new app.view.ComposeView({
|
var self = this,
|
||||||
|
composeView;
|
||||||
|
|
||||||
|
composeView = new app.view.ComposeView({
|
||||||
account: userId,
|
account: userId,
|
||||||
folder: folder,
|
folder: folder,
|
||||||
messageId: (messageId) ? decodeURIComponent(messageId) : null
|
messageId: (messageId) ? decodeURIComponent(messageId) : null,
|
||||||
|
callback: function(view) {
|
||||||
|
self.changePage(view);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.changePage(composeView);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
folders: function(userId) {
|
folders: function(userId) {
|
||||||
|
|
|
@ -4,13 +4,31 @@
|
||||||
app.view.ComposeView = Backbone.View.extend({
|
app.view.ComposeView = Backbone.View.extend({
|
||||||
|
|
||||||
initialize: function(args) {
|
initialize: function(args) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
this.template = _.template(app.util.tpl.get('compose'));
|
this.template = _.template(app.util.tpl.get('compose'));
|
||||||
this.account = args.account;
|
this.account = args.account;
|
||||||
this.folder = args.folder;
|
this.folder = args.folder;
|
||||||
|
|
||||||
if (args.folder && args.messageId) {
|
if (args.folder && args.messageId) {
|
||||||
// fetch reply-to email model
|
// fetch reply-to email model
|
||||||
this.replyTo = args.dao.getItem(args.folder, args.messageId);
|
// post message to main window
|
||||||
|
app.util.postMessage('getEmail', {
|
||||||
|
folder: args.folder,
|
||||||
|
messageId: args.messageId
|
||||||
|
}, function(resArgs) {
|
||||||
|
var err = resArgs.err;
|
||||||
|
if (err) {
|
||||||
|
window.alert(JSON.stringify(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// set mail to reply to
|
||||||
|
self.replyTo = resArgs.email;
|
||||||
|
args.callback(self);
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
args.callback(self);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,14 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} else if (cmd === 'getEmail') {
|
||||||
|
// list emails from folder
|
||||||
|
var mail = emailDao.getItem(args.folder, args.messageId);
|
||||||
|
callback({
|
||||||
|
err: null,
|
||||||
|
email: mail.toJSON()
|
||||||
|
});
|
||||||
|
|
||||||
} else if (cmd === 'sendEmail') {
|
} else if (cmd === 'sendEmail') {
|
||||||
// list emails from folder
|
// list emails from folder
|
||||||
sendEmail(args.email, function(err) {
|
sendEmail(args.email, function(err) {
|
||||||
|
|
Loading…
Reference in New Issue