Ghost/core/client/routes/posts.js
David Arvelo 12e6b09943 Infinite Scroll on Posts List
closes #2414
- Add PostsController with loadNextPage action
- Collect and store pagination info from PostsRoute into PostsController
- Use `store.filter` on PostsRoute model hook to auto-update posts list template as post models are added to the store
- Add content list view and use it to check for scroll event
- Make PostRoute only load a post that's already in the store, until we figure how to load multiple pages on refresh
- Add util function from clientold that concats error messages from server response
2014-05-30 22:14:45 -04:00

35 lines
938 B
JavaScript

import styleBody from 'ghost/mixins/style-body';
import AuthenticatedRoute from 'ghost/routes/authenticated';
var paginationSettings = {
status: 'all',
staticPages: 'all',
page: 1,
limit: 15
};
var PostsRoute = AuthenticatedRoute.extend(styleBody, {
classNames: ['manage'],
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 this.store.filter('post', paginationSettings, function () {
return true;
});
},
setupController: function (controller, model) {
this._super(controller, model);
controller.set('paginationSettings', paginationSettings);
},
actions: {
openEditor: function (post) {
this.transitionTo('editor', post);
}
}
});
export default PostsRoute;