mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-14 21:04:53 +00:00
@@ -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);
|
||||
|
||||
@@ -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 :'))
|
||||
|
||||
Reference in New Issue
Block a user