From e091b81187472eb5b54b9e6fbb2f84192705dde6 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 13 Dec 2017 15:20:51 +0100 Subject: [PATCH] fix events pagination --- .../javascripts/controllers/admin/events.coffee.erb | 10 +++++----- app/assets/javascripts/controllers/events.coffee.erb | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/controllers/admin/events.coffee.erb b/app/assets/javascripts/controllers/admin/events.coffee.erb index 2efb2bbee..fe3d56015 100644 --- a/app/assets/javascripts/controllers/admin/events.coffee.erb +++ b/app/assets/javascripts/controllers/admin/events.coffee.erb @@ -171,7 +171,7 @@ Application.Controllers.controller "AdminEventsController", ["$scope", "$state", $scope.events = eventsPromise ## Current virtual page - $scope.page = 2 + $scope.page = 1 ## Temporary datastore for creating new elements $scope.inserted = @@ -199,10 +199,10 @@ Application.Controllers.controller "AdminEventsController", ["$scope", "$state", # Adds a bucket of events to the bottom of the page, grouped by month ## $scope.loadMoreEvents = -> - Event.query {page: $scope.page, scope: $scope.eventsScope.selected}, (data)-> + $scope.page += 1 + Event.query { page: $scope.page, scope: $scope.eventsScope.selected }, (data)-> $scope.events = $scope.events.concat data paginationCheck(data, $scope.events) - $scope.page += 1 ## @@ -349,10 +349,10 @@ Application.Controllers.controller "AdminEventsController", ["$scope", "$state", # We request the first page of corresponding events to the API ## $scope.changeScope = -> - Event.query {page: 0, scope: $scope.eventsScope.selected}, (data)-> + Event.query {page: 1, scope: $scope.eventsScope.selected}, (data)-> $scope.events = data paginationCheck(data, $scope.events) - $scope.page = 0 + $scope.page = 1 diff --git a/app/assets/javascripts/controllers/events.coffee.erb b/app/assets/javascripts/controllers/events.coffee.erb index f7d08072b..9dd525549 100644 --- a/app/assets/javascripts/controllers/events.coffee.erb +++ b/app/assets/javascripts/controllers/events.coffee.erb @@ -37,10 +37,10 @@ Application.Controllers.controller "EventsController", ["$scope", "$state", 'Eve # Adds a resultset of events to the bottom of the page, grouped by month ## $scope.loadMoreEvents = -> + $scope.page += 1 Event.query Object.assign({page: $scope.page}, $scope.filters), (data) -> $scope.events = $scope.events.concat data groupEvents($scope.events) - $scope.page += 1 if (!data[0] || data[0].nb_total_events <= $scope.events.length) $scope.noMoreResults = true @@ -71,7 +71,6 @@ Application.Controllers.controller "EventsController", ["$scope", "$state", 'Eve Event.query Object.assign({page: $scope.page}, $scope.filters), (data) -> $scope.events = data groupEvents(data) - $scope.page += 1 if (!data[0] || data[0].nb_total_events <= $scope.events.length) $scope.noMoreResults = true