@bento-core/paginated-table 1.0.1-icdc.18 → 1.0.1-icdc.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34,6 +34,12 @@ const TableController = props => {
|
|
|
34
34
|
sortBy,
|
|
35
35
|
sortOrder
|
|
36
36
|
} = table;
|
|
37
|
+
const arraySort = (a, b) => {
|
|
38
|
+
// handles sort for csvDownload column
|
|
39
|
+
const aHasData = a[sortBy] && a[sortBy].length > 0;
|
|
40
|
+
const bHasData = b[sortBy] && b[sortBy].length > 0;
|
|
41
|
+
return aHasData === bHasData ? 0 : aHasData ? -1 : 1;
|
|
42
|
+
};
|
|
37
43
|
|
|
38
44
|
/**
|
|
39
45
|
* client table aplhanumeric sorting for column table
|
|
@@ -48,7 +54,13 @@ const TableController = props => {
|
|
|
48
54
|
* sort base on table state
|
|
49
55
|
*/
|
|
50
56
|
const sortRows = (a, b) => {
|
|
51
|
-
|
|
57
|
+
const areValuesArrays = Array.isArray(a[sortBy]) && Array.isArray(b[sortBy]);
|
|
58
|
+
if (areValuesArrays) {
|
|
59
|
+
if (sortOrder === 'asc') {
|
|
60
|
+
return arraySort(a, b);
|
|
61
|
+
}
|
|
62
|
+
return arraySort(b, a);
|
|
63
|
+
}
|
|
52
64
|
if (sortOrder === 'asc') {
|
|
53
65
|
return alphaNumericSort(a, b);
|
|
54
66
|
}
|
package/package.json
CHANGED
|
@@ -27,6 +27,13 @@ const TableController = ((props) => {
|
|
|
27
27
|
sortOrder,
|
|
28
28
|
} = table;
|
|
29
29
|
|
|
30
|
+
const arraySort = (a, b) => {
|
|
31
|
+
// handles sort for csvDownload column
|
|
32
|
+
const aHasData = a[sortBy] && a[sortBy].length > 0;
|
|
33
|
+
const bHasData = b[sortBy] && b[sortBy].length > 0;
|
|
34
|
+
return aHasData === bHasData ? 0 : aHasData ? -1 : 1;
|
|
35
|
+
};
|
|
36
|
+
|
|
30
37
|
/**
|
|
31
38
|
* client table aplhanumeric sorting for column table
|
|
32
39
|
* uses string prototype function for sorting
|
|
@@ -42,6 +49,14 @@ const TableController = ((props) => {
|
|
|
42
49
|
* sort base on table state
|
|
43
50
|
*/
|
|
44
51
|
const sortRows = (a, b) => {
|
|
52
|
+
const areValuesArrays = Array.isArray(a[sortBy]) && Array.isArray(b[sortBy]);
|
|
53
|
+
if (areValuesArrays) {
|
|
54
|
+
if (sortOrder === 'asc') {
|
|
55
|
+
return arraySort(a, b);
|
|
56
|
+
}
|
|
57
|
+
return arraySort(b, a);
|
|
58
|
+
}
|
|
59
|
+
|
|
45
60
|
if (sortOrder === 'asc') {
|
|
46
61
|
return alphaNumericSort(a, b);
|
|
47
62
|
}
|