mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-03 14:12:21 +00:00
(feat) can now batch delete messages
This commit is contained in:
committed by
Francis Lachapelle
parent
0edc2c1217
commit
6cd02043af
@@ -143,6 +143,22 @@
|
||||
return Mailbox.$absolutePath(this.$account.id, this.path);
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $selectedCount
|
||||
* @memberof Mailbox.prototype
|
||||
* @desc Return the number of messages selected by the user.
|
||||
* @returns the number of selected messages
|
||||
*/
|
||||
Mailbox.prototype.$selectedCount = function() {
|
||||
var count;
|
||||
|
||||
count = 0;
|
||||
if (this.$messages) {
|
||||
count = (_.filter(this.$messages, function(message) { return message.selected })).length;
|
||||
}
|
||||
return count;
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $filter
|
||||
* @memberof Mailbox.prototype
|
||||
@@ -348,6 +364,7 @@
|
||||
* @return a promise of the HTTP operation
|
||||
*/
|
||||
Mailbox.prototype.$deleteMessages = function(uids) {
|
||||
var _this = this;
|
||||
return Mailbox.$$resource.post(this.id, 'batchDelete', {uids: uids});
|
||||
};
|
||||
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
$scope.account = stateAccount;
|
||||
$rootScope.mailbox = stateMailbox;
|
||||
$rootScope.currentFolder = stateMailbox;
|
||||
|
||||
$scope.selectMessage = function(message) {
|
||||
$state.go('mail.account.mailbox.message', {accountId: stateAccount.id, mailboxId: encodeUriFilter(stateMailbox.path), messageId: message.uid});
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
angular
|
||||
|
||||
@@ -59,6 +59,24 @@
|
||||
});
|
||||
};
|
||||
|
||||
$scope.unselectMessages = function() {
|
||||
_.each($rootScope.mailbox.$messages, function(message) { message.selected = false; });
|
||||
};
|
||||
|
||||
$scope.confirmDeleteSelectedMessages = function() {
|
||||
Dialog.confirm(l('Warning'),
|
||||
l('Are you sure you want to delete the selected messages?'))
|
||||
.then(function() {
|
||||
// User confirmed the deletion
|
||||
var selectedMessages = _.filter($rootScope.mailbox.$messages, function(message) { return message.selected });
|
||||
var selectedUIDs = _.pluck(selectedMessages, 'uid');
|
||||
$rootScope.mailbox.$deleteMessages(selectedUIDs).then(function() {
|
||||
$rootScope.mailbox.$messages = _.difference($rootScope.mailbox.$messages, selectedMessages);
|
||||
});
|
||||
}, function(data, status) {
|
||||
// Delete failed
|
||||
});
|
||||
};
|
||||
if ($state.current.name == 'mail' && $scope.accounts.length > 0 && $scope.accounts[0].$mailboxes.length > 0) {
|
||||
// Redirect to first mailbox of first account if no mailbox is selected
|
||||
var account = $scope.accounts[0];
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
// The promise will be unwrapped first
|
||||
this.$unwrap(futureMessageData);
|
||||
}
|
||||
this.selected = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user