Allow a mailbox to be deleted immediately

Fixes #3875
This commit is contained in:
Francis Lachapelle
2016-11-01 11:40:59 -04:00
parent 5c7147cccc
commit 0e0f53cd98
6 changed files with 116 additions and 60 deletions
@@ -620,12 +620,13 @@
* @function $delete
* @memberof Mailbox.prototype
* @desc Delete the mailbox from the server
* @param {object} [options] - additional options (use {withoutTrash: true} to delete immediately)
* @returns a promise of the HTTP operation
*/
Mailbox.prototype.$delete = function() {
Mailbox.prototype.$delete = function(options) {
var _this = this;
return Mailbox.$$resource.remove(this.id)
return Mailbox.$$resource.post(this.id, 'delete', options)
.then(function() {
_this.$account.$getMailboxes({reload: true});
return true;
@@ -674,6 +675,7 @@
* @function $deleteMessages
* @memberof Mailbox.prototype
* @desc Delete multiple messages from mailbox.
* @param {object} [options] - additional options (use {withoutTrash: true} to delete immediately)
* @return a promise of the HTTP operation
*/
Mailbox.prototype.$deleteMessages = function(messages, options) {
@@ -311,7 +311,7 @@
var selectedMessages = vm.selectedFolder.$selectedMessages();
if (messageDialog === null && _.size(selectedMessages) > 0)
messageDialog = Dialog.confirm(l('Warning'),
messageDialog = Dialog.confirm(l('Confirmation'),
l('Are you sure you want to delete the selected messages?'),
{ ok: l('Delete') })
.then(function() {
@@ -344,14 +344,26 @@
}
function confirmDelete(folder) {
Dialog.confirm(l('Confirmation'), l('Do you really want to move this folder into the trash ?'))
Dialog.confirm(l('Warning'),
l('Do you really want to move this folder into the trash ?'),
{ ok: l('Delete') })
.then(function() {
folder.$delete()
.then(function() {
$state.go('mail.account.inbox');
}, function(data, status) {
Dialog.alert(l('An error occured while deleting the mailbox "%{0}".', folder.name),
l(data.error));
}, function(response) {
Dialog.confirm(l('Warning'),
l('The mailbox could not be moved to the trash folder. Would you like to delete it immediately?'),
{ ok: l('Delete') })
.then(function() {
folder.$delete({ withoutTrash: true })
.then(function() {
$state.go('mail.account.inbox');
}, function(response) {
Dialog.alert(l('An error occured while deleting the mailbox "%{0}".', folder.name),
l(response.error));
});
});
});
});
}