fix #194: pagination for user tickets
This commit is contained in:
parent
1d5512347f
commit
0f9b2c8555
2 changed files with 44 additions and 12 deletions
36
angular_app/js/controllers.js
vendored
36
angular_app/js/controllers.js
vendored
|
@ -990,14 +990,43 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('UsersCtrl', ['$scope', '$rootScope', '$state', '$log', 'User', '$uibModal',
|
eventManControllers.controller('UsersCtrl', ['$scope', '$rootScope', '$state', '$log', 'User', '$uibModal', '$filter',
|
||||||
function ($scope, $rootScope, $state, $log, User, $uibModal) {
|
function ($scope, $rootScope, $state, $log, User, $uibModal, $filter) {
|
||||||
$scope.loginData = {};
|
$scope.loginData = {};
|
||||||
$scope.user = {};
|
$scope.user = {};
|
||||||
|
$scope.user.tickets = [];
|
||||||
$scope.updateUserInfo = {};
|
$scope.updateUserInfo = {};
|
||||||
$scope.users = [];
|
$scope.users = [];
|
||||||
$scope.usersOrderProp = 'username';
|
$scope.usersOrderProp = 'username';
|
||||||
$scope.ticketsOrderProp = 'title';
|
$scope.query = "";
|
||||||
|
|
||||||
|
$scope.userQuery = "";
|
||||||
|
$scope.userCurrentPage = 1;
|
||||||
|
$scope.userItemsPerPage = 10;
|
||||||
|
$scope.userFilteredLength = 0;
|
||||||
|
$scope.userMaxPaginationSize = 10;
|
||||||
|
$scope.userMaxAllPersons = 10;
|
||||||
|
$scope.userShownItems = [];
|
||||||
|
|
||||||
|
$scope.userFilterTickets = function() {
|
||||||
|
var tickets = $scope.user.tickets || [];
|
||||||
|
tickets = $filter('splittedFilter')(tickets, $scope.userQuery);
|
||||||
|
$scope.userFilteredTickets = angular.copy(tickets);
|
||||||
|
$scope.userFilteredLength = $scope.userFilteredTickets.length;
|
||||||
|
tickets = $filter('pagination')(tickets, $scope.userCurrentPage, $scope.userItemsPerPage);
|
||||||
|
$scope.userShownItems = tickets;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.$watch('userQuery', function() {
|
||||||
|
if (!$scope.userQuery) {
|
||||||
|
$scope.userCurrentPage = 1;
|
||||||
|
}
|
||||||
|
$scope.userFilterTickets();
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$watch('userCurrentPage + userItemsPerPage', function() {
|
||||||
|
$scope.userFilterTickets();
|
||||||
|
});
|
||||||
|
|
||||||
$scope.confirm_delete = 'Do you really want to delete this user?';
|
$scope.confirm_delete = 'Do you really want to delete this user?';
|
||||||
$rootScope.$on('$translateChangeSuccess', function () {
|
$rootScope.$on('$translateChangeSuccess', function () {
|
||||||
|
@ -1018,6 +1047,7 @@ eventManControllers.controller('UsersCtrl', ['$scope', '$rootScope', '$state', '
|
||||||
$scope.user = User.get({id: $state.params.id}, function() {
|
$scope.user = User.get({id: $state.params.id}, function() {
|
||||||
$scope.updateUserInfo = $scope.user;
|
$scope.updateUserInfo = $scope.user;
|
||||||
$scope.updateUserInfo.isAdmin = $rootScope.hasPermission('admin|all', $scope.updateUserInfo);
|
$scope.updateUserInfo.isAdmin = $rootScope.hasPermission('admin|all', $scope.updateUserInfo);
|
||||||
|
$scope.userFilterTickets();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,26 +36,25 @@
|
||||||
<form class="form-inline">
|
<form class="form-inline">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="query-tickets">{{'Search:' | translate}}</label>
|
<label for="query-tickets">{{'Search:' | translate}}</label>
|
||||||
<input eventman-focus type="text" id="query-tickets" class="form-control" placeholder="{{'Event title' | translate}}" ng-model="query" ng-model-options="{debounce: 350}">
|
<input eventman-focus type="text" id="query-tickets" class="form-control" placeholder="{{'Name' | translate}}" ng-model="userQuery" ng-model-options="{debounce: 350}">
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="tickets-order">{{'Sort by:' | translate}}</label>
|
|
||||||
<select id="tickets-order" class="form-control" ng-model="ticketsOrderProp">
|
|
||||||
<option value="title">{{'Title' | translate}}</option>
|
|
||||||
<option value="-title">{{'Title (descending)' | translate}}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<uib-pagination ng-model="userCurrentPage" total-items="userFilteredLength" items-per-page="userItemsPerPage"
|
||||||
|
direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="userMaxPaginationSize">
|
||||||
|
</uib-pagination>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th class="text-right nowrap">#</th>
|
||||||
<th>{{'Ticket' | translate}}</th>
|
<th>{{'Ticket' | translate}}</th>
|
||||||
<th>{{'Event' | translate}}</th>
|
<th>{{'Event' | translate}}</th>
|
||||||
<th class="text-center">{{'Attended' | translate}}</th>
|
<th class="text-center">{{'Attended' | translate}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="ticket in (user.tickets || []) | splittedFilter:query | orderBy:ticketsOrderProp">
|
<tr ng-repeat="ticket in userShownItems">
|
||||||
|
<td class="text-right">{{$index + 1 + ((userCurrentPage-1)*userItemsPerPage)}}</td>
|
||||||
<td>
|
<td>
|
||||||
<strong>
|
<strong>
|
||||||
<a ui-sref="event.ticket.edit({id: ticket.event_id, ticket_id: ticket._id})">
|
<a ui-sref="event.ticket.edit({id: ticket.event_id, ticket_id: ticket._id})">
|
||||||
|
@ -73,6 +72,9 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<uib-pagination ng-model="userCurrentPage" total-items="userFilteredLength" items-per-page="userItemsPerPage"
|
||||||
|
direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="userMaxPaginationSize">
|
||||||
|
</uib-pagination>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue