@bento-core/paginated-table 1.0.1-icdc.2 → 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.
- package/Add_ALL_Files__BLUE_ButtonREADME.md +124 -0
- package/Add_Selected_Files_Orange_button_README.md +121 -0
- package/Column_Grouping_README.md +65 -0
- package/README.md +10 -4
- package/dist/table/ClientController.js +72 -2
- package/dist/table/PaginatedTable.js +40 -1
- package/dist/table/TableService.js +5 -2
- package/dist/table/state/Actions.js +15 -3
- package/dist/table/state/Reducer.js +10 -0
- package/dist/wrapper/components/AddAllFiles/AddAllView.js +2 -1
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +14 -4
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +4 -2
- package/dist/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/dist/wrapper/components/TooltipView.js +3 -2
- package/package.json +10 -19
- package/src/table/ClientController.js +73 -1
- package/src/table/PaginatedTable.js +46 -1
- package/src/table/TableService.js +5 -2
- package/src/table/state/Actions.js +12 -0
- package/src/table/state/Reducer.js +12 -0
- package/src/wrapper/components/AddAllFiles/AddAllView.js +1 -0
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +7 -0
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +2 -0
- package/src/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/src/wrapper/components/TooltipView.js +2 -1
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
|
|
2
|
+
### 1 Use latest or bento-core/paginated-table package version publish by ICDC
|
|
3
|
+
Alternative configuratoin for BLUE button
|
|
4
|
+
```
|
|
5
|
+
// 1.0.1-icdc.3
|
|
6
|
+
npm i @bento-core/paginated-table@1.0.1-icdc.3
|
|
7
|
+
|
|
8
|
+
or in package.json
|
|
9
|
+
{
|
|
10
|
+
@bento-core/paginated-table: '1.0.1-icdc.3'
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
**NOTE: Create a new dashboard page using bento-core components before removing old dashboard page**
|
|
14
|
+
<br>
|
|
15
|
+
<span style="color:yellow">
|
|
16
|
+
Assuming New Dashboard page have Filter component and table component from bento-core
|
|
17
|
+
</span>.
|
|
18
|
+
|
|
19
|
+
### 2 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
import React, { useCallback } from 'react';
|
|
23
|
+
import { ButtonView, btnTypes, TableContextProvider } from '@bento-core/paginated-table';
|
|
24
|
+
|
|
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
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Add All Button Component or Configuration Properties**
|
|
45
|
+
| Component Props | Required | description | Configuration |
|
|
46
|
+
| :--- | :----:| :----: | ----: |
|
|
47
|
+
| btnType | TRUE | Determines the role of the button, add all files (blue) or add selected files (orange) | btnTypes.ADD_ALL_FILES, btnTypes.ADD_SELECTED_FILES or btnTypes.DOWNLOAD_MANIFEST |
|
|
48
|
+
| title | TRUE | text for the button | 'Add all files' |
|
|
49
|
+
| clsName | TRUE | configure theme with themeprovider | |
|
|
50
|
+
| maxFileLimit | FALSE | limits no of files that can be added to myCart | 0 - 10000 (by default 1000) |
|
|
51
|
+
| addFileQuery | TRUE | query to retrive files or file ids | graphQL query |
|
|
52
|
+
| responseKeys | TRUE | Keys to access file_ids reponse provided by addFileQuery, provided as list to access the nested respose object or list (max depth upto 2) | ['caseOverview', 'files'] |
|
|
53
|
+
| section | TRUE | This key is used for accessing the tootip text provided in tooltipCofig | section="toolTipText" |
|
|
54
|
+
| classes | TRUE | provide class for toltips to override the style | tooltip: classes.customTooltip, arrow: classes.customArrow
|
|
55
|
+
| tooltipCofig | FALSE | displays tooltip if provided, configuration for arrow, clsName, icon, tooltipText | graphQL query |
|
|
56
|
+
| activeFilters | TRUE | filtes the case or sample based on the active filters | graphQL query |
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### 3 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
const customTheme = {
|
|
63
|
+
MuiContainer: {
|
|
64
|
+
root: {
|
|
65
|
+
'& img': {
|
|
66
|
+
width: '17px',
|
|
67
|
+
'&.addAllTooltip': {
|
|
68
|
+
verticalAlign: 'top',
|
|
69
|
+
marginTop: '8px',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const btnTheme = createTheme({ overrides: { ...customTheme } });
|
|
77
|
+
<ThemeProvider theme={btnTheme}>
|
|
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
|
+
/>
|
|
113
|
+
</Container>
|
|
114
|
+
</ThemeProvider>
|
|
115
|
+
|
|
116
|
+
<Grid container>
|
|
117
|
+
<Grid item xs={12} id={config.tableID}>
|
|
118
|
+
<TableView
|
|
119
|
+
initState={initTblState}
|
|
120
|
+
...
|
|
121
|
+
/>
|
|
122
|
+
</Grid>
|
|
123
|
+
</Grid>
|
|
124
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
|
|
2
|
+
### 1 Use latest or bento-core/paginated-table package version publish by ICDC
|
|
3
|
+
Alternative configuration for ORANGE button
|
|
4
|
+
```
|
|
5
|
+
// 1.0.1-icdc.3
|
|
6
|
+
npm i @bento-core/paginated-table@1.0.1-icdc.3
|
|
7
|
+
|
|
8
|
+
or in package.json
|
|
9
|
+
{
|
|
10
|
+
@bento-core/paginated-table: '1.0.1-icdc.3'
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
<span style="color:yellow">
|
|
15
|
+
Assuming table component is imported from bento-core/paginated-table
|
|
16
|
+
</span>
|
|
17
|
+
|
|
18
|
+
### 2 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
import React, { useCallback } from 'react';
|
|
22
|
+
import { ButtonView, btnTypes } from '@bento-core/paginated-table';
|
|
23
|
+
|
|
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
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Add All Button Component or Configuration Properties**
|
|
42
|
+
| Component Props | Required | description | Configuration |
|
|
43
|
+
| :--- | :----:| :----: | ----: |
|
|
44
|
+
| btnType | TRUE | Determines the role of the button, add all files (blue) or add selected files (orange) | btnTypes.ADD_ALL_FILES, btnTypes.ADD_SELECTED_FILES or btnTypes.DOWNLOAD_MANIFEST |
|
|
45
|
+
| title | TRUE | text for the button | 'Add Selected files' |
|
|
46
|
+
| clsName | TRUE | configure theme with themeprovider | |
|
|
47
|
+
| addFileQuery | TRUE | query to retrive files or file ids | graphQL query |
|
|
48
|
+
| responseKeys | TRUE | Keys to access file_ids reponse provided by addFileQuery, provided as list to access the nested respose object or list (max depth upto 2) | ['caseOverview', 'files'] |
|
|
49
|
+
| classes | TRUE | provide class for toltips to override the style | tooltip: classes.customTooltip, arrow: classes.customArrow
|
|
50
|
+
| tooltipCofig | FALSE | displays tooltip if provided, configuration for arrow, clsName, icon, tooltipText | graphQL query |
|
|
51
|
+
| dataKey | TRUE | Attribute used for getting selected rows in a table | case_id, file_name or any other column with distinct values |
|
|
52
|
+
| applyActiveFilter | FALSE | Only adds files of selected case or sample based on active filter | Bool |
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### 3 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
const customTheme = {
|
|
60
|
+
MuiContainer: {
|
|
61
|
+
root: {
|
|
62
|
+
'& img': {
|
|
63
|
+
width: '17px',
|
|
64
|
+
'&.addAllTooltip': {
|
|
65
|
+
verticalAlign: 'top',
|
|
66
|
+
marginTop: '8px',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const btnTheme = createTheme({ overrides: { ...customTheme } });
|
|
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
|
+
/>
|
|
110
|
+
</Container>
|
|
111
|
+
</ThemeProvider>
|
|
112
|
+
|
|
113
|
+
<Grid container>
|
|
114
|
+
<Grid item xs={12} id={config.tableID}>
|
|
115
|
+
<TableView
|
|
116
|
+
initState={initTblState}
|
|
117
|
+
...
|
|
118
|
+
/>
|
|
119
|
+
</Grid>
|
|
120
|
+
</Grid>
|
|
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
|
+
```
|
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# PAGINATED TABLE COMPONENT DESIGN
|
|
2
2
|
|
|
3
|
+
```diff
|
|
4
|
+
- After updating to latest version remove transform: 'rotateX(180deg)) in red
|
|
5
|
+
```
|
|
3
6
|
### Bento core paginated table design:
|
|
4
7
|
|
|
5
8
|
* Use of UseReducer to track table state and local state to display dialog component
|
|
@@ -228,6 +231,9 @@ TableContextProvider provides table state to Wrapper Component or it can be used
|
|
|
228
231
|
####
|
|
229
232
|
|
|
230
233
|
## 4 Wrapper Configuration:
|
|
234
|
+
|
|
235
|
+
**NOTE: Alternative option to configure Blue and Orange button refer to [ADD_ALL_FILES_BLUE_BUTTON_ReadME](Add_ALL_Files__BLUE_ButtonREADME.md) and [ADD_SELECTED_FILES_Orange_button_ReadMe](Add_Selected_Files_Orange_button_README.md). (Note: No Wrapper conponent required)**
|
|
236
|
+
|
|
231
237
|
Wrapper component around table compnent.
|
|
232
238
|
1. ADD ALL FILES button
|
|
233
239
|
2. ADD SELECTED ROWS button
|
|
@@ -319,8 +325,8 @@ headerConfig - upper component on the table
|
|
|
319
325
|
|
|
320
326
|
####
|
|
321
327
|
|
|
322
|
-
## 5 Pagination
|
|
323
|
-
|
|
328
|
+
## 5 Customize Pagination Action:
|
|
329
|
+
Customize paginated action is provided to add event in addition to update of the table state. It will override default paginated action.
|
|
324
330
|
```
|
|
325
331
|
import {
|
|
326
332
|
TableContext,
|
|
@@ -339,7 +345,7 @@ import {
|
|
|
339
345
|
const { context } = tableContext;
|
|
340
346
|
const { dispatch } = context;
|
|
341
347
|
|
|
342
|
-
const
|
|
348
|
+
const customPaginationOptions = {
|
|
343
349
|
customizeOnRowSelect: (event, row) => {
|
|
344
350
|
const payload = {
|
|
345
351
|
page: 2,
|
|
@@ -362,7 +368,7 @@ import {
|
|
|
362
368
|
queryVariables={activeFilters}
|
|
363
369
|
totalRowCount={dashboardStats[config.count]}
|
|
364
370
|
activeTab={activeTab}
|
|
365
|
-
paginationOptions={
|
|
371
|
+
paginationOptions={customPaginationOptions}
|
|
366
372
|
/>
|
|
367
373
|
```
|
|
368
374
|
|
|
@@ -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,7 +37,8 @@ const TableController = props => {
|
|
|
32
37
|
page = 0,
|
|
33
38
|
rowsPerPage = 10,
|
|
34
39
|
sortBy,
|
|
35
|
-
sortOrder
|
|
40
|
+
sortOrder,
|
|
41
|
+
groupBy
|
|
36
42
|
} = table;
|
|
37
43
|
|
|
38
44
|
/**
|
|
@@ -43,16 +49,80 @@ const TableController = props => {
|
|
|
43
49
|
numeric: true,
|
|
44
50
|
sensitivity: 'base'
|
|
45
51
|
});
|
|
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
|
+
|
|
46
106
|
/**
|
|
47
107
|
* sort base on table state
|
|
48
108
|
*/
|
|
49
109
|
const sortRows = (a, b) => {
|
|
110
|
+
const areValuesArrays = Array.isArray(a[sortBy]) && Array.isArray(b[sortBy]);
|
|
111
|
+
if (areValuesArrays) {
|
|
112
|
+
if (sortOrder === 'asc') {
|
|
113
|
+
return arraySort(a, b);
|
|
114
|
+
}
|
|
115
|
+
return arraySort(b, a);
|
|
116
|
+
}
|
|
50
117
|
if (sortOrder === 'asc') {
|
|
51
118
|
return alphaNumericSort(a, b);
|
|
52
119
|
}
|
|
53
120
|
return alphaNumericSort(b, a);
|
|
54
121
|
};
|
|
55
|
-
|
|
122
|
+
|
|
123
|
+
// sort based on row grouping
|
|
124
|
+
// groupBy column name
|
|
125
|
+
const sortedRows = groupBy ? sortWithRowGrouping(updateRows) : [...updateRows].sort((a, b) => sortRows(a, b));
|
|
56
126
|
const startIndex = page * rowsPerPage;
|
|
57
127
|
const endIndex = startIndex + rowsPerPage;
|
|
58
128
|
const displayRows = [...sortedRows].slice(startIndex, endIndex);
|
|
@@ -97,7 +97,9 @@ const PaginatedTable = _ref => {
|
|
|
97
97
|
customizeSortByColumn,
|
|
98
98
|
customizeChangePage,
|
|
99
99
|
customizeChangeRowsPerPage,
|
|
100
|
-
customizeColumnViewChange
|
|
100
|
+
customizeColumnViewChange,
|
|
101
|
+
customizeDeleteRow,
|
|
102
|
+
customizeDeleteAllRows
|
|
101
103
|
} = paginationOptions;
|
|
102
104
|
|
|
103
105
|
/**
|
|
@@ -157,6 +159,39 @@ const PaginatedTable = _ref => {
|
|
|
157
159
|
columns
|
|
158
160
|
})));
|
|
159
161
|
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* handle delete row from table
|
|
165
|
+
* remove selected rows
|
|
166
|
+
*/
|
|
167
|
+
const onDeleteRow = row => {
|
|
168
|
+
let selectedIds = table.selectedRows;
|
|
169
|
+
// if del row is selected remove from selected rows
|
|
170
|
+
if (row.isChecked) {
|
|
171
|
+
const delId = row[table.dataKey];
|
|
172
|
+
selectedIds = table.selectedRows.reduce((acc, id) => {
|
|
173
|
+
if (delId !== id) {
|
|
174
|
+
acc.push(id);
|
|
175
|
+
}
|
|
176
|
+
return acc;
|
|
177
|
+
}, []);
|
|
178
|
+
}
|
|
179
|
+
dispatch((0, _Actions.onRowDelete)({
|
|
180
|
+
deletedRow: row,
|
|
181
|
+
selectedRows: selectedIds
|
|
182
|
+
}));
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* clear selected rows when all files are removed from myCart/ My file
|
|
187
|
+
*/
|
|
188
|
+
const onDeleteAllRows = () => {
|
|
189
|
+
dispatch((0, _Actions.onClearCart)({
|
|
190
|
+
deletedRows: table.selectedRows,
|
|
191
|
+
selectedRows: []
|
|
192
|
+
}));
|
|
193
|
+
};
|
|
194
|
+
|
|
160
195
|
/**
|
|
161
196
|
* A. client table
|
|
162
197
|
* table data provide by bento app (tblRows)
|
|
@@ -172,6 +207,8 @@ const PaginatedTable = _ref => {
|
|
|
172
207
|
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
173
208
|
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
174
209
|
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
210
|
+
onDeleteRow: customizeDeleteRow || onDeleteRow,
|
|
211
|
+
onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
|
|
175
212
|
themeConfig: themeConfig
|
|
176
213
|
}));
|
|
177
214
|
}
|
|
@@ -197,6 +234,8 @@ const PaginatedTable = _ref => {
|
|
|
197
234
|
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
198
235
|
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
199
236
|
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
237
|
+
onDeleteRow: customizeDeleteRow || onDeleteRow,
|
|
238
|
+
onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
|
|
200
239
|
themeConfig: themeConfig
|
|
201
240
|
}));
|
|
202
241
|
};
|
|
@@ -22,10 +22,13 @@ const setSelectedRows = function setSelectedRows() {
|
|
|
22
22
|
let table = arguments.length > 1 ? arguments[1] : undefined;
|
|
23
23
|
const {
|
|
24
24
|
selectedRows,
|
|
25
|
-
dataKey
|
|
25
|
+
dataKey,
|
|
26
|
+
deletedRow
|
|
26
27
|
} = table;
|
|
28
|
+
// checked selected row if deleted
|
|
29
|
+
const checkedRows = deletedRow !== null && deletedRow !== void 0 && deletedRow.isChecked ? [...selectedRows, deletedRow[dataKey]] : selectedRows;
|
|
27
30
|
const updateRows = [...rows].map(row => {
|
|
28
|
-
const isChecked = dataKey ?
|
|
31
|
+
const isChecked = dataKey ? checkedRows.indexOf(row[dataKey]) !== -1 : false;
|
|
29
32
|
return _objectSpread(_objectSpread({}, row), {}, {
|
|
30
33
|
isChecked
|
|
31
34
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSeclect = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onChangeSortDirection = exports.customPaginationAction = exports.actionTypes = void 0;
|
|
6
|
+
exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSeclect = exports.onRowDelete = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onClearCart = exports.onChangeSortDirection = exports.customPaginationAction = exports.actionTypes = void 0;
|
|
7
7
|
const actionTypes = {
|
|
8
8
|
VIEW_COLUMN_CHANGE: 'VIEW_COLUMN_CHANGE',
|
|
9
9
|
ON_COLUMN_SORT: 'ON_COLUMN_SORT',
|
|
@@ -13,7 +13,9 @@ const actionTypes = {
|
|
|
13
13
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
14
14
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
15
15
|
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
|
|
16
|
-
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION'
|
|
16
|
+
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
|
|
17
|
+
ON_ROWS_DELETE: 'ON_ROWS_DELETE',
|
|
18
|
+
ON_ROW_DELETE: 'ON_ROW_DELETE'
|
|
17
19
|
};
|
|
18
20
|
exports.actionTypes = actionTypes;
|
|
19
21
|
const onColumnViewChange = columns => ({
|
|
@@ -60,4 +62,14 @@ const customPaginationAction = value => ({
|
|
|
60
62
|
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
61
63
|
payload: value
|
|
62
64
|
});
|
|
63
|
-
exports.customPaginationAction = customPaginationAction;
|
|
65
|
+
exports.customPaginationAction = customPaginationAction;
|
|
66
|
+
const onClearCart = value => ({
|
|
67
|
+
type: actionTypes.ON_ROWS_DELETE,
|
|
68
|
+
payload: value
|
|
69
|
+
});
|
|
70
|
+
exports.onClearCart = onClearCart;
|
|
71
|
+
const onRowDelete = value => ({
|
|
72
|
+
type: actionTypes.ON_ROW_DELETE,
|
|
73
|
+
payload: value
|
|
74
|
+
});
|
|
75
|
+
exports.onRowDelete = onRowDelete;
|
|
@@ -47,6 +47,16 @@ const reducer = (state, action) => {
|
|
|
47
47
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
48
48
|
totalRowCount: payload
|
|
49
49
|
});
|
|
50
|
+
case _Actions.actionTypes.ON_ROW_DELETE:
|
|
51
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
52
|
+
deletedRow: payload.deletedRow,
|
|
53
|
+
selectedRows: payload.selectedRows
|
|
54
|
+
});
|
|
55
|
+
case _Actions.actionTypes.ON_ROWS_DELETE:
|
|
56
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
57
|
+
deletedRows: payload.deleteRows,
|
|
58
|
+
selectedRows: payload.selectedRows
|
|
59
|
+
});
|
|
50
60
|
default:
|
|
51
61
|
return state;
|
|
52
62
|
}
|
|
@@ -79,7 +79,8 @@ const AddAllFilesComponent = props => {
|
|
|
79
79
|
open: openAddDialog,
|
|
80
80
|
onYesClick: addFilesToCart,
|
|
81
81
|
onNoClick: toggleOpen,
|
|
82
|
-
DisplayCustomText: DisplayCustomText
|
|
82
|
+
DisplayCustomText: DisplayCustomText,
|
|
83
|
+
activeFilters: activeFilters
|
|
83
84
|
}));
|
|
84
85
|
};
|
|
85
86
|
var _default = AddAllFilesComponent;
|
|
@@ -17,6 +17,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
24
|
+
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); }
|
|
20
25
|
const AddSelectedFilesController = props => {
|
|
21
26
|
const {
|
|
22
27
|
clsName,
|
|
@@ -28,7 +33,9 @@ const AddSelectedFilesController = props => {
|
|
|
28
33
|
setOpenSnackbar,
|
|
29
34
|
setAlterDisplay,
|
|
30
35
|
client,
|
|
31
|
-
maxFileLimit = 1000
|
|
36
|
+
maxFileLimit = 1000,
|
|
37
|
+
applyActiveFilter = false,
|
|
38
|
+
activeFilters = {}
|
|
32
39
|
} = props;
|
|
33
40
|
const tableContext = (0, _react.useContext)(_ContextProvider.TableContext);
|
|
34
41
|
const {
|
|
@@ -38,10 +45,13 @@ const AddSelectedFilesController = props => {
|
|
|
38
45
|
selectedRows = [],
|
|
39
46
|
dispatch
|
|
40
47
|
} = context;
|
|
41
|
-
const
|
|
42
|
-
|
|
48
|
+
const activeFilterItems = applyActiveFilter ? activeFilters : {};
|
|
49
|
+
const variables = _objectSpread(_objectSpread({
|
|
50
|
+
first: 10000
|
|
51
|
+
}, activeFilterItems), {}, {
|
|
43
52
|
[dataKey]: selectedRows
|
|
44
|
-
};
|
|
53
|
+
});
|
|
54
|
+
|
|
45
55
|
// add selected files id
|
|
46
56
|
const addSelectedFiles = () => {
|
|
47
57
|
const fileIds = (0, _WrapperService.getFilesID)({
|
|
@@ -16,7 +16,8 @@ function AddToCartDialogView(props) {
|
|
|
16
16
|
onNoClick,
|
|
17
17
|
cartWillFull = false,
|
|
18
18
|
alertMessage,
|
|
19
|
-
DisplayCustomText
|
|
19
|
+
DisplayCustomText,
|
|
20
|
+
activeFilters
|
|
20
21
|
} = props;
|
|
21
22
|
if (cartWillFull) {
|
|
22
23
|
return /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
|
|
@@ -31,7 +32,8 @@ function AddToCartDialogView(props) {
|
|
|
31
32
|
"aria-describedby": "alert-dialog-description"
|
|
32
33
|
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, DisplayCustomText ? /*#__PURE__*/_react.default.createElement(DisplayCustomText, {
|
|
33
34
|
onYesClick: onYesClick,
|
|
34
|
-
onNoClick: onNoClick
|
|
35
|
+
onNoClick: onNoClick,
|
|
36
|
+
activeFilters: activeFilters
|
|
35
37
|
}) : /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
|
|
36
38
|
id: "alert-dialog-description"
|
|
37
39
|
}, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, {
|
|
@@ -33,7 +33,7 @@ const SnackbarView = props => {
|
|
|
33
33
|
className: "snackBarMessageIcon"
|
|
34
34
|
}, /*#__PURE__*/_react.default.createElement(_SuccessOutlined.default, null), ' '), /*#__PURE__*/_react.default.createElement("span", {
|
|
35
35
|
className: "snackBarText"
|
|
36
|
-
}, count, ' ', "File(s) successfully added to
|
|
36
|
+
}, count, ' ', "File(s) successfully added to My Files."))
|
|
37
37
|
}));
|
|
38
38
|
};
|
|
39
39
|
var _default = SnackbarView;
|
|
@@ -21,10 +21,11 @@ const ToolTipView = props => {
|
|
|
21
21
|
icon,
|
|
22
22
|
alt,
|
|
23
23
|
arrow = false,
|
|
24
|
-
clsName
|
|
24
|
+
clsName,
|
|
25
|
+
toolTipText
|
|
25
26
|
} = tooltipCofig;
|
|
26
27
|
return /*#__PURE__*/_react.default.createElement(_toolTip.default, {
|
|
27
|
-
title: tooltipCofig[section],
|
|
28
|
+
title: toolTipText || tooltipCofig[section],
|
|
28
29
|
arrow: arrow,
|
|
29
30
|
classes: {
|
|
30
31
|
tooltip: classes.customTooltip,
|
package/package.json
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/paginated-table",
|
|
3
|
-
"version": "1.0.1-icdc.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1-icdc.20",
|
|
4
|
+
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
9
|
"lint": "eslint src"
|
|
10
10
|
},
|
|
11
|
-
"repository":
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/CBIIT/bento-frontend.git"
|
|
14
|
-
},
|
|
11
|
+
"repository": "https://github.com/CBIIT/bento-frontend",
|
|
15
12
|
"publishConfig": {
|
|
16
|
-
"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@bento-core/cart": "^1.0.0",
|
|
20
|
-
"@bento-core/table": "^1.0.0",
|
|
21
|
-
"@bento-core/tool-tip": "^1.0.0",
|
|
22
|
-
"@bento-core/util": "^1.0.0"
|
|
13
|
+
"access": "public"
|
|
23
14
|
},
|
|
24
15
|
"peerDependencies": {
|
|
25
16
|
"@apollo/client": "^3.6.9",
|
|
@@ -27,12 +18,12 @@
|
|
|
27
18
|
"clsx": "^1.2.1",
|
|
28
19
|
"react": "^17.0.2",
|
|
29
20
|
"react-dom": "^17.0.0",
|
|
30
|
-
"react-redux": "^7.2.1"
|
|
21
|
+
"react-redux": "^7.2.1",
|
|
22
|
+
"@bento-core/cart": "^1.0.0",
|
|
23
|
+
"@bento-core/table": "1.0.1-icdc.0",
|
|
24
|
+
"@bento-core/tool-tip": "^1.0.0",
|
|
25
|
+
"@bento-core/util": "^1.0.0"
|
|
31
26
|
},
|
|
32
27
|
"author": "CTOS Bento Team",
|
|
33
|
-
"license": "ISC"
|
|
34
|
-
"bugs": {
|
|
35
|
-
"url": "https://github.com/CBIIT/bento-frontend/issues"
|
|
36
|
-
},
|
|
37
|
-
"homepage": "https://github.com/CBIIT/bento-frontend#readme"
|
|
28
|
+
"license": "ISC"
|
|
38
29
|
}
|
|
@@ -25,6 +25,7 @@ const TableController = ((props) => {
|
|
|
25
25
|
rowsPerPage = 10,
|
|
26
26
|
sortBy,
|
|
27
27
|
sortOrder,
|
|
28
|
+
groupBy,
|
|
28
29
|
} = table;
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -37,16 +38,87 @@ const TableController = ((props) => {
|
|
|
37
38
|
sensitivity: 'base',
|
|
38
39
|
},
|
|
39
40
|
);
|
|
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
|
+
|
|
40
100
|
/**
|
|
41
101
|
* sort base on table state
|
|
42
102
|
*/
|
|
43
103
|
const sortRows = (a, b) => {
|
|
104
|
+
const areValuesArrays = Array.isArray(a[sortBy]) && Array.isArray(b[sortBy]);
|
|
105
|
+
if (areValuesArrays) {
|
|
106
|
+
if (sortOrder === 'asc') {
|
|
107
|
+
return arraySort(a, b);
|
|
108
|
+
}
|
|
109
|
+
return arraySort(b, a);
|
|
110
|
+
}
|
|
111
|
+
|
|
44
112
|
if (sortOrder === 'asc') {
|
|
45
113
|
return alphaNumericSort(a, b);
|
|
46
114
|
}
|
|
47
115
|
return alphaNumericSort(b, a);
|
|
48
116
|
};
|
|
49
|
-
|
|
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));
|
|
50
122
|
const startIndex = page * rowsPerPage;
|
|
51
123
|
const endIndex = startIndex + rowsPerPage;
|
|
52
124
|
const displayRows = [...sortedRows].slice(startIndex, endIndex);
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useContext,
|
|
3
|
+
useEffect,
|
|
4
|
+
useReducer,
|
|
5
|
+
} from 'react';
|
|
2
6
|
import ServerTableView from './ServerController';
|
|
3
7
|
import ClientTableView from './ClientController';
|
|
4
8
|
import {
|
|
@@ -9,6 +13,8 @@ import {
|
|
|
9
13
|
onColumnSort,
|
|
10
14
|
onPageAndTotalCountChange,
|
|
11
15
|
onColumnViewChange,
|
|
16
|
+
onRowDelete,
|
|
17
|
+
onClearCart,
|
|
12
18
|
} from './state/Actions';
|
|
13
19
|
import { TableContext } from './ContextProvider';
|
|
14
20
|
import reducer from './state/Reducer';
|
|
@@ -83,6 +89,8 @@ const PaginatedTable = ({
|
|
|
83
89
|
customizeChangePage,
|
|
84
90
|
customizeChangeRowsPerPage,
|
|
85
91
|
customizeColumnViewChange,
|
|
92
|
+
customizeDeleteRow,
|
|
93
|
+
customizeDeleteAllRows,
|
|
86
94
|
} = paginationOptions;
|
|
87
95
|
|
|
88
96
|
/**
|
|
@@ -140,6 +148,39 @@ const PaginatedTable = ({
|
|
|
140
148
|
columns,
|
|
141
149
|
}));
|
|
142
150
|
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* handle delete row from table
|
|
154
|
+
* remove selected rows
|
|
155
|
+
*/
|
|
156
|
+
const onDeleteRow = (row) => {
|
|
157
|
+
let selectedIds = table.selectedRows;
|
|
158
|
+
// if del row is selected remove from selected rows
|
|
159
|
+
if (row.isChecked) {
|
|
160
|
+
const delId = row[table.dataKey];
|
|
161
|
+
selectedIds = table.selectedRows.reduce((acc, id) => {
|
|
162
|
+
if (delId !== id) {
|
|
163
|
+
acc.push(id);
|
|
164
|
+
}
|
|
165
|
+
return acc;
|
|
166
|
+
}, []);
|
|
167
|
+
}
|
|
168
|
+
dispatch(onRowDelete({
|
|
169
|
+
deletedRow: row,
|
|
170
|
+
selectedRows: selectedIds,
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* clear selected rows when all files are removed from myCart/ My file
|
|
176
|
+
*/
|
|
177
|
+
const onDeleteAllRows = () => {
|
|
178
|
+
dispatch(onClearCart({
|
|
179
|
+
deletedRows: table.selectedRows,
|
|
180
|
+
selectedRows: [],
|
|
181
|
+
}));
|
|
182
|
+
};
|
|
183
|
+
|
|
143
184
|
/**
|
|
144
185
|
* A. client table
|
|
145
186
|
* table data provide by bento app (tblRows)
|
|
@@ -157,6 +198,8 @@ const PaginatedTable = ({
|
|
|
157
198
|
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
158
199
|
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
159
200
|
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
201
|
+
onDeleteRow={customizeDeleteRow || onDeleteRow}
|
|
202
|
+
onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
|
|
160
203
|
themeConfig={themeConfig}
|
|
161
204
|
/>
|
|
162
205
|
</>
|
|
@@ -187,6 +230,8 @@ const PaginatedTable = ({
|
|
|
187
230
|
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
188
231
|
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
189
232
|
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
233
|
+
onDeleteRow={customizeDeleteRow || onDeleteRow}
|
|
234
|
+
onDeleteAllFiles={customizeDeleteAllRows || onDeleteAllRows}
|
|
190
235
|
themeConfig={themeConfig}
|
|
191
236
|
/>
|
|
192
237
|
</>
|
|
@@ -8,10 +8,13 @@ import { useEffect, useState } from 'react';
|
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
10
|
export const setSelectedRows = (rows = [], table) => {
|
|
11
|
-
const { selectedRows, dataKey } = table;
|
|
11
|
+
const { selectedRows, dataKey, deletedRow } = table;
|
|
12
|
+
// checked selected row if deleted
|
|
13
|
+
const checkedRows = deletedRow?.isChecked
|
|
14
|
+
? [...selectedRows, deletedRow[dataKey]] : selectedRows;
|
|
12
15
|
const updateRows = [...rows].map((row) => {
|
|
13
16
|
const isChecked = dataKey
|
|
14
|
-
? (
|
|
17
|
+
? (checkedRows.indexOf(row[dataKey]) !== -1) : false;
|
|
15
18
|
return { ...row, isChecked };
|
|
16
19
|
}, []);
|
|
17
20
|
return updateRows;
|
|
@@ -8,6 +8,8 @@ export const actionTypes = {
|
|
|
8
8
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
9
9
|
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
|
|
10
10
|
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
|
|
11
|
+
ON_ROWS_DELETE: 'ON_ROWS_DELETE',
|
|
12
|
+
ON_ROW_DELETE: 'ON_ROW_DELETE',
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export const onColumnViewChange = (columns) => ({
|
|
@@ -54,3 +56,13 @@ export const customPaginationAction = (value) => ({
|
|
|
54
56
|
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
55
57
|
payload: value,
|
|
56
58
|
});
|
|
59
|
+
|
|
60
|
+
export const onClearCart = (value) => ({
|
|
61
|
+
type: actionTypes.ON_ROWS_DELETE,
|
|
62
|
+
payload: value,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export const onRowDelete = (value) => ({
|
|
66
|
+
type: actionTypes.ON_ROW_DELETE,
|
|
67
|
+
payload: value,
|
|
68
|
+
});
|
|
@@ -46,6 +46,18 @@ const reducer = (state, action) => {
|
|
|
46
46
|
...state,
|
|
47
47
|
totalRowCount: payload,
|
|
48
48
|
};
|
|
49
|
+
case actionTypes.ON_ROW_DELETE:
|
|
50
|
+
return {
|
|
51
|
+
...state,
|
|
52
|
+
deletedRow: payload.deletedRow,
|
|
53
|
+
selectedRows: payload.selectedRows,
|
|
54
|
+
};
|
|
55
|
+
case actionTypes.ON_ROWS_DELETE:
|
|
56
|
+
return {
|
|
57
|
+
...state,
|
|
58
|
+
deletedRows: payload.deleteRows,
|
|
59
|
+
selectedRows: payload.selectedRows,
|
|
60
|
+
};
|
|
49
61
|
default:
|
|
50
62
|
return state;
|
|
51
63
|
}
|
|
@@ -20,6 +20,8 @@ const AddSelectedFilesController = (props) => {
|
|
|
20
20
|
setAlterDisplay,
|
|
21
21
|
client,
|
|
22
22
|
maxFileLimit = 1000,
|
|
23
|
+
applyActiveFilter = false,
|
|
24
|
+
activeFilters = {},
|
|
23
25
|
} = props;
|
|
24
26
|
|
|
25
27
|
const tableContext = useContext(TableContext);
|
|
@@ -28,10 +30,15 @@ const AddSelectedFilesController = (props) => {
|
|
|
28
30
|
selectedRows = [],
|
|
29
31
|
dispatch,
|
|
30
32
|
} = context;
|
|
33
|
+
|
|
34
|
+
const activeFilterItems = applyActiveFilter ? activeFilters : {};
|
|
35
|
+
|
|
31
36
|
const variables = {
|
|
32
37
|
first: 10000,
|
|
38
|
+
...activeFilterItems,
|
|
33
39
|
[dataKey]: selectedRows,
|
|
34
40
|
};
|
|
41
|
+
|
|
35
42
|
// add selected files id
|
|
36
43
|
const addSelectedFiles = () => {
|
|
37
44
|
const fileIds = getFilesID({
|
|
@@ -13,6 +13,7 @@ function AddToCartDialogView(props) {
|
|
|
13
13
|
cartWillFull = false,
|
|
14
14
|
alertMessage,
|
|
15
15
|
DisplayCustomText,
|
|
16
|
+
activeFilters,
|
|
16
17
|
} = props;
|
|
17
18
|
|
|
18
19
|
if (cartWillFull) {
|
|
@@ -38,6 +39,7 @@ function AddToCartDialogView(props) {
|
|
|
38
39
|
<DisplayCustomText
|
|
39
40
|
onYesClick={onYesClick}
|
|
40
41
|
onNoClick={onNoClick}
|
|
42
|
+
activeFilters={activeFilters}
|
|
41
43
|
/>
|
|
42
44
|
) : (
|
|
43
45
|
<DialogContentText id="alert-dialog-description">
|
|
@@ -17,10 +17,11 @@ const ToolTipView = (props) => {
|
|
|
17
17
|
alt,
|
|
18
18
|
arrow = false,
|
|
19
19
|
clsName,
|
|
20
|
+
toolTipText,
|
|
20
21
|
} = tooltipCofig;
|
|
21
22
|
return (
|
|
22
23
|
<ToolTip
|
|
23
|
-
title={tooltipCofig[section]}
|
|
24
|
+
title={toolTipText || tooltipCofig[section]}
|
|
24
25
|
arrow={arrow}
|
|
25
26
|
classes={{
|
|
26
27
|
tooltip: classes.customTooltip,
|