@bento-core/paginated-table 1.0.1-icdc.19 → 1.0.1-icdc.20
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.
|
@@ -16,33 +16,29 @@ or in package.json
|
|
|
16
16
|
Assuming New Dashboard page have Filter component and table component from bento-core
|
|
17
17
|
</span>.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
19
|
### 2 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
22
20
|
|
|
23
21
|
```
|
|
24
22
|
import React, { useCallback } from 'react';
|
|
25
23
|
import { ButtonView, btnTypes, TableContextProvider } from '@bento-core/paginated-table';
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/>
|
|
45
|
-
), []);
|
|
25
|
+
<ButtonView
|
|
26
|
+
btnType={btnTypes.ADD_ALL_FILES}
|
|
27
|
+
title="Add all files Btn"
|
|
28
|
+
clsName="add_all_button"
|
|
29
|
+
maxFileLimit={10000}
|
|
30
|
+
activeFilters={activeFilters}
|
|
31
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
32
|
+
responseKeys={['caseOverview', 'files']}
|
|
33
|
+
classes={classes}
|
|
34
|
+
section="toolTipText"
|
|
35
|
+
tooltipCofig={{
|
|
36
|
+
arrow: true,
|
|
37
|
+
clsName: 'addAllTooltip',
|
|
38
|
+
toolTipText: 'Add filtered files associated with all cases',
|
|
39
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
46
42
|
```
|
|
47
43
|
|
|
48
44
|
**Add All Button Component or Configuration Properties**
|
|
@@ -78,23 +74,51 @@ const AddAllBlueButton = useCallback(() => (
|
|
|
78
74
|
};
|
|
79
75
|
|
|
80
76
|
const btnTheme = createTheme({ overrides: { ...customTheme } });
|
|
81
|
-
<TableContextProvider>
|
|
82
77
|
<ThemeProvider theme={btnTheme}>
|
|
83
|
-
<Container
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
<Container
|
|
79
|
+
maxWidth="xl"
|
|
80
|
+
>
|
|
81
|
+
<ButtonView
|
|
82
|
+
btnType={btnTypes.ADD_ALL_FILES}
|
|
83
|
+
title="Add all files Btn"
|
|
84
|
+
clsName="add_all_button"
|
|
85
|
+
maxFileLimit={10000}
|
|
86
|
+
activeFilters={activeFilters}
|
|
87
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
88
|
+
responseKeys={['caseOverview', 'files']}
|
|
89
|
+
classes={classes}
|
|
90
|
+
section="toolTipText"
|
|
91
|
+
tooltipCofig={{
|
|
92
|
+
arrow: true,
|
|
93
|
+
clsName: 'addAllTooltip',
|
|
94
|
+
toolTipText: 'Add filtered files associated with all cases',
|
|
95
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
<ButtonView
|
|
99
|
+
btnType={btnTypes.ADD_SELECTED_FILES}
|
|
100
|
+
title="ADD SELECTED FILES Btn"
|
|
101
|
+
clsName="add_selected_button"
|
|
102
|
+
dataKey="case_ids"
|
|
103
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
104
|
+
responseKeys={['caseOverview', 'files']}
|
|
105
|
+
classes={classes}
|
|
106
|
+
tooltipCofig={{
|
|
107
|
+
arrow: true,
|
|
108
|
+
clsName: 'addSelectedFileTooltip',
|
|
109
|
+
tooltipText: 'Add files associated selected cases',
|
|
110
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
88
113
|
</Container>
|
|
89
114
|
</ThemeProvider>
|
|
90
115
|
|
|
91
|
-
// table view
|
|
92
116
|
<Grid container>
|
|
93
117
|
<Grid item xs={12} id={config.tableID}>
|
|
94
118
|
<TableView
|
|
119
|
+
initState={initTblState}
|
|
95
120
|
...
|
|
96
121
|
/>
|
|
97
122
|
</Grid>
|
|
98
123
|
</Grid>
|
|
99
|
-
</TableContextProvider>
|
|
100
124
|
```
|
|
@@ -21,24 +21,21 @@ Assuming table component is imported from bento-core/paginated-table
|
|
|
21
21
|
import React, { useCallback } from 'react';
|
|
22
22
|
import { ButtonView, btnTypes } from '@bento-core/paginated-table';
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}}
|
|
40
|
-
/>
|
|
41
|
-
), []);
|
|
24
|
+
<ButtonView
|
|
25
|
+
btnType={btnTypes.ADD_SELECTED_FILES}
|
|
26
|
+
title="ADD SELECTED FILES Btn"
|
|
27
|
+
clsName="add_selected_button"
|
|
28
|
+
dataKey="case_ids"
|
|
29
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
30
|
+
responseKeys={['caseOverview', 'files']}
|
|
31
|
+
classes={classes}
|
|
32
|
+
tooltipCofig={{
|
|
33
|
+
arrow: true,
|
|
34
|
+
clsName: 'addSelectedFileTooltip',
|
|
35
|
+
tooltipText: 'Add files associated selected cases',
|
|
36
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
42
39
|
```
|
|
43
40
|
|
|
44
41
|
**Add All Button Component or Configuration Properties**
|
|
@@ -74,24 +71,51 @@ const AddSelectedFilesOrangeButton = useCallback(() => (
|
|
|
74
71
|
};
|
|
75
72
|
|
|
76
73
|
const btnTheme = createTheme({ overrides: { ...customTheme } });
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
<ThemeProvider theme={btnTheme}>
|
|
75
|
+
<Container
|
|
76
|
+
maxWidth="xl"
|
|
77
|
+
>
|
|
78
|
+
<ButtonView
|
|
79
|
+
btnType={btnTypes.ADD_ALL_FILES}
|
|
80
|
+
title="Add all files Btn"
|
|
81
|
+
clsName="add_all_button"
|
|
82
|
+
maxFileLimit={10000}
|
|
83
|
+
activeFilters={activeFilters}
|
|
84
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
85
|
+
responseKeys={['caseOverview', 'files']}
|
|
86
|
+
classes={classes}
|
|
87
|
+
section="toolTipText"
|
|
88
|
+
tooltipCofig={{
|
|
89
|
+
arrow: true,
|
|
90
|
+
clsName: 'addAllTooltip',
|
|
91
|
+
toolTipText: 'Add filtered files associated with all cases',
|
|
92
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
<ButtonView
|
|
96
|
+
btnType={btnTypes.ADD_SELECTED_FILES}
|
|
97
|
+
title="ADD SELECTED FILES Btn"
|
|
98
|
+
clsName="add_selected_button"
|
|
99
|
+
dataKey="case_ids"
|
|
100
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
101
|
+
responseKeys={['caseOverview', 'files']}
|
|
102
|
+
classes={classes}
|
|
103
|
+
tooltipCofig={{
|
|
104
|
+
arrow: true,
|
|
105
|
+
clsName: 'addSelectedFileTooltip',
|
|
106
|
+
tooltipText: 'Add files associated selected cases',
|
|
107
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
85
110
|
</Container>
|
|
86
111
|
</ThemeProvider>
|
|
87
112
|
|
|
88
|
-
// table view
|
|
89
113
|
<Grid container>
|
|
90
114
|
<Grid item xs={12} id={config.tableID}>
|
|
91
115
|
<TableView
|
|
116
|
+
initState={initTblState}
|
|
92
117
|
...
|
|
93
118
|
/>
|
|
94
119
|
</Grid>
|
|
95
120
|
</Grid>
|
|
96
|
-
</TableContextProvider>
|
|
97
121
|
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
### Column Grouping Configure
|
|
2
|
+
* startColIndex - endColIndex: range of the column group, should not be overlapping between the column groups.
|
|
3
|
+
```
|
|
4
|
+
const config = {
|
|
5
|
+
title: 'program',
|
|
6
|
+
dataField: 'studiesByProgram',
|
|
7
|
+
extendedViewConfig: { // display download button and manage view column
|
|
8
|
+
download: {
|
|
9
|
+
downloadFileName: 'ICDC_Studies_download',
|
|
10
|
+
downloadCsv: 'Download Table Contents As CSV',
|
|
11
|
+
},
|
|
12
|
+
manageViewColumns: {
|
|
13
|
+
title: 'View Columns',
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
columns: [
|
|
17
|
+
{
|
|
18
|
+
cellType: cellTypes.CHECKBOX,
|
|
19
|
+
display: true,
|
|
20
|
+
role: cellTypes.CHECKBOX,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
dataField: 'program_id',
|
|
24
|
+
header: 'Program',
|
|
25
|
+
cellType: cellTypes.LINK,
|
|
26
|
+
linkAttr: {
|
|
27
|
+
rootPath: '/program',
|
|
28
|
+
pathParams: ['program_id'],
|
|
29
|
+
},
|
|
30
|
+
role: cellTypes.DISPLAY,
|
|
31
|
+
display: true,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
columnGroups: {
|
|
35
|
+
{
|
|
36
|
+
clsName: 'col_group_1',
|
|
37
|
+
title: 'column group title',
|
|
38
|
+
columnIndexes: [startColIndex, endColIndex],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
clsName: 'col_group_2',
|
|
42
|
+
title: 'column group title',
|
|
43
|
+
customViewRender: () => <h2>'custom Text'</h2>, // add custom element to title
|
|
44
|
+
columnIndexes: [startColIndex, endColIndex],
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const initTblState = (initailState) => ({
|
|
50
|
+
...initailState,
|
|
51
|
+
title: config.name,
|
|
52
|
+
query: config.api,
|
|
53
|
+
dataKey: config.dataKey,
|
|
54
|
+
columns: configColumn(config.columns),
|
|
55
|
+
count: dashboardStats[config.count],
|
|
56
|
+
selectedRows: [],
|
|
57
|
+
tableMsg: config.tableMsg,
|
|
58
|
+
paginationAPIField: config.paginationAPIField,
|
|
59
|
+
sortBy: config.defaultSortField,
|
|
60
|
+
sortOrder: config.defaultSortDirection,
|
|
61
|
+
columnGroups: config.columnGroups
|
|
62
|
+
rowsPerPage: 10,
|
|
63
|
+
page: 0,
|
|
64
|
+
});
|
|
65
|
+
```
|
|
@@ -10,6 +10,11 @@ var _table = require("@bento-core/table");
|
|
|
10
10
|
var _TableService = require("./TableService");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
18
|
/**
|
|
14
19
|
* Updates table row when table state is changed 1. (paginated action) and 2. filter action
|
|
15
20
|
*/
|
|
@@ -32,14 +37,9 @@ const TableController = props => {
|
|
|
32
37
|
page = 0,
|
|
33
38
|
rowsPerPage = 10,
|
|
34
39
|
sortBy,
|
|
35
|
-
sortOrder
|
|
40
|
+
sortOrder,
|
|
41
|
+
groupBy
|
|
36
42
|
} = 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
|
-
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* client table aplhanumeric sorting for column table
|
|
@@ -50,6 +50,59 @@ const TableController = props => {
|
|
|
50
50
|
sensitivity: 'base'
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
// use group index to customize cell view
|
|
54
|
+
const groupingIndex = array => {
|
|
55
|
+
if (array.length === 0) {
|
|
56
|
+
return array;
|
|
57
|
+
}
|
|
58
|
+
const columnValues = array.map(item => item[groupBy]);
|
|
59
|
+
const distinctGroups = [...new Set(columnValues)];
|
|
60
|
+
const indexedArray = [];
|
|
61
|
+
distinctGroups.forEach(group => {
|
|
62
|
+
let index = 0;
|
|
63
|
+
array.forEach(row => {
|
|
64
|
+
if (row[groupBy] === group) {
|
|
65
|
+
indexedArray.push(_objectSpread(_objectSpread({}, row), {}, {
|
|
66
|
+
groupIndex: index
|
|
67
|
+
}));
|
|
68
|
+
index += 1;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return indexedArray;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// sort order with row group
|
|
76
|
+
// 1. sort by groupBy
|
|
77
|
+
// 2. sort by current sort column
|
|
78
|
+
const sortWithRowGrouping = function sortWithRowGrouping() {
|
|
79
|
+
let array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
80
|
+
const sorted = array.sort((a, b) => {
|
|
81
|
+
// if current sort column is not groupBy column
|
|
82
|
+
// apply sorting with row grouping
|
|
83
|
+
if (groupBy !== sortBy) {
|
|
84
|
+
const rowGrouping = "".concat(a[groupBy]).localeCompare("".concat(b[groupBy]), undefined, {
|
|
85
|
+
numeric: true,
|
|
86
|
+
sensitivity: 'base'
|
|
87
|
+
});
|
|
88
|
+
if (rowGrouping !== 0) {
|
|
89
|
+
return rowGrouping;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (sortOrder === 'asc') {
|
|
93
|
+
return alphaNumericSort(a, b);
|
|
94
|
+
}
|
|
95
|
+
return alphaNumericSort(b, a);
|
|
96
|
+
});
|
|
97
|
+
return groupingIndex(sorted);
|
|
98
|
+
};
|
|
99
|
+
const arraySort = (a, b) => {
|
|
100
|
+
// handles sort for the column with the array value
|
|
101
|
+
const aHasData = a[sortBy] && a[sortBy].length > 0;
|
|
102
|
+
const bHasData = b[sortBy] && b[sortBy].length > 0;
|
|
103
|
+
return aHasData === bHasData ? 0 : aHasData ? -1 : 1;
|
|
104
|
+
};
|
|
105
|
+
|
|
53
106
|
/**
|
|
54
107
|
* sort base on table state
|
|
55
108
|
*/
|
|
@@ -66,7 +119,10 @@ const TableController = props => {
|
|
|
66
119
|
}
|
|
67
120
|
return alphaNumericSort(b, a);
|
|
68
121
|
};
|
|
69
|
-
|
|
122
|
+
|
|
123
|
+
// sort based on row grouping
|
|
124
|
+
// groupBy column name
|
|
125
|
+
const sortedRows = groupBy ? sortWithRowGrouping(updateRows) : [...updateRows].sort((a, b) => sortRows(a, b));
|
|
70
126
|
const startIndex = page * rowsPerPage;
|
|
71
127
|
const endIndex = startIndex + rowsPerPage;
|
|
72
128
|
const displayRows = [...sortedRows].slice(startIndex, endIndex);
|
package/package.json
CHANGED
|
@@ -25,15 +25,9 @@ const TableController = ((props) => {
|
|
|
25
25
|
rowsPerPage = 10,
|
|
26
26
|
sortBy,
|
|
27
27
|
sortOrder,
|
|
28
|
+
groupBy,
|
|
28
29
|
} = table;
|
|
29
30
|
|
|
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
|
-
|
|
37
31
|
/**
|
|
38
32
|
* client table aplhanumeric sorting for column table
|
|
39
33
|
* uses string prototype function for sorting
|
|
@@ -45,6 +39,64 @@ const TableController = ((props) => {
|
|
|
45
39
|
},
|
|
46
40
|
);
|
|
47
41
|
|
|
42
|
+
// use group index to customize cell view
|
|
43
|
+
const groupingIndex = (array) => {
|
|
44
|
+
if (array.length === 0) {
|
|
45
|
+
return array;
|
|
46
|
+
}
|
|
47
|
+
const columnValues = array.map((item) => item[groupBy]);
|
|
48
|
+
const distinctGroups = [...new Set(columnValues)];
|
|
49
|
+
const indexedArray = [];
|
|
50
|
+
distinctGroups.forEach((group) => {
|
|
51
|
+
let index = 0;
|
|
52
|
+
array.forEach((row) => {
|
|
53
|
+
if (row[groupBy] === group) {
|
|
54
|
+
indexedArray.push({
|
|
55
|
+
...row,
|
|
56
|
+
groupIndex: index,
|
|
57
|
+
});
|
|
58
|
+
index += 1;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return indexedArray;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// sort order with row group
|
|
66
|
+
// 1. sort by groupBy
|
|
67
|
+
// 2. sort by current sort column
|
|
68
|
+
const sortWithRowGrouping = (array = []) => {
|
|
69
|
+
const sorted = array.sort((a, b) => {
|
|
70
|
+
// if current sort column is not groupBy column
|
|
71
|
+
// apply sorting with row grouping
|
|
72
|
+
if (groupBy !== sortBy) {
|
|
73
|
+
const rowGrouping = `${a[groupBy]}`.localeCompare(
|
|
74
|
+
`${b[groupBy]}`, undefined, {
|
|
75
|
+
numeric: true,
|
|
76
|
+
sensitivity: 'base',
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
if (rowGrouping !== 0) {
|
|
80
|
+
return rowGrouping;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (sortOrder === 'asc') {
|
|
85
|
+
return alphaNumericSort(a, b);
|
|
86
|
+
}
|
|
87
|
+
return alphaNumericSort(b, a);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return groupingIndex(sorted);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const arraySort = (a, b) => {
|
|
94
|
+
// handles sort for the column with the array value
|
|
95
|
+
const aHasData = a[sortBy] && a[sortBy].length > 0;
|
|
96
|
+
const bHasData = b[sortBy] && b[sortBy].length > 0;
|
|
97
|
+
return aHasData === bHasData ? 0 : aHasData ? -1 : 1;
|
|
98
|
+
};
|
|
99
|
+
|
|
48
100
|
/**
|
|
49
101
|
* sort base on table state
|
|
50
102
|
*/
|
|
@@ -62,7 +114,11 @@ const TableController = ((props) => {
|
|
|
62
114
|
}
|
|
63
115
|
return alphaNumericSort(b, a);
|
|
64
116
|
};
|
|
65
|
-
|
|
117
|
+
|
|
118
|
+
// sort based on row grouping
|
|
119
|
+
// groupBy column name
|
|
120
|
+
const sortedRows = (groupBy) ? sortWithRowGrouping(updateRows)
|
|
121
|
+
: [...updateRows].sort((a, b) => sortRows(a, b));
|
|
66
122
|
const startIndex = page * rowsPerPage;
|
|
67
123
|
const endIndex = startIndex + rowsPerPage;
|
|
68
124
|
const displayRows = [...sortedRows].slice(startIndex, endIndex);
|