summaryrefslogtreecommitdiff
path: root/web-ui/app/js/services/mail_service.js
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/app/js/services/mail_service.js')
-rw-r--r--web-ui/app/js/services/mail_service.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/web-ui/app/js/services/mail_service.js b/web-ui/app/js/services/mail_service.js
index 04194964..a63d517e 100644
--- a/web-ui/app/js/services/mail_service.js
+++ b/web-ui/app/js/services/mail_service.js
@@ -128,11 +128,32 @@ define(
var mails = dataToRecover.mails || [dataToRecover.mail];
this.refreshMails();
- this.trigger(document, events.ui.userAlerts.displayMessage, { message: dataToRecover.successMessage});
+ this.trigger(document, events.ui.userAlerts.displayMessage, { message: i18n(dataToRecover.successMessage)});
this.trigger(document, events.ui.mails.uncheckAll);
}, this);
};
+ this.triggerArchived = function (dataToArchive) {
+ return _.bind(function (response) {
+ this.refreshMails();
+ this.trigger(document, events.ui.userAlerts.displayMessage, { message: i18n(response.successMessage)});
+ this.trigger(document, events.ui.mails.uncheckAll);
+ }, this);
+ };
+
+ this.archiveManyMails = function(event, dataToArchive) {
+ var mailIdents = _.map(dataToArchive.checkedMails, function (mail) {
+ return mail.ident;
+ });
+ monitoredAjax(this, '/mails/archive', {
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json; charset=utf-8',
+ data: JSON.stringify({idents: mailIdents})
+ }).done(this.triggerArchived(dataToArchive))
+ .fail(this.errorMessage(i18n('Could not archive emails')));
+ };
+
this.deleteMail = function (ev, data) {
monitoredAjax(this, '/mail/' + data.mail.ident,
{type: 'DELETE'})
@@ -222,7 +243,7 @@ define(
monitoredAjax(this, url, { dataType: 'json' })
.done(function (data) {
this.attr.numPages = Math.ceil(data.stats.total / this.attr.pageSize);
- this.trigger(document, events.mails.available, _.merge(_.merge({tag: this.attr.currentTag }), this.parseMails(data)));
+ this.trigger(document, events.mails.available, _.merge({tag: this.attr.currentTag, forSearch: this.attr.lastQuery }, this.parseMails(data)));
}.bind(this))
.fail(function () {
this.trigger(document, events.ui.userAlerts.displayMessage, { message: i18n('Could not fetch messages') });
@@ -299,6 +320,7 @@ define(
this.on(document, events.mail.delete, this.deleteMail);
this.on(document, events.mail.deleteMany, this.deleteManyMails);
this.on(document, events.mail.recoverMany, this.recoverManyMails);
+ this.on(document, events.mail.archiveMany, this.archiveManyMails);
this.on(document, events.search.perform, this.newSearch);
this.on(document, events.ui.tag.selected, this.fetchByTag);
this.on(document, events.ui.tag.select, this.fetchByTag);