Skip to content

Commit

Permalink
Generalize [pi-sort-by] to work for client-side sorting as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Pierre committed Oct 28, 2019
1 parent 07505a8 commit 20cb795
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ myApp.directive("piSortBy", function(){
link: function(scope, element, attr) {
element.on('click', function() {
var column = attr.piSortBy;
scope.params.sortby=column;
scope.sortby=column;
scope.reverse=!scope.reverse;
$(".sortUp").addClass("unsorted");
$(".sortDown").addClass("unsorted");
Expand All @@ -93,7 +93,10 @@ myApp.directive("piSortBy", function(){
} else {
element.addClass("sortUp");
}
scope.get();

// scope.get() is what we call, when sorting is done on the server. For client-side sorting $apply() is
// used to rerender the list with the new sorting.
scope.get ? scope.get() : scope.$apply();
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ myApp.controller("tokenChallengesController", function ($scope,
// define functions
$scope.get = function () {
$scope.params.serial = "*" + ($scope.serialFilter || "") + "*";
$scope.params.sortBy = $scope.sortBy;
if ($scope.reverse) {
$scope.params.sortdir = "desc";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ myApp.controller("tokenController", function (TokenFactory, ConfigFactory,
$scope.params.userid = "*" + ($scope.userIdFilter || "") + "*";
$scope.params.resolver = "*" + ($scope.resolverFilter || "") + "*";
$scope.params.pagesize = $scope.token_page_size;
$scope.params.sortBy = $scope.sortBy;
if ($scope.reverse) {
$scope.params.sortdir = "desc";
} else {
Expand Down

0 comments on commit 20cb795

Please sign in to comment.