1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

fix events pagination

This commit is contained in:
Sylvain 2017-12-13 15:20:51 +01:00
parent 0b3192c3ab
commit e091b81187
2 changed files with 6 additions and 7 deletions

View File

@ -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

View File

@ -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