Skip to content
Permalink
Browse files

Generalize [pi-sort-by] to work for client-side sorting as well.

  • Loading branch information...
NuvandaPV committed Oct 28, 2019
1 parent 07505a8 commit 20cb795131e6651a67f9987de4e4e5c758417f75
@@ -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");
@@ -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();
});
}
};
@@ -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 {
@@ -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 {

0 comments on commit 20cb795

Please sign in to comment.
You can’t perform that action at this time.