reset pagination when search query is reset
This commit is contained in:
parent
2095977fe8
commit
d201ba8fa8
1 changed files with 9 additions and 2 deletions
11
angular_app/js/controllers.js
vendored
11
angular_app/js/controllers.js
vendored
|
@ -68,6 +68,7 @@ eventManControllers.controller('ModalConfirmInstanceCtrl', ['$scope', '$uibModal
|
||||||
|
|
||||||
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal', '$log', '$translate', '$rootScope', '$state', '$filter',
|
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal', '$log', '$translate', '$rootScope', '$state', '$filter',
|
||||||
function ($scope, Event, $uibModal, $log, $translate, $rootScope, $state, $filter) {
|
function ($scope, Event, $uibModal, $log, $translate, $rootScope, $state, $filter) {
|
||||||
|
$scope.query = '';
|
||||||
$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')) {
|
||||||
|
@ -93,14 +94,17 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal'
|
||||||
|
|
||||||
$scope.filterTickets = function() {
|
$scope.filterTickets = function() {
|
||||||
var tickets = $scope.tickets || [];
|
var tickets = $scope.tickets || [];
|
||||||
tickets = $filter('splittedFilter')(tickets, $scope['query-tickets']);
|
tickets = $filter('splittedFilter')(tickets, $scope.query);
|
||||||
tickets = $filter('orderBy')(tickets, $scope.ticketsOrderProp);
|
tickets = $filter('orderBy')(tickets, $scope.ticketsOrderProp);
|
||||||
$scope.filteredLength = tickets.length;
|
$scope.filteredLength = tickets.length;
|
||||||
tickets = $filter('pagination')(tickets, $scope.currentPage, $scope.itemsPerPage);
|
tickets = $filter('pagination')(tickets, $scope.currentPage, $scope.itemsPerPage);
|
||||||
$scope.shownItems = tickets;
|
$scope.shownItems = tickets;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$watch('query-tickets', function() {
|
$scope.$watch('query', function() {
|
||||||
|
if (!$scope.query) {
|
||||||
|
$scope.currentPage = 1;
|
||||||
|
}
|
||||||
$scope.filterTickets();
|
$scope.filterTickets();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -223,6 +227,9 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$watch('query', function() {
|
$scope.$watch('query', function() {
|
||||||
|
if (!$scope.query) {
|
||||||
|
$scope.currentPage = 1;
|
||||||
|
}
|
||||||
$scope.filterTickets();
|
$scope.filterTickets();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue