mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
4c72c318d5
closes #2855 , closes #2848 - New mixin that utilizes NProgress for displaying a loading indictor for all routes who's model issue a "loading" event (aka: when requesting data from the server during a route change). - Also removing (the now unnecessary) "loading" template.
39 lines
974 B
JavaScript
39 lines
974 B
JavaScript
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
|
|
var PostsPostRoute = AuthenticatedRoute.extend(loadingIndicator, {
|
|
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;
|