(js) Improve URL routing in Mail module
This commit is contained in:
parent
eda112c4bd
commit
be6bd47c15
|
@ -52,13 +52,6 @@
|
|||
params: []
|
||||
};
|
||||
|
||||
if ($state.current.name == 'mail' && vm.accounts.length > 0 && vm.accounts[0].$mailboxes.length > 0) {
|
||||
// Redirect to first mailbox of first account if no mailbox is selected
|
||||
account = vm.accounts[0];
|
||||
mailbox = account.$mailboxes[0];
|
||||
$state.go('mail.account.mailbox', { accountId: account.id, mailboxId: encodeUriFilter(mailbox.path) });
|
||||
}
|
||||
|
||||
function showAdvancedSearch(path) {
|
||||
vm.showingAdvancedSearch = true;
|
||||
vm.search.mailbox = path;
|
||||
|
@ -265,7 +258,7 @@
|
|||
.then(function() {
|
||||
folder.$delete()
|
||||
.then(function() {
|
||||
$state.go('mail');
|
||||
$state.go('mail.account.inbox');
|
||||
}, function(data, status) {
|
||||
Dialog.alert(l('An error occured while deleting the mailbox "%{0}".', folder.name),
|
||||
l(data.error));
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
$stateProvider
|
||||
.state('mail', {
|
||||
url: '/Mail',
|
||||
abstract: true,
|
||||
views: {
|
||||
mailboxes: {
|
||||
templateUrl: 'UIxMailMainFrame', // UI/Templates/MailerUI/UIxMailMainFrame.wox
|
||||
|
@ -67,6 +68,20 @@
|
|||
stateMessage: stateMessage
|
||||
}
|
||||
})
|
||||
.state('mail.account.inbox', {
|
||||
url: '/inbox',
|
||||
views: {
|
||||
'mailbox@mail': {
|
||||
templateUrl: 'UIxMailFolderTemplate', // UI/Templates/MailerUI/UIxMailFolderTemplate.wox
|
||||
controller: 'MailboxController',
|
||||
controllerAs: 'mailbox'
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
stateMailbox: stateInbox,
|
||||
stateMessages: stateMessages
|
||||
}
|
||||
})
|
||||
.state('mail.account.mailbox', {
|
||||
url: '/:mailboxId',
|
||||
views: {
|
||||
|
@ -134,14 +149,7 @@
|
|||
// });
|
||||
|
||||
// if none of the above states are matched, use this as the fallback
|
||||
$urlRouterProvider.otherwise('/Mail');
|
||||
|
||||
// Set default configuration for tags input
|
||||
// tagsInputConfigProvider.setDefaults('tagsInput', {
|
||||
// addOnComma: false,
|
||||
// replaceSpacesWithDashes: false,
|
||||
// allowedTagsPattern: /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i
|
||||
// });
|
||||
$urlRouterProvider.otherwise('/Mail/0/inbox');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +157,7 @@
|
|||
*/
|
||||
stateAccounts.$inject = ['$q', 'Account'];
|
||||
function stateAccounts($q, Account) {
|
||||
var accounts = Account.$findAll(mailAccounts),
|
||||
var accounts = Account.$findAll(window.mailAccounts),
|
||||
promises = [];
|
||||
// Fetch list of mailboxes for each account
|
||||
angular.forEach(accounts, function(account, i) {
|
||||
|
@ -174,9 +182,10 @@
|
|||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateMailbox.$inject = ['$stateParams', 'stateAccount', 'decodeUriFilter', 'Mailbox'];
|
||||
function stateMailbox($stateParams, stateAccount, decodeUriFilter, Mailbox) {
|
||||
var mailboxId = decodeUriFilter($stateParams.mailboxId),
|
||||
stateMailbox.$inject = ['$q', '$state', '$stateParams', 'stateAccount', 'decodeUriFilter', 'Mailbox'];
|
||||
function stateMailbox($q, $state, $stateParams, stateAccount, decodeUriFilter, Mailbox) {
|
||||
var mailbox,
|
||||
mailboxId = decodeUriFilter($stateParams.mailboxId),
|
||||
_find;
|
||||
|
||||
// Recursive find function
|
||||
|
@ -197,7 +206,24 @@
|
|||
if (Mailbox.selectedFolder)
|
||||
Mailbox.selectedFolder.$isLoading = true;
|
||||
|
||||
return _find(stateAccount.$mailboxes);
|
||||
mailbox = _find(stateAccount.$mailboxes);
|
||||
|
||||
if (mailbox)
|
||||
return mailbox;
|
||||
else
|
||||
// Mailbox not found
|
||||
return $state.go('mail.account.inbox');
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngInject
|
||||
*/
|
||||
stateInbox.$inject = ['stateAccount', 'Mailbox'];
|
||||
function stateInbox(stateAccount, Mailbox) {
|
||||
if (Mailbox.selectedFolder)
|
||||
Mailbox.selectedFolder.$isLoading = true;
|
||||
|
||||
return stateAccount.$mailboxes[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue