diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-01-30 14:07:13 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-01-30 14:07:13 -0500 |
commit | bdd0ae6722ae504431199c427c9bf603eed11737 (patch) | |
tree | 41baf3fdbe3187f701abce0c2850faf543d5b111 /js/controller | |
parent | b8ee5e4fc44bf8a37d3a8e47bc32bfe56f058aba (diff) |
js: Fix package sorting.
* js/controllers/packages.js (guix.packages.controller.sortAndPage): New
function.
(guix.packages.controller): Use 'sortAndPage'.
(guix.packages.controller.doSearch): Likewise.
Diffstat (limited to 'js/controller')
-rw-r--r-- | js/controller/packages.js | 13 |
1 files changed, 9 insertions, 4 deletions
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) { |