diff --git a/NEWS b/NEWS index f527ac3de..542f352a7 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ Enhancements - [web] expose all email addresses in autocompletion of message editor (#3443) - [web] Gravatar service can now be disabled (#3600) + - [web] collapsable mail accounts (#3493) Bug fixes - [web] fixed creation of chip on blur (sgTransformOnBlur directive) diff --git a/UI/Templates/MailerUI/UIxMailMainFrame.wox b/UI/Templates/MailerUI/UIxMailMainFrame.wox index 2691403e4..21605bd6c 100644 --- a/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -36,39 +36,39 @@ -
- -
- + + +
{{account.name}}
+
+ people -
{{account.name}}
-
- add_circle_outline -
-
+ +
{{account.$quota.description}}
- + - diff --git a/UI/WebServerResources/js/Mailer/Account.service.js b/UI/WebServerResources/js/Mailer/Account.service.js index 4dcabb179..4b5c79eb0 100644 --- a/UI/WebServerResources/js/Mailer/Account.service.js +++ b/UI/WebServerResources/js/Mailer/Account.service.js @@ -91,6 +91,32 @@ return collection; }; + /** + * @function getLength + * @memberof Account.prototype + * @desc Used by md-virtual-repeat / md-on-demand + * @returns the number of mailboxes in the account + */ + Account.prototype.getLength = function() { + return this.$flattenMailboxes().length; + }; + + /** + * @function getItemAtIndex + * @memberof Account.prototype + * @desc Used by md-virtual-repeat / md-on-demand + * @returns the mailbox at the specified index + */ + Account.prototype.getItemAtIndex = function(index) { + var expandedMailboxes; + + expandedMailboxes = this.$flattenMailboxes(); + if (index >= 0 && index < expandedMailboxes.length) + return expandedMailboxes[index]; + + return null; + }; + /** * @function $getMailboxes * @memberof Account.prototype @@ -125,6 +151,7 @@ expandedFolders = angular.fromJson(Account.$Preferences.settings.Mail.ExpandedFolders); else expandedFolders = Account.$Preferences.settings.Mail.ExpandedFolders; + _this.$expanded = (expandedFolders.indexOf('/' + _this.id) >= 0) || Account.$accounts.length == 1; if (expandedFolders.length > 0) { _visit(_this.$mailboxes); } @@ -170,6 +197,9 @@ if (options && options.saveState) { // Save expansion state of mailboxes to the server _.forEach(Account.$accounts, function(account) { + if (account.$expanded) { + expandedMailboxes.push('/' + account.id); + } _.reduce(account.$$flattenMailboxes, function(expandedFolders, mailbox) { if (mailbox.$expanded) { expandedFolders.push('/' + mailbox.id); diff --git a/UI/WebServerResources/js/Mailer/MailboxesController.js b/UI/WebServerResources/js/Mailer/MailboxesController.js index 909b77a3f..6347c052f 100644 --- a/UI/WebServerResources/js/Mailer/MailboxesController.js +++ b/UI/WebServerResources/js/Mailer/MailboxesController.js @@ -6,14 +6,15 @@ /** * @ngInject */ - MailboxesController.$inject = ['$state', '$timeout', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'sgConstant', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'Account', 'Mailbox', 'VirtualMailbox', 'User', 'Preferences', 'stateAccounts']; - function MailboxesController($state, $timeout, $mdDialog, $mdToast, $mdMedia, $mdSidenav, sgConstant, focus, encodeUriFilter, Dialog, Settings, Account, Mailbox, VirtualMailbox, User, Preferences, stateAccounts) { + MailboxesController.$inject = ['$state', '$timeout', '$window', '$mdDialog', '$mdToast', '$mdMedia', '$mdSidenav', 'sgConstant', 'sgFocus', 'encodeUriFilter', 'Dialog', 'sgSettings', 'Account', 'Mailbox', 'VirtualMailbox', 'User', 'Preferences', 'stateAccounts']; + function MailboxesController($state, $timeout, $window, $mdDialog, $mdToast, $mdMedia, $mdSidenav, sgConstant, focus, encodeUriFilter, Dialog, Settings, Account, Mailbox, VirtualMailbox, User, Preferences, stateAccounts) { var vm = this, account, mailbox; vm.service = Mailbox; vm.accounts = stateAccounts; + vm.toggleAccountState = toggleAccountState; vm.newFolder = newFolder; vm.delegate = delegate; vm.editFolder = editFolder; @@ -130,6 +131,17 @@ } } + function toggleAccountState(account) { + account.$expanded = !account.$expanded; + account.$flattenMailboxes({ reload: true, saveState: true }); + // Fire a window resize to recompute the virtual-repeater. + // This is a fix until the following issue is officially resolved: + // https://github.com/angular/material/issues/7309 + $timeout(function() { + angular.element($window).triggerHandler('resize'); + }, 150); + } + function newFolder(parentFolder) { Dialog.prompt(l('New folder'), l('Enter the new name of your folder :'))