Skip to content

Commit 8f3296e

Browse files
committed
v2.21.4
1 parent a94b2cb commit 8f3296e

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-table",
3-
"version": "2.21.3",
3+
"version": "2.21.4",
44
"main": [
55
"./dist/ap-mesa.js",
66
"./dist/ap-mesa.css"

dist/ap-mesa.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,9 @@ angular.module('apMesa.controllers.ApMesaController', [
847847
});
848848
}
849849
},
850+
getRowSort: function () {
851+
return scope.persistentState.sortOrder;
852+
},
850853
hasActiveFilters: function () {
851854
return scope.enabledColumns.some(function (columnId) {
852855
return scope.persistentState.searchTerms[columnId];
@@ -1550,7 +1553,15 @@ angular.module('apMesa.filters.apMesaRowSorter', []).filter('apMesaRowSorter', f
15501553
columns.forEach(function (column) {
15511554
enabledColumns[column.id] = true;
15521555
});
1553-
return arrayCopy.sort(function (a, b) {
1556+
// js sort doesn't work as expected because it rearranges the equal elements
1557+
// so we will arrange elements only if they are different, based on the element index
1558+
var sortArray = arrayCopy.map(function (data, index) {
1559+
return {
1560+
index: index,
1561+
data: data
1562+
};
1563+
});
1564+
sortArray.sort(function (a, b) {
15541565
for (var i = 0; i < sortOrder.length; i++) {
15551566
var sortItem = sortOrder[i];
15561567
if (!enabledColumns[sortItem.id]) {
@@ -1560,13 +1571,16 @@ angular.module('apMesa.filters.apMesaRowSorter', []).filter('apMesaRowSorter', f
15601571
var dir = sortItem.dir;
15611572
if (column && column.sort) {
15621573
var fn = column.sort;
1563-
var result = dir === '+' ? fn(a, b, options, column) : fn(b, a, options, column);
1574+
var result = dir === '+' ? fn(a.data, b.data, options, column) : fn(b.data, a.data, options, column);
15641575
if (result !== 0) {
15651576
return result;
15661577
}
15671578
}
15681579
}
1569-
return 0;
1580+
return a.index - b.index;
1581+
});
1582+
return sortArray.map(function (value) {
1583+
return value.data;
15701584
});
15711585
};
15721586
});

dist/ap-mesa.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angularjs-table",
3-
"version": "2.21.3",
3+
"version": "2.21.4",
44
"license": "Apache License, v2.0",
55
"dependencies": {
66
"angular": "^1.6",

0 commit comments

Comments
 (0)