/transactions/search/last10 ersetzt durch
/transactions/search/forAccount mit Paging, Transaktionen-Liste erweiterbar
This commit is contained in:
@@ -22,16 +22,12 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
}
|
||||
|
||||
// get recent transactions
|
||||
var transactions = $resource('/transactions/search/last10', { accountId: $scope.account.id }).get();
|
||||
//var transactions = $resource('/transactions?size=10&sort=date,desc')
|
||||
var transactions = $resource('http://localhost:8080/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc' }).get();
|
||||
transactions.$promise.then(function(data) {
|
||||
$scope.transactions = transactions._embedded.transactions;
|
||||
|
||||
for (var i = 0; i < $scope.transactions.length; i++) {
|
||||
$scope.transactions[i].category = $resource($scope.transactions[i]._links.category.href).get();
|
||||
$scope.transactions[i].creditor = $resource($scope.transactions[i]._links.creditor.href).get();
|
||||
}
|
||||
|
||||
$scope.nextPageAvailable = (transactions.page.totalPages !== transactions.page.number + 1);
|
||||
$scope.prevPageAvailable = (transactions.page.number > 0);
|
||||
$scope.pageNumber = transactions.page.number;
|
||||
});
|
||||
|
||||
var accountUsers = $resource($scope.account._links.users.href).get();
|
||||
@@ -113,7 +109,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
$scope.initList = function() {
|
||||
console.log('initList()');
|
||||
|
||||
$scope.transactionsPage = 0;
|
||||
$scope.pageSize = 20;
|
||||
|
||||
var userinfo = $resource('/user').get();
|
||||
userinfo.$promise.then(function(data) {
|
||||
@@ -208,6 +204,18 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
||||
$location.path('/transaction/' + transaction._links.self.href);
|
||||
};
|
||||
|
||||
$scope.moreTransactions = function() {
|
||||
if ($scope.nextPageAvailable) {
|
||||
$scope.pageNumber++;
|
||||
var transactions = $resource('http://localhost:8080/transactions/search/forAccount', { accountId: $scope.account.id, size: $scope.pageSize, sort: 'date,desc', page: $scope.pageNumber }).get();
|
||||
transactions.$promise.then(function(data) {
|
||||
$scope.transactions = $scope.transactions.concat(transactions._embedded.transactions);
|
||||
$scope.nextPageAvailable = (transactions.page.totalPages !== transactions.page.number + 1);
|
||||
$scope.prevPageAvailable = (transactions.page.number > 0);
|
||||
$scope.pageNumber = transactions.page.number;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// initialize (http://stackoverflow.com/a/25662066/3761783)
|
||||
$scope.initList();
|
||||
|
||||
@@ -63,6 +63,9 @@
|
||||
<td>{{transaction.description}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="text-align: center; font-size: 80%" ng-show="nextPageAvailable">
|
||||
<a href="" ng-click="moreTransactions()">more</a>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 2em; text-align: center;">
|
||||
<span ng-repeat="user in accountUsers">{{user.name}} {{user.outstandings | number : 2}} €<br/></span>
|
||||
|
||||
Reference in New Issue
Block a user