diff --git a/ghost/admin/app/controllers/posts-loading.js b/ghost/admin/app/controllers/posts-loading.js index 116cf9a237..80acc04921 100644 --- a/ghost/admin/app/controllers/posts-loading.js +++ b/ghost/admin/app/controllers/posts-loading.js @@ -11,6 +11,8 @@ export default Controller.extend({ availableTags: readOnly('postsController.availableTags'), selectedTag: readOnly('postsController.selectedTag'), availableAuthors: readOnly('postsController.availableAuthors'), - selectedAuthor: readOnly('postsController.selectedAuthor') + selectedAuthor: readOnly('postsController.selectedAuthor'), + availableOrders: readOnly('postsController.availableOrders'), + selectedOrder: readOnly('postsController.selectedOrder') }); diff --git a/ghost/admin/app/controllers/posts.js b/ghost/admin/app/controllers/posts.js index 91386ec094..2e5edf617d 100644 --- a/ghost/admin/app/controllers/posts.js +++ b/ghost/admin/app/controllers/posts.js @@ -8,10 +8,11 @@ export default Controller.extend({ session: injectService(), store: injectService(), - queryParams: ['type', 'author', 'tag'], + queryParams: ['type', 'author', 'tag', 'order'], type: null, author: null, tag: null, + order: null, _hasLoadedTags: false, _hasLoadedAuthors: false, @@ -35,6 +36,14 @@ export default Controller.extend({ value: 'page' }], + availableOrders: [{ + name: 'Latest', + value: null + }, { + name: 'Earliest', + value: 'published_at asc' + }], + showingAll: computed('type', 'author', 'tag', function () { let {type, author, tag} = this.getProperties(['type', 'author', 'tag']); @@ -46,6 +55,11 @@ export default Controller.extend({ return types.findBy('value', this.get('type')); }), + selectedOrder: computed('order', function () { + let orders = this.get('availableOrders'); + return orders.findBy('value', this.get('order')); + }), + _availableTags: computed(function () { return this.get('store').peekAll('tag'); }), @@ -101,6 +115,10 @@ export default Controller.extend({ changeTag(tag) { this.set('tag', get(tag, 'slug')); + }, + + changeOrder(order) { + this.set('order', get(order, 'value')); } } }); diff --git a/ghost/admin/app/routes/posts.js b/ghost/admin/app/routes/posts.js index 39114a48f9..fbc61f43e5 100644 --- a/ghost/admin/app/routes/posts.js +++ b/ghost/admin/app/routes/posts.js @@ -24,6 +24,10 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, { tag: { refreshModel: true, replace: true + }, + order: { + refreshModel: true, + replace: true } }, @@ -47,6 +51,10 @@ export default AuthenticatedRoute.extend(InfinityRoute, ShortcutsRoute, { queryParams.filter = filter; } + if (!isBlank(params.order)) { + queryParams.order = params.order; + } + let perPage = this.get('perPage'); let paginationSettings = assign({perPage, startingPage: 1}, queryParams); diff --git a/ghost/admin/app/templates/components/gh-nav-menu.hbs b/ghost/admin/app/templates/components/gh-nav-menu.hbs index ce91b6c134..cfce84c0c3 100644 --- a/ghost/admin/app/templates/components/gh-nav-menu.hbs +++ b/ghost/admin/app/templates/components/gh-nav-menu.hbs @@ -33,7 +33,7 @@