From 8a9297e9c2e9d736fdf0fe6e3e06486ab4a58565 Mon Sep 17 00:00:00 2001 From: Delgermurun Date: Thu, 18 Dec 2014 11:26:35 +0800 Subject: [PATCH] Add 'id' to post sort fields. So there is no longer equally sorted posts. closes #4648 - Add id to order by fields on posts API - Order by id on posts controller --- ghost/admin/controllers/posts.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ghost/admin/controllers/posts.js b/ghost/admin/controllers/posts.js index c99d22c0b2..f9119ac0de 100644 --- a/ghost/admin/controllers/posts.js +++ b/ghost/admin/controllers/posts.js @@ -36,9 +36,11 @@ var PostsController = Ember.ArrayController.extend(PaginationControllerMixin, { // status: ASC // published_at: DESC // updated_at: DESC + // id: DESC orderBy: function (item1, item2) { var updated1 = item1.get('updated_at'), updated2 = item2.get('updated_at'), + idResult, statusResult, updatedAtResult, publishedAtResult; @@ -53,12 +55,17 @@ var PostsController = Ember.ArrayController.extend(PaginationControllerMixin, { return 1; } + idResult = Ember.compare(parseInt(item1.get('id')), parseInt(item2.get('id'))); statusResult = Ember.compare(item1.get('status'), item2.get('status')); updatedAtResult = Ember.compare(updated1.valueOf(), updated2.valueOf()); publishedAtResult = publishedAtCompare(item1, item2); if (statusResult === 0) { if (publishedAtResult === 0) { + if (updatedAtResult === 0) { + // This should be DESC + return idResult * -1; + } // This should be DESC return updatedAtResult * -1; }