(js) Fix mailbox deletion from the hot key
parent
9b2527ce6d
commit
67b9ef0b8b
|
@ -52,8 +52,8 @@
|
||||||
key: 'backspace',
|
key: 'backspace',
|
||||||
description: l('Delete selected message or folder'),
|
description: l('Delete selected message or folder'),
|
||||||
callback: function() {
|
callback: function() {
|
||||||
if (Mailbox.selectedFolder && !Mailbox.selectedFolder.hasSelectedMessage())
|
if (Mailbox.selectedFolderController && Mailbox.selectedFolder && !Mailbox.selectedFolder.hasSelectedMessage())
|
||||||
confirmDelete(Mailbox.selectedFolder);
|
Mailbox.selectedFolderController.confirmDelete(Mailbox.selectedFolder);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
// Called from a sgMailboxListItem controller
|
// Called from a sgMailboxListItem controller
|
||||||
this.selectFolder = function (mailboxController) {
|
this.selectFolder = function (mailboxController) {
|
||||||
|
Mailbox.selectedFolderController = mailboxController;
|
||||||
if (Mailbox.selectedFolder !== null) {
|
if (Mailbox.selectedFolder !== null) {
|
||||||
var selectedMailboxCtrl = _.find(mailboxes, function(ctrl) {
|
var selectedMailboxCtrl = _.find(mailboxes, function(ctrl) {
|
||||||
return ctrl.mailbox.id == Mailbox.selectedFolder.id;
|
return ctrl.mailbox.id == Mailbox.selectedFolder.id;
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
// Check if router's state has selected a mailbox
|
// Check if router's state has selected a mailbox
|
||||||
if (Mailbox.selectedFolder !== null && Mailbox.selectedFolder.id == this.mailbox.id) {
|
if (Mailbox.selectedFolder !== null && Mailbox.selectedFolder.id == this.mailbox.id) {
|
||||||
this.selectFolder();
|
this.accountController.selectFolder(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -145,6 +145,32 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.confirmDelete = function() {
|
||||||
|
Dialog.confirm(l('Warning'),
|
||||||
|
l('Do you really want to move this folder into the trash ?'),
|
||||||
|
{ ok: l('Delete') })
|
||||||
|
.then(function() {
|
||||||
|
$ctrl.mailbox.$delete()
|
||||||
|
.then(function() {
|
||||||
|
$state.go('mail.account.inbox');
|
||||||
|
}, 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() {
|
||||||
|
$ctrl.mailbox.$delete({ withoutTrash: true })
|
||||||
|
.then(function() {
|
||||||
|
$state.go('mail.account.inbox');
|
||||||
|
}, function(response) {
|
||||||
|
Dialog.alert(l('An error occured while deleting the mailbox "%{0}".', $ctrl.mailbox.name),
|
||||||
|
l(response.error));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.showMenu = function($event) {
|
this.showMenu = function($event) {
|
||||||
var panelPosition = $mdPanel.newPanelPosition()
|
var panelPosition = $mdPanel.newPanelPosition()
|
||||||
.relativeTo(this.moreOptionsButton)
|
.relativeTo(this.moreOptionsButton)
|
||||||
|
@ -162,7 +188,8 @@
|
||||||
attachTo: angular.element(document.body),
|
attachTo: angular.element(document.body),
|
||||||
locals: {
|
locals: {
|
||||||
itemCtrl: this,
|
itemCtrl: this,
|
||||||
folder: this.mailbox
|
folder: this.mailbox,
|
||||||
|
confirmDelete: this.confirmDelete
|
||||||
},
|
},
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controller: MenuController,
|
controller: MenuController,
|
||||||
|
@ -231,31 +258,6 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.confirmDelete = function() {
|
|
||||||
Dialog.confirm(l('Warning'),
|
|
||||||
l('Do you really want to move this folder into the trash ?'),
|
|
||||||
{ ok: l('Delete') })
|
|
||||||
.then(function() {
|
|
||||||
$menuCtrl.folder.$delete()
|
|
||||||
.then(function() {
|
|
||||||
$state.go('mail.account.inbox');
|
|
||||||
}, 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() {
|
|
||||||
$menuCtrl.folder.$delete({ withoutTrash: true })
|
|
||||||
.then(function() {
|
|
||||||
$state.go('mail.account.inbox');
|
|
||||||
}, function(response) {
|
|
||||||
Dialog.alert(l('An error occured while deleting the mailbox "%{0}".', $menuCtrl.folder.name),
|
|
||||||
l(response.error));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.showAdvancedSearch = function() {
|
this.showAdvancedSearch = function() {
|
||||||
Mailbox.$virtualPath = this.folder.path;
|
Mailbox.$virtualPath = this.folder.path;
|
||||||
// Close sidenav on small devices
|
// Close sidenav on small devices
|
||||||
|
|
Loading…
Reference in New Issue