mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-20 02:45:25 +00:00
(feat) can now batch delete messages
This commit is contained in:
committed by
Francis Lachapelle
parent
0edc2c1217
commit
6cd02043af
@@ -12,49 +12,49 @@
|
||||
|
||||
$rootScope.currentFolder = stateAddressbook;
|
||||
$rootScope.card = null;
|
||||
|
||||
|
||||
$scope.selectCard = function(card) {
|
||||
$state.go('app.addressbook.card.view', {addressbookId: stateAddressbook.id, cardId: card.id});
|
||||
};
|
||||
|
||||
$scope.newComponent = function(ev) {
|
||||
$mdDialog.show({
|
||||
parent: angular.element(document.body),
|
||||
targetEvent: ev,
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
template: [
|
||||
'<md-dialog aria-label="' + l('Create component') + '">',
|
||||
' <md-content>',
|
||||
' <div layout="column">',
|
||||
' <md-button ng-click="create(\'card\')">',
|
||||
' ' + l('Contact'),
|
||||
' </md-button>',
|
||||
' <md-button ng-click="create(\'list\')">',
|
||||
' ' + l('List'),
|
||||
' </md-button>',
|
||||
' </div>',
|
||||
' </md-content>',
|
||||
'</md-dialog>'
|
||||
].join(''),
|
||||
locals: {
|
||||
state: $state,
|
||||
addressbookId: $scope.currentFolder.id
|
||||
},
|
||||
controller: ComponentDialogController
|
||||
});
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
ComponentDialogController.$inject = ['scope', '$mdDialog', 'state', 'addressbookId'];
|
||||
function ComponentDialogController(scope, $mdDialog, state, addressbookId) {
|
||||
scope.create = function(type) {
|
||||
$mdDialog.hide();
|
||||
state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type });
|
||||
}
|
||||
|
||||
$scope.newComponent = function(ev) {
|
||||
$mdDialog.show({
|
||||
parent: angular.element(document.body),
|
||||
targetEvent: ev,
|
||||
clickOutsideToClose: true,
|
||||
escapeToClose: true,
|
||||
template: [
|
||||
'<md-dialog aria-label="' + l('Create component') + '">',
|
||||
' <md-content>',
|
||||
' <div layout="column">',
|
||||
' <md-button ng-click="create(\'card\')">',
|
||||
' ' + l('Contact'),
|
||||
' </md-button>',
|
||||
' <md-button ng-click="create(\'list\')">',
|
||||
' ' + l('List'),
|
||||
' </md-button>',
|
||||
' </div>',
|
||||
' </md-content>',
|
||||
'</md-dialog>'
|
||||
].join(''),
|
||||
locals: {
|
||||
state: $state,
|
||||
addressbookId: $scope.currentFolder.id
|
||||
},
|
||||
controller: ComponentDialogController
|
||||
});
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
ComponentDialogController.$inject = ['scope', '$mdDialog', 'state', 'addressbookId'];
|
||||
function ComponentDialogController(scope, $mdDialog, state, addressbookId) {
|
||||
scope.create = function(type) {
|
||||
$mdDialog.hide();
|
||||
state.go('app.addressbook.new', { addressbookId: addressbookId, contactType: type });
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
$scope.notSelectedComponent = function(currentCard, type) {
|
||||
return (currentCard.tag == type && !currentCard.selected);
|
||||
|
||||
@@ -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