mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
a8ca517c54
closes #3222 - implementing server-side pagination for /users API - passing /users?limit=none will return all users - passing /users?status=invited will filter base on user status - creating 3 mixins (route, controller and view) to keep pagination logic DRY - updating route, controller and view for Posts to use new mixing - implementing infinite scrolling for Users Management screen (using new mixins) - Users Management screen displays all invited users, but paginates active users
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
import PaginationRouteMixin from 'ghost/mixins/pagination-route';
|
|
|
|
var activeUsersPaginationSettings = {
|
|
include: 'roles',
|
|
page: 1,
|
|
limit: 20
|
|
};
|
|
|
|
var invitedUsersPaginationSettings = {
|
|
include: 'roles',
|
|
limit: 'all',
|
|
status: 'invited'
|
|
};
|
|
|
|
var UsersIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, PaginationRouteMixin, {
|
|
setupController: function (controller, model) {
|
|
this._super(controller, model.active);
|
|
this.setupPagination(activeUsersPaginationSettings);
|
|
},
|
|
|
|
model: function () {
|
|
// using `.filter` allows the template to auto-update when new models are pulled in from the server.
|
|
// we just need to 'return true' to allow all models by default.
|
|
return Ember.RSVP.hash({
|
|
inactive: this.store.filter('user', invitedUsersPaginationSettings, function () {
|
|
return true;
|
|
}),
|
|
active: this.store.filter('user', activeUsersPaginationSettings, function () {
|
|
return true;
|
|
})
|
|
});
|
|
}
|
|
});
|
|
|
|
export default UsersIndexRoute;
|