Skip to content

Commit

Permalink
2.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
NandoMB committed May 17, 2019
1 parent b9b97e3 commit 926f515
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 27 deletions.
29 changes: 21 additions & 8 deletions dist/js/veasy-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,30 @@ angular.module('veasy.table', [
]);

angular.module('veasy.table')

.filter('vtUrl', ['$sanitize', function ($sanitize) {
return function (input, text, target) {
// if (!text) {
// var matches = input.match(/\w+:\/\/([\w|\.]+)/);
// if (matches) text = matches[0];
// }
// return $sanitize('<a target="' + target + '" href="' + input + '">' + text + '</a>');

return $sanitize('<a target="' + target + '" href="' + input + '">' + input + '</a>');
};
}])
.filter('vtLocaleOrderBy', [function () {
return function (array, predicate, reverse) {
if (!Array.isArray(array)) return array;
if (!predicate) return array;

array.sort(function (first, second) {
const valueA = first[predicate];
const valueB = second[predicate];
if (typeof valueA === 'string') {
return !reverse ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
}
if (typeof valueA === 'number' || typeof valueA === 'boolean') {
return !reverse ? valueA - valueB : valueB - valueA;
}
return 0;
});

return array;
}
}]);

angular.module('veasy.table')
Expand Down Expand Up @@ -795,7 +808,7 @@ angular.module('veasy.table')
}
scope.predicate = predicate;
if (scope.predicate !== '') {
var list = $filter('orderBy')(scope.filteredList, scope.predicate, scope.reverse);
var list = $filter('vtLocaleOrderBy')(scope.filteredList, scope.predicate, scope.reverse);
paginate(list, scope.config.pagination.itemsPerPage, 0);
}
scope.$emit('veasyTable:onEndSort');
Expand Down
4 changes: 2 additions & 2 deletions dist/js/veasy-table.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions mocks/MOCK_DATA_NEW.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"id":2,
"first_name":"Lisa",
"first_name":"Aalana",
"gender":"Female",
"company":"Apple",
"address":"193 Straubel Plaza",
Expand Down Expand Up @@ -71,7 +71,7 @@
},
{
"id":8,
"first_name":"Bobby",
"first_name":"Áalfred",
"gender":null,
"company":null,
"address":"9 Grover Center",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-veasy-table",
"version": "2.2.9",
"version": "2.2.10",
"description": "AngularJS directive to create quickly data tables without giving up the beauty and functionality.",
"author": "Fernando Machado Bernardino <[email protected]> (https://github.com/NandoMB)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/js/directives/veasyTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ angular.module('veasy.table')
}
scope.predicate = predicate;
if (scope.predicate !== '') {
var list = $filter('orderBy')(scope.filteredList, scope.predicate, scope.reverse);
var list = $filter('vtLocaleOrderBy')(scope.filteredList, scope.predicate, scope.reverse);
paginate(list, scope.config.pagination.itemsPerPage, 0);
}
scope.$emit('veasyTable:onEndSort');
Expand Down
26 changes: 26 additions & 0 deletions src/js/filters/customFilter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
angular.module('veasy.table')
.filter('vtUrl', ['$sanitize', function ($sanitize) {
return function (input, text, target) {
return $sanitize('<a target="' + target + '" href="' + input + '">' + input + '</a>');
};
}])
.filter('vtLocaleOrderBy', [function () {
return function (array, predicate, reverse) {
if (!Array.isArray(array)) return array;
if (!predicate) return array;

array.sort(function (first, second) {
const valueA = first[predicate];
const valueB = second[predicate];
if (typeof valueA === 'string') {
return !reverse ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
}
if (typeof valueA === 'number' || typeof valueA === 'boolean') {
return !reverse ? valueA - valueB : valueB - valueA;
}
return 0;
});

return array;
}
}]);
13 changes: 0 additions & 13 deletions src/js/filters/urlFilter.js

This file was deleted.

0 comments on commit 926f515

Please sign in to comment.