0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/routes/posts/index.js
Jason Williams 2e67d6bf99 Extend adapter to support automatic includes
Closes #3325
- Add Roles model and add hasMany roles to User model.
- Add EmbeddedRelationAdapter that will automatically include
  hasMany relations in calls to the API.
- UserAdapter and PostAdapter now extend EmbeddedRelationAdapter
  and all explicit includes from store.find() have been removed.
2014-07-21 17:05:13 +00:00

21 lines
629 B
JavaScript

import loadingIndicator from 'ghost/mixins/loading-indicator';
var PostsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
// redirect to first post subroute unless no posts exist
beforeModel: function () {
var self = this;
return this.store.find('post', {
status: 'all',
staticPages: 'all',
}).then(function (records) {
var post = records.get('firstObject');
if (post) {
return self.transitionTo('posts.post', post);
}
});
}
});
export default PostsIndexRoute;