diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 7c682b216..e04d278ed 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -3,6 +3,7 @@ /* Icon's label */ "Create" = "Create"; "Empty Trash" = "Empty Trash"; +"Empty Junk Folder" = "Empty Junk Folder"; "Delete" = "Delete"; "Expunge" = "Expunge"; "Forward" = "Forward"; @@ -73,8 +74,13 @@ "An error occured while communicating with the mail server" = "An error occured while communicating with the mail server"; /* Mailbox actions */ + /* Compact Folder success message */ "Folder compacted" = "Folder compacted"; + +/* Empty Junk Folder success message */ +"Junk folder emptied" = "Junk folder emptied"; + /* Empty Trash success message */ "Trash emptied" = "Trash emptied"; @@ -387,6 +393,12 @@ "Send Anyway" = "Send Anyway"; "Error while saving the draft" = "Error while saving the draft"; +/* Error when emptying trash */ +"Unable to empty the trash folder." = "Unable to empty the trash folder."; + +/* Error when emptying junk folder */ +"Unable to empty the junk folder." = "Unable to empty the junk folder."; + /* Error when uploading a file attachment */ "Error while uploading the file \"%{0}\":" = "Error while uploading the file \"%{0}\":"; "There is an active file upload. Closing the window will interrupt it." = "There is an active file upload. Closing the window will interrupt it."; diff --git a/UI/MailerUI/UIxMailFolderActions.h b/UI/MailerUI/UIxMailFolderActions.h index 17a134ad9..b6ba4a797 100644 --- a/UI/MailerUI/UIxMailFolderActions.h +++ b/UI/MailerUI/UIxMailFolderActions.h @@ -1,6 +1,6 @@ /* UIxMailFolderActions.h - this file is part of SOGo * - * Copyright (C) 2007-2016 Inverse inc. + * Copyright (C) 2007-2021 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +33,9 @@ - (WOResponse *) batchDeleteAction; - (WOResponse *) saveMessagesAction; - (WOResponse *) expungeAction; +- (WOResponse *) emptyJunkAction; - (WOResponse *) emptyTrashAction; +- (WOResponse *) emptySpecialFolderAction: (NSString *) folderType; - (WOResponse *) subscribeAction; - (WOResponse *) unsubscribeAction; - (id ) getLabelsAction; diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index bc6daa927..dfae4bc70 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -31,6 +31,7 @@ #import +#import #import #import @@ -876,15 +877,25 @@ return response; } +- (WOResponse *) emptyJunkAction +{ + return [self emptySpecialFolderAction: @"junk"]; +} + - (WOResponse *) emptyTrashAction +{ + return [self emptySpecialFolderAction: @"trash"]; +} + +- (WOResponse *) emptySpecialFolderAction: (NSString *) folderType { NSException *error; - SOGoTrashFolder *co; + SOGoSpecialMailFolder *co; SOGoMailAccount *account; NSEnumerator *subfolders; WOResponse *response; NGImap4Connection *connection; - NSString *currentName; + NSString *currentName, *errorMsg; NSDictionary *data; id quota; @@ -909,7 +920,8 @@ } if (error) { - data = [NSDictionary dictionaryWithObject: [self labelForKey: @"Unable to empty the trash folder." inContext: context] + errorMsg = [NSString stringWithFormat: @"Unable to empty the %@ folder.", folderType]; + data = [NSDictionary dictionaryWithObject: [self labelForKey: errorMsg inContext: context] forKey: @"message"]; response = [self responseWithStatus: 500 andJSONRepresentation: data]; } diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index b9ee88a92..d7700d7c8 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -161,6 +161,23 @@ }; }; + SOGoJunkFolder = { + /* just a new toolbar, other things come from SOGoMailFolder */ + slots = { + toolbar = { + protectedBy = "View"; + value = "SOGoMailFolder.toolbar"; + }; + }; + methods = { + emptyJunk = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "emptyJunk"; + }; + }; + }; + SOGoTrashFolder = { /* just a new toolbar, other things come from SOGoMailFolder */ slots = { diff --git a/UI/WebServerResources/js/Mailer/Mailbox.service.js b/UI/WebServerResources/js/Mailer/Mailbox.service.js index d1ab9494f..a695b9f6e 100644 --- a/UI/WebServerResources/js/Mailer/Mailbox.service.js +++ b/UI/WebServerResources/js/Mailer/Mailbox.service.js @@ -659,15 +659,16 @@ }; /** - * @function $emptyTrash + * @function $empty * @memberof Mailbox.prototype * @desc Empty the Trash folder. * @returns a promise of the HTTP operation */ - Mailbox.prototype.$emptyTrash = function() { - var _this = this; + Mailbox.prototype.$empty = function() { + var _this = this, + action = 'empty' + this.type[0].capitalize() + this.type.substring(1); - return Mailbox.$$resource.post(this.id, 'emptyTrash').then(function(data) { + return Mailbox.$$resource.post(this.id, action).then(function(data) { // Remove all messages from the mailbox _this.$messages = _this.$visibleMessages = []; _this.uidsMap = {}; diff --git a/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js b/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js index 694d51857..828fbb19b 100644 --- a/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js +++ b/UI/WebServerResources/js/Mailer/sgMailboxListItem.directive.js @@ -258,11 +258,19 @@ }); }; + this.emptyJunkFolder = function() { + return this.emptyFolder(l('Junk folder emptied')); + }; + this.emptyTrashFolder = function() { - this.folder.$emptyTrash().then(function() { + return this.emptyFolder(l('Trash emptied')); + }; + + this.emptyFolder = function(successMsg) { + this.folder.$empty().then(function() { $mdToast.show( $mdToast.simple() - .textContent(l('Trash emptied')) + .textContent(successMsg) .position('top right') .hideDelay(3000)); });