mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
85f7e1d269
closes #2883, closes #2951 - introduce custom findQuery in ApplicationAdapter - posts/post route and editor/edit route now use custom findQuery to find a single post by id with query params - create a sorting function in PostsController for out-of-order loading - refresh updated posts in posts.index to make PostsList highlight latest draft after returning from a save in editor
38 lines
893 B
JavaScript
38 lines
893 B
JavaScript
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
|
|
|
var PostsPostRoute = AuthenticatedRoute.extend({
|
|
model: function (params) {
|
|
var self = this,
|
|
post,
|
|
postId;
|
|
|
|
postId = Number(params.post_id);
|
|
|
|
if (!Number.isInteger(postId) || !Number.isFinite(postId) || postId <= 0) {
|
|
this.transitionTo('posts.index');
|
|
}
|
|
|
|
post = this.store.getById('post', postId);
|
|
|
|
if (post) {
|
|
return post;
|
|
}
|
|
|
|
return this.store.find('post', {
|
|
id: params.post_id,
|
|
status: 'all',
|
|
staticPages: 'all'
|
|
}).then(function (records) {
|
|
var post = records.get('firstObject');
|
|
|
|
if (post) {
|
|
return post;
|
|
}
|
|
|
|
return self.transitionTo('posts.index');
|
|
});
|
|
},
|
|
});
|
|
|
|
export default PostsPostRoute;
|