mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
8cbc6dc3b7
closes #2998 - update PostSerializer to use DS.EmbeddedRecordsMixin - create PostAdapter to include include=tags in query params for POST and PUT - set include=tags for various GET post requests - change PostModel to have { embedded: always } instead of { async: true } - update Ember-Data to beta8 from beta7 - make call to get tags from model in editor.edit route synchronous since the tags now exist in the store - change casper test to wait for call to posts api with `?include=tags`
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
|
|
|
|
var PostsPostRoute = AuthenticatedRoute.extend(loadingIndicator, ShortcutsRoute, {
|
|
model: function (params) {
|
|
var self = this,
|
|
post,
|
|
postId;
|
|
|
|
postId = Number(params.post_id);
|
|
|
|
if (!Number.isInteger(postId) || !Number.isFinite(postId) || postId <= 0) {
|
|
this.transitionTo('error404', params.post_id);
|
|
}
|
|
|
|
post = this.store.getById('post', postId);
|
|
|
|
if (post) {
|
|
return post;
|
|
}
|
|
|
|
return this.store.find('post', {
|
|
id: params.post_id,
|
|
status: 'all',
|
|
staticPages: 'all',
|
|
include: 'tags'
|
|
}).then(function (records) {
|
|
var post = records.get('firstObject');
|
|
|
|
if (post) {
|
|
return post;
|
|
}
|
|
|
|
return self.transitionTo('posts.index');
|
|
});
|
|
},
|
|
shortcuts: {
|
|
'enter': 'openEditor'
|
|
},
|
|
actions: {
|
|
openEditor: function () {
|
|
this.transitionTo('editor.edit', this.get('controller.model'));
|
|
}
|
|
}
|
|
});
|
|
|
|
export default PostsPostRoute;
|