Browse Source

fixes #166: introduce pagination for tickets

Davide Alberani 7 years ago
parent
commit
55208639d4
3 changed files with 16 additions and 12 deletions
  1. 3 3
      angular_app/event-tickets.html
  2. 11 7
      angular_app/js/controllers.js
  3. 2 2
      angular_app/tickets-list.html

+ 3 - 3
angular_app/event-tickets.html

@@ -31,7 +31,7 @@
                             </div>&nbsp;<label>&nbsp;<input type="checkbox" ng-model="registeredFilterOptions.all" /> {{'Show cancelled tickets' | translate}}</label>
                         </form>
 						<pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
-                                    boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
+                                    direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
                         </pagination>
                         <table class="table table-striped">
                             <thead>
@@ -75,7 +75,7 @@
                             </tbody>
                         </table>
 						<pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
-                                    boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
+                                    direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
                         </pagination>
                     </div>
                 </div>
@@ -93,7 +93,7 @@
                                 </tr>
                             </thead>
                             <tbody>
-                                <tr ng-repeat="person in (query ? allPersons : []) | splittedFilter:query | personRegistered:{event: event, present: false}">
+                                <tr ng-repeat="person in (query ? allPersons : []) | splittedFilter:query | personRegistered:{event: event, present: false} | limitTo:10>
                                     <td>
                                         <strong>{{person.name}} {{person.surname}}</strong>
                                         <br />

+ 11 - 7
angular_app/js/controllers.js

@@ -88,9 +88,9 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal'
 
         $scope.shownItems = [];
         $scope.currentPage = 1;
-        $scope.itemsPerPage = 20;
+        $scope.itemsPerPage = 10;
         $scope.filteredLength = 0;
-        $scope.maxPaginationSize = 5;
+        $scope.maxPaginationSize = 10;
 
         $scope.filterTickets = function() {
             var tickets = $scope.tickets || [];
@@ -210,11 +210,13 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
         $scope.guiOptions = {dangerousActionsEnabled: false};
         $scope.customFields = Setting.query({setting: 'ticket_custom_field', in_event_details: true});
         $scope.registeredFilterOptions = {all: false};
+        $scope.formFieldsMap = {};
+        $scope.formFieldsMapRev = {};
 
         $scope.currentPage = 1;
-        $scope.itemsPerPage = 20;
+        $scope.itemsPerPage = 10;
         $scope.filteredLength = 0;
-        $scope.maxPaginationSize = 5;
+        $scope.maxPaginationSize = 10;
 
         $scope.filterTickets = function() {
             var tickets = $scope.event.tickets || [];
@@ -233,12 +235,13 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
             $scope.filterTickets();
         });
 
-        $scope.$watch('currentPage + itemsPerPage', function() {
+        $scope.$watch('registeredFilterOptions', function() {
             $scope.filterTickets();
         });
 
-        $scope.formFieldsMap = {};
-        $scope.formFieldsMapRev = {};
+        $scope.$watch('currentPage + itemsPerPage', function() {
+            $scope.filterTickets();
+        });
 
         if ($state.params.id) {
             $scope.event = Event.get({id: $state.params.id}, function(data) {
@@ -642,6 +645,7 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
                 }
             );
             $scope.ticketsOrder = new_order;
+            $scope.filterTickets();
         };
 
         $scope.showMessage = function(cfg) {

+ 2 - 2
angular_app/tickets-list.html

@@ -16,7 +16,7 @@
             </form>
 
             <pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
-                        boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
+                        direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
             </pagination>
             <table class="table table-striped">
                 <thead>
@@ -44,7 +44,7 @@
                 </tbody>
             </table>
             <pagination ng-model="currentPage" total-items="filteredLength" items-per-page="itemsPerPage"
-                        boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
+                        direction-links="false" boundary-links="true" boundary-link-numbers="true" max-size="maxPaginationSize">
             </pagination>
         </div>
     </div>