pagination for All tickets page
This commit is contained in:
parent
d0286e2a80
commit
2095977fe8
2 changed files with 34 additions and 4 deletions
30
angular_app/js/controllers.js
vendored
30
angular_app/js/controllers.js
vendored
|
@ -66,8 +66,8 @@ eventManControllers.controller('ModalConfirmInstanceCtrl', ['$scope', '$uibModal
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal', '$log', '$translate', '$rootScope', '$state',
|
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal', '$log', '$translate', '$rootScope', '$state', '$filter',
|
||||||
function ($scope, Event, $uibModal, $log, $translate, $rootScope, $state) {
|
function ($scope, Event, $uibModal, $log, $translate, $rootScope, $state, $filter) {
|
||||||
$scope.tickets = [];
|
$scope.tickets = [];
|
||||||
$scope.events = Event.all(function(events) {
|
$scope.events = Event.all(function(events) {
|
||||||
if (events && $state.is('tickets')) {
|
if (events && $state.is('tickets')) {
|
||||||
|
@ -79,11 +79,35 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal'
|
||||||
});
|
});
|
||||||
$scope.tickets.push.apply($scope.tickets, evt_tickets || []);
|
$scope.tickets.push.apply($scope.tickets, evt_tickets || []);
|
||||||
});
|
});
|
||||||
|
$scope.filterTickets();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$scope.eventsOrderProp = "-begin_date";
|
$scope.eventsOrderProp = "-begin_date";
|
||||||
$scope.ticketsOrderProp = ["name", "surname"];
|
$scope.ticketsOrderProp = ["name", "surname"];
|
||||||
|
|
||||||
|
$scope.shownItems = [];
|
||||||
|
$scope.currentPage = 1;
|
||||||
|
$scope.itemsPerPage = 20;
|
||||||
|
$scope.filteredLength = 0;
|
||||||
|
$scope.maxPaginationSize = 5;
|
||||||
|
|
||||||
|
$scope.filterTickets = function() {
|
||||||
|
var tickets = $scope.tickets || [];
|
||||||
|
tickets = $filter('splittedFilter')(tickets, $scope['query-tickets']);
|
||||||
|
tickets = $filter('orderBy')(tickets, $scope.ticketsOrderProp);
|
||||||
|
$scope.filteredLength = tickets.length;
|
||||||
|
tickets = $filter('pagination')(tickets, $scope.currentPage, $scope.itemsPerPage);
|
||||||
|
$scope.shownItems = tickets;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.$watch('query-tickets', function() {
|
||||||
|
$scope.filterTickets();
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$watch('currentPage + itemsPerPage', function() {
|
||||||
|
$scope.filterTickets();
|
||||||
|
});
|
||||||
|
|
||||||
$scope.confirm_delete = 'Do you really want to delete this event?';
|
$scope.confirm_delete = 'Do you really want to delete this event?';
|
||||||
$rootScope.$on('$translateChangeSuccess', function () {
|
$rootScope.$on('$translateChangeSuccess', function () {
|
||||||
$translate('Do you really want to delete this event?').then(function (translation) {
|
$translate('Do you really want to delete this event?').then(function (translation) {
|
||||||
|
@ -123,8 +147,8 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$scope.ticketsOrderProp = new_order;
|
$scope.ticketsOrderProp = new_order;
|
||||||
|
$scope.filterTickets();
|
||||||
};
|
};
|
||||||
|
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
|
||||||
|
boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
|
||||||
|
</pagination>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -25,7 +28,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="ticket in tickets | splittedFilter:query | orderBy:ticketsOrderProp">
|
<tr ng-repeat="ticket in shownItems">
|
||||||
<td class="text-right">{{$index+1}}</td>
|
<td class="text-right">{{$index+1}}</td>
|
||||||
<td>
|
<td>
|
||||||
<span><strong><a ui-sref="event.ticket.edit({id: ticket.event_id, ticket_id: ticket._id})"><span>{{ticket.name}}</span> <span>{{ticket.surname}}</span></a></strong></span><span ng-if="ticket.email"> <{{ticket.email}}></span>
|
<span><strong><a ui-sref="event.ticket.edit({id: ticket.event_id, ticket_id: ticket._id})"><span>{{ticket.name}}</span> <span>{{ticket.surname}}</span></a></strong></span><span ng-if="ticket.email"> <{{ticket.email}}></span>
|
||||||
|
@ -40,6 +43,9 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
|
||||||
|
boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
|
||||||
|
</pagination>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue