From bdd0ae6722ae504431199c427c9bf603eed11737 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 30 Jan 2015 14:07:13 -0500 Subject: js: Fix package sorting. * js/controllers/packages.js (guix.packages.controller.sortAndPage): New function. (guix.packages.controller): Use 'sortAndPage'. (guix.packages.controller.doSearch): Likewise. --- js/controller/packages.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'js/controller') diff --git a/js/controller/packages.js b/js/controller/packages.js index b1348e9..9cac565 100644 --- a/js/controller/packages.js +++ b/js/controller/packages.js @@ -57,7 +57,7 @@ .then(this.packages) .then(function(packages) { // All packages are visible initially - self.pager(Pager(packages)); + self.sortAndPage(packages); }) .then(m.redraw); }; @@ -69,13 +69,18 @@ .value(); }; + controller.prototype.sortAndPage = function(packages) { + this.pager(Pager(this.sorter().sort(packages))); + }; + controller.prototype.doSearch = function() { var regexp = new RegExp(this.searchTerm(), "i"); - - this.pager(Pager(this.packages().filter(function(package) { + var filteredPackages = this.packages().filter(function(package) { return regexp.test(package.name) || regexp.test(package.synopsis); - }))); + }); + + this.sortAndPage(filteredPackages); }; controller.prototype.sortBy = function(field) { -- cgit v1.2.3