1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 18:32:20 -05:00

WIP: start new routing

This commit is contained in:
Tankred Hase 2014-12-02 16:12:42 +01:00
parent e06fff4385
commit c012f54c89
10 changed files with 51 additions and 17 deletions

View File

@ -68,6 +68,11 @@ var app = angular.module('mail', [
// set router paths
app.config(function($routeProvider, $animateProvider) {
//
// Login routes
//
$routeProvider.when('/login', {
templateUrl: 'tpl/login.html',
controller: LoginCtrl
@ -104,10 +109,24 @@ app.config(function($routeProvider, $animateProvider) {
templateUrl: 'tpl/login-privatekey-download.html',
controller: LoginPrivateKeyDownloadCtrl
});
$routeProvider.when('/desktop', {
//
// main app routes
//
var accountRoute = {
templateUrl: 'tpl/desktop.html',
controller: NavigationCtrl
});
};
$routeProvider.when('/account', accountRoute);
$routeProvider.when('/account/:folderIndex', accountRoute);
$routeProvider.when('/account/:folderIndex/:uid', accountRoute);
//
// Default route
//
$routeProvider.otherwise({
redirectTo: '/login'
});

View File

@ -11,7 +11,7 @@ var INIT_DISPLAY_LEN = 20,
FOLDER_TYPE_INBOX = 'Inbox',
NOTIFICATION_INBOX_TIMEOUT = 5000;
var MailListCtrl = function($scope, $timeout, $routeParams, $filter, statusDisplay, notification, email, keychain, dialog, search, dummy) {
var MailListCtrl = function($scope, $timeout, $location, $routeParams, $filter, statusDisplay, notification, email, keychain, dialog, search, dummy) {
//
// Init
@ -50,6 +50,10 @@ var MailListCtrl = function($scope, $timeout, $routeParams, $filter, statusDispl
});
};
$scope.navigate = function(message) {
$location.path('/account/' + $routeParams.folderIndex + '/' + message.uid);
};
/**
* Called when clicking on an message list item
*/
@ -98,6 +102,11 @@ var MailListCtrl = function($scope, $timeout, $routeParams, $filter, statusDispl
}
};
var selectedMessage = _.findWhere(currentFolder().messages, {
uid: $routeParams.uid
});
$scope.select(selectedMessage);
$scope.flag = function(message, flagged) {
$scope.state.actionBar.flagMessage(message, flagged);
};
@ -155,7 +164,7 @@ var MailListCtrl = function($scope, $timeout, $routeParams, $filter, statusDispl
// Shows the next message based on the uid of the currently selected element
if (currentFolder().messages.indexOf(currentMessage()) === -1) {
firstSelect = true; // reset first selection
$scope.select($scope.displayMessages[0]);
$scope.navigate($scope.displayMessages[0]);
}
});
@ -301,7 +310,7 @@ var MailListCtrl = function($scope, $timeout, $routeParams, $filter, statusDispl
}
// mark message as read
$scope.select(_.findWhere(currentFolder().messages, {
$scope.navigate(_.findWhere(currentFolder().messages, {
uid: unreadMsgs[0].uid
}));
},

View File

@ -17,9 +17,13 @@ var NavigationCtrl = function($scope, $routeParams, $location, account, email, o
if (!$routeParams.dev && !account.isLoggedIn()) {
$location.path('/'); // init app
return;
} else if (!$routeParams.folderIndex) {
$location.path('/account/0'); // navigate to default account's inbox by default
return;
}
var str = appConfig.string,
var folderIndex = $routeParams.folderIndex,
str = appConfig.string,
config = appConfig.config;
//
@ -77,10 +81,12 @@ var NavigationCtrl = function($scope, $routeParams, $location, account, email, o
// init folders
initializeFolders();
// select inbox as the current folder on init
if ($scope.account.folders && $scope.account.folders.length > 0) {
$scope.openFolder($scope.account.folders[0]);
// select current folder on init
if ($scope.account.folders && $scope.account.folders.length > folderIndex) {
// navigate to the selected folder index
$scope.openFolder($scope.account.folders[folderIndex]);
}
// connect imap/smtp clients on first startup
account.onConnect(function(err) {
if (err) {

View File

@ -43,7 +43,7 @@ var LoginExistingCtrl = function($scope, $location, $routeParams, email, auth, k
return;
}
$location.path('/desktop');
$location.path('/account');
$scope.$apply();
});
}

View File

@ -65,7 +65,7 @@ var LoginInitialCtrl = function($scope, $location, $routeParams, newsletter, ema
return;
}
$location.path('/desktop');
$location.path('/account');
$scope.$apply();
});
});

View File

@ -95,7 +95,7 @@ var LoginExistingCtrl = function($scope, $location, $routeParams, email, auth, p
return;
}
$location.path('/desktop');
$location.path('/account');
$scope.$apply();
});
}

View File

@ -100,7 +100,7 @@ var LoginPrivateKeyDownloadCtrl = function($scope, $location, $routeParams, auth
return;
}
$scope.goTo('/desktop');
$scope.goTo('/account');
});
});
});

View File

@ -60,7 +60,7 @@ var LoginCtrl = function($scope, $timeout, $location, updateHandler, account, au
return dialog.error(err);
}
$scope.goTo('/desktop');
$scope.goTo('/account');
});
});
} else if (availableKeys && availableKeys.publicKey && !availableKeys.privateKey) {

View File

@ -27,7 +27,7 @@
infinite-scroll-distance="1" infinite-scroll-parent="true">
<li class="mail-list-entry"
ng-class="{'mail-list-entry--active': email === state.mailList.selected, 'mail-list-entry--unread': email.unread, 'mail-list-entry--attachment': email.attachments !== undefined && email.attachments.length > 0}"
wo-touch="select(email)"
wo-touch="navigate(email)"
ng-repeat="email in displayMessages">
<ul class="mail-list-entry__flags">
<li class="mail-list-entry__flags-unread"></li>

View File

@ -7,7 +7,7 @@
<ul class="nav__folders">
<li ng-repeat="folder in account.folders" ng-if="folder.wellknown" ng-hide="folder.type === 'Outbox' && folder.count < 1"
class="nav__folder" ng-class="{'nav__folder--open': state.nav.currentFolder === folder}">
<a href="#" wo-touch="$event.preventDefault(); openFolder(folder)">
<a href="#/account/{{$index}}">
<svg ng-if="folder.type === 'Inbox'" role="presentation">
<use xlink:href="#icon-inbox" />
</svg>
@ -38,7 +38,7 @@
<ul class="nav__folders">
<li ng-repeat="folder in account.folders" ng-if="!folder.wellknown"
class="nav__folder" ng-class="{'nav__folder--open': state.nav.currentFolder === folder}">
<a href="#" wo-touch="$event.preventDefault(); openFolder(folder)">
<a href="#/account/{{$index}}">
<svg role="presentation"><use xlink:href="#icon-folder" /></svg>
{{folder.name}}
<span ng-show="folder.count > 0" class="nav__counter">{{folder.count}}</span>