From 8bd979e3e56abcffcf4a987967979e3dfc64ada6 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Wed, 20 Aug 2014 19:18:47 +0200 Subject: [PATCH] addad desc sorting for graphs view --- .../js/collections/graphCollection.js | 24 ++++++++++++-- .../js/templates/graphManagementView.ejs | 25 +++----------- .../frontend/js/views/databaseView.js | 1 - .../frontend/js/views/graphManagementView.js | 33 ++++++++++++++++++- 4 files changed, 59 insertions(+), 24 deletions(-) diff --git a/js/apps/system/aardvark/frontend/js/collections/graphCollection.js b/js/apps/system/aardvark/frontend/js/collections/graphCollection.js index 9bde0e8f58..da89a25272 100644 --- a/js/apps/system/aardvark/frontend/js/collections/graphCollection.js +++ b/js/apps/system/aardvark/frontend/js/collections/graphCollection.js @@ -5,10 +5,30 @@ window.GraphCollection = Backbone.Collection.extend({ model: window.Graph, - + + sortOptions: { + desc: false + }, + url: "/_api/gharial", - comparator: "_key", + //comparator: "_key", + + comparator: function(item, item2) { + var a, b; + if (this.sortOptions.desc === true) { + a = item.get('_key'); + b = item2.get('_key'); + return a < b ? 1 : a > b ? -1 : 0; + } + a = item.get('_key'); + b = item2.get('_key'); + return a > b ? 1 : a < b ? -1 : 0; + }, + + setSortingDesc: function(val) { + this.sortOptions.desc = val; + }, parse: function(res) { if (!res.error) { diff --git a/js/apps/system/aardvark/frontend/js/templates/graphManagementView.ejs b/js/apps/system/aardvark/frontend/js/templates/graphManagementView.ejs index 1bc03c3416..9d9e450675 100644 --- a/js/apps/system/aardvark/frontend/js/templates/graphManagementView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/graphManagementView.ejs @@ -1,6 +1,6 @@