0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Properly handle no posts

fixes #4058
- Set noPosts in setupController
This commit is contained in:
Fabian Becker 2014-09-18 10:20:15 +00:00
parent a4ef0c7118
commit 4af5b89c60
2 changed files with 8 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import loadingIndicator from 'ghost/mixins/loading-indicator';
import mobileQuery from 'ghost/utils/mobile'; import mobileQuery from 'ghost/utils/mobile';
var PostsIndexRoute = MobileIndexRoute.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, { var PostsIndexRoute = MobileIndexRoute.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
noPosts: false,
// Transition to a specific post if we're not on mobile // Transition to a specific post if we're not on mobile
beforeModel: function () { beforeModel: function () {
if (!mobileQuery.matches) { if (!mobileQuery.matches) {
@ -10,6 +11,11 @@ var PostsIndexRoute = MobileIndexRoute.extend(SimpleAuth.AuthenticatedRouteMixin
} }
}, },
setupController: function (controller, model) {
/*jshint unused:false*/
controller.set('noPosts', this.get('noPosts'));
},
goToPost: function () { goToPost: function () {
var self = this, var self = this,
// the store has been populated by PostsRoute // the store has been populated by PostsRoute
@ -26,7 +32,7 @@ var PostsIndexRoute = MobileIndexRoute.extend(SimpleAuth.AuthenticatedRouteMixin
if (post) { if (post) {
return self.transitionTo('posts.post', post); return self.transitionTo('posts.post', post);
} }
self.get('controller').set('noPosts', true); self.set('noPosts', true);
}); });
}, },

View file

@ -5,4 +5,4 @@
{{#link-to "editor.new"}}<button type="button" class="btn btn-green btn-lg" title="New Post">Write a new Post</button>{{/link-to}} {{#link-to "editor.new"}}<button type="button" class="btn btn-green btn-lg" title="New Post">Write a new Post</button>{{/link-to}}
</div> </div>
</div> </div>
{{/if}} {{/if}}