@bento-core/paginated-table 1.0.1-CDS.0 → 1.0.1-CDS.2
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 +86 -0
- package/Add_Selected_Files_Orange_button_README.md +81 -0
- package/{dist/table/README.md → README.md} +124 -3
- package/dist/index.js +13 -0
- package/dist/table/ClientController.js +1 -0
- package/dist/table/PaginatedTable.js +64 -14
- package/dist/table/TableService.js +5 -2
- package/dist/table/state/Actions.js +21 -3
- package/dist/table/state/Reducer.js +12 -0
- package/dist/wrapper/WrapperService.js +1 -1
- package/dist/wrapper/components/AddAllFiles/AddAllView.js +17 -13
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +24 -5
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -0
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +11 -3
- package/dist/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/dist/wrapper/components/util.js +33 -0
- package/package.json +3 -3
- package/src/index.js +4 -0
- package/src/table/ClientController.js +1 -0
- package/src/table/PaginatedTable.js +70 -14
- package/src/table/TableService.js +5 -2
- package/src/table/state/Actions.js +18 -0
- package/src/table/state/Reducer.js +17 -0
- package/src/wrapper/WrapperService.js +1 -1
- package/src/wrapper/components/AddAllFiles/AddAllView.js +16 -10
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +20 -4
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -1
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +20 -8
- package/src/wrapper/components/Snackbar/Snackbar.js +1 -1
- package/src/wrapper/components/util.js +26 -0
- package/src/table/README.md +0 -253
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
### 1 Use 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:red">
|
|
16
|
+
Assuming New Dashboard page have Filter component and table component from bento-core
|
|
17
|
+
</span>.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### 2 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
import React, { useCallback } from 'react';
|
|
25
|
+
import { ButtonView, btnTypes } from '@bento-core/paginated-table';
|
|
26
|
+
|
|
27
|
+
const AddAllBlueButton = useCallback(() => (
|
|
28
|
+
<ButtonView
|
|
29
|
+
btnType={btnTypes.ADD_ALL_FILES}
|
|
30
|
+
title="Add All Files Btn"
|
|
31
|
+
clsName="add_all_button"
|
|
32
|
+
maxFileLimit={10000}
|
|
33
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
34
|
+
responseKeys={['caseOverview', 'files']}
|
|
35
|
+
activeFilters={activeFilters}
|
|
36
|
+
classes={classes}
|
|
37
|
+
section="toolTipText"
|
|
38
|
+
tooltipCofig={{
|
|
39
|
+
arrow: true,
|
|
40
|
+
clsName: 'addAllTooltip',
|
|
41
|
+
toolTipText: 'Add filtered files associated with all cases',
|
|
42
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
), []);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Add All Button Component or Configuration Properties**
|
|
49
|
+
| Component Props | Required | description | Configuration |
|
|
50
|
+
| :--- | :----:| :----: | ----: |
|
|
51
|
+
| 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 |
|
|
52
|
+
| title | TRUE | text for the button | 'Add all files' |
|
|
53
|
+
| clsName | TRUE | configure theme with themeprovider | |
|
|
54
|
+
| maxFileLimit | FALSE | limits no of files that can be added to myCart | 0 - 10000 (by default 1000) |
|
|
55
|
+
| addFileQuery | TRUE | query to retrive files or file ids | graphQL query |
|
|
56
|
+
| 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'] |
|
|
57
|
+
| section | TRUE | This key is used for accessing the tootip text provided in tooltipCofig | section="toolTipText" |
|
|
58
|
+
| classes | TRUE | provide class for toltips to override the style | tooltip: classes.customTooltip, arrow: classes.customArrow
|
|
59
|
+
| tooltipCofig | FALSE | displays tooltip if provided, configuration for arrow, clsName, icon, tooltipText | graphQL query |
|
|
60
|
+
| activeFilters | TRUE | filtes the case or sample based on the active filters | graphQL query |
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### 3 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
const customTheme = {
|
|
67
|
+
MuiContainer: {
|
|
68
|
+
root: {
|
|
69
|
+
'& img': {
|
|
70
|
+
width: '17px',
|
|
71
|
+
'&.addAllTooltip': {
|
|
72
|
+
verticalAlign: 'top',
|
|
73
|
+
marginTop: '8px',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const btnTheme = createTheme({ overrides: { ...customTheme } });
|
|
81
|
+
<ThemeProvider theme={btnTheme}>
|
|
82
|
+
<Container>
|
|
83
|
+
<AddAllBlueButton /> // from step 2
|
|
84
|
+
</Container>
|
|
85
|
+
</ThemeProvider>
|
|
86
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
### 1 Use 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:red">
|
|
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
|
+
const AddSelectedFilesOrangeButton = useCallback(() => (
|
|
25
|
+
<ButtonView
|
|
26
|
+
btnType={btnTypes.ADD_SELECTED_FILES}
|
|
27
|
+
title="ADD SELECTED FILES Btn"
|
|
28
|
+
clsName="add_selected_button"
|
|
29
|
+
dataKey="case_ids"
|
|
30
|
+
addFileQuery={GET_ALL_FILEIDS_CASESTAB_FOR_SELECT_ALL}
|
|
31
|
+
responseKeys={['caseOverview', 'files']}
|
|
32
|
+
classes={classes}
|
|
33
|
+
applyActiveFilter={true}
|
|
34
|
+
tooltipCofig={{
|
|
35
|
+
arrow: true,
|
|
36
|
+
clsName: 'addSelectedFileTooltip',
|
|
37
|
+
tooltipText: 'Add files associated selected cases',
|
|
38
|
+
icon: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/icdc/images/svgs/Tooltip.SpeechBubble.svg',
|
|
39
|
+
}}
|
|
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 Selected files' |
|
|
49
|
+
| clsName | TRUE | configure theme with themeprovider | |
|
|
50
|
+
| addFileQuery | TRUE | query to retrive files or file ids | graphQL query |
|
|
51
|
+
| 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'] |
|
|
52
|
+
| classes | TRUE | provide class for toltips to override the style | tooltip: classes.customTooltip, arrow: classes.customArrow
|
|
53
|
+
| tooltipCofig | FALSE | displays tooltip if provided, configuration for arrow, clsName, icon, tooltipText | graphQL query |
|
|
54
|
+
| dataKey | TRUE | Attribute used for getting selected rows in a table | case_id, file_name or any other column with distinct values |
|
|
55
|
+
| applyActiveFilter | FALSE | Only adds files of selected case or sample based on active filter | Bool |
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### 3 Configure Add_All_Button Or BLUE Button in Dashboard
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
const customTheme = {
|
|
62
|
+
MuiContainer: {
|
|
63
|
+
root: {
|
|
64
|
+
'& img': {
|
|
65
|
+
width: '17px',
|
|
66
|
+
'&.addAllTooltip': {
|
|
67
|
+
verticalAlign: 'top',
|
|
68
|
+
marginTop: '8px',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const btnTheme = createTheme({ overrides: { ...customTheme } });
|
|
76
|
+
<ThemeProvider theme={btnTheme}>
|
|
77
|
+
<Container>
|
|
78
|
+
<AddSelectedFilesOrangeButton /> // from step 2
|
|
79
|
+
</Container>
|
|
80
|
+
</ThemeProvider>
|
|
81
|
+
```
|
|
@@ -13,6 +13,67 @@
|
|
|
13
13
|
|
|
14
14
|
### Generate and integrate redux dispatch actions
|
|
15
15
|
```
|
|
16
|
+
const config = {
|
|
17
|
+
title: 'program',
|
|
18
|
+
dataField: 'studiesByProgram',
|
|
19
|
+
extendedViewConfig: { // display download button and manage view column
|
|
20
|
+
download: {
|
|
21
|
+
downloadFileName: 'ICDC_Studies_download',
|
|
22
|
+
downloadCsv: 'Download Table Contents As CSV',
|
|
23
|
+
},
|
|
24
|
+
manageViewColumns: {
|
|
25
|
+
title: 'View Columns',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
columns: [
|
|
29
|
+
{
|
|
30
|
+
cellType: cellTypes.CHECKBOX,
|
|
31
|
+
display: true,
|
|
32
|
+
role: cellTypes.CHECKBOX,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
dataField: 'program_id',
|
|
36
|
+
header: 'Program',
|
|
37
|
+
cellType: cellTypes.LINK,
|
|
38
|
+
linkAttr: {
|
|
39
|
+
rootPath: '/program',
|
|
40
|
+
pathParams: ['program_id'],
|
|
41
|
+
},
|
|
42
|
+
role: cellTypes.DISPLAY,
|
|
43
|
+
display: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
dataField: 'clinical_study_name',
|
|
47
|
+
header: 'Study Name',
|
|
48
|
+
display: true,
|
|
49
|
+
tooltipText: 'sort',
|
|
50
|
+
role: cellTypes.DISPLAY, // to display column in managecolumn view
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
dataField: 'numberOfStudyFiles',
|
|
54
|
+
header: 'Study File(s)',
|
|
55
|
+
display: true,
|
|
56
|
+
columnDefaultValues: {
|
|
57
|
+
'0': 'Not Applicable', // replaces 0 with other text value in a column
|
|
58
|
+
},
|
|
59
|
+
role: cellTypes.DISPLAY,
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
columnGroups: {
|
|
63
|
+
{
|
|
64
|
+
clsName: 'col_group_1',
|
|
65
|
+
title: 'column group title',
|
|
66
|
+
columnIndexes: [startColIndex, endColIndex],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
clsName: 'col_group_2',
|
|
70
|
+
title: 'column group title',
|
|
71
|
+
customViewRender: () => <h2>'custom Text'</h2>, // customize element (takes priority over title)
|
|
72
|
+
columnIndexes: [startColIndex, endColIndex],
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
16
77
|
const initTblState = (initailState) => ({
|
|
17
78
|
...initailState,
|
|
18
79
|
title: config.name,
|
|
@@ -25,6 +86,7 @@ const initTblState = (initailState) => ({
|
|
|
25
86
|
paginationAPIField: config.paginationAPIField,
|
|
26
87
|
sortBy: config.defaultSortField,
|
|
27
88
|
sortOrder: config.defaultSortDirection,
|
|
89
|
+
columnGroups: config.columnGroups
|
|
28
90
|
rowsPerPage: 10,
|
|
29
91
|
page: 0,
|
|
30
92
|
});
|
|
@@ -45,7 +107,9 @@ const initTblState = (initailState) => ({
|
|
|
45
107
|
| sortOrder | FALSE | default sort column 'ASC' | ```defaultSortDirection: 'asc',```|
|
|
46
108
|
| rowsPerPage | FALSE | default 10 | |
|
|
47
109
|
| page | FALSE | 0 | |
|
|
48
|
-
| extendedViewConfig | FALSE | extended view of table header component | refer bento-frontend tabContainers, dashboardTabData.js |
|
|
110
|
+
| extendedViewConfig | FALSE | extended view of table header component | refer bento-frontend / bento-icdc-frontend tabContainers, dashboardTabData.js |
|
|
111
|
+
| ColumnGroups | FALSE | ColumnGrouping Component | refer bento-icdc-frontend tabContainers, StudiesData.js |
|
|
112
|
+
|
|
49
113
|
|
|
50
114
|
|
|
51
115
|
### 2 Importing Component and Configuration
|
|
@@ -125,13 +189,14 @@ const initTblState = (initailState) => ({
|
|
|
125
189
|
sortBy: config.defaultSortField,
|
|
126
190
|
sortOrder: config.defaultSortDirection,
|
|
127
191
|
extendedViewConfig: config.extendedViewConfig,
|
|
192
|
+
columnGroups: config.columnGroups,
|
|
128
193
|
rowsPerPage: 10,
|
|
129
194
|
page: 0,
|
|
130
195
|
});
|
|
131
196
|
|
|
132
197
|
<TableContextProvider>
|
|
133
198
|
<Wrapper
|
|
134
|
-
wrapConfig={configWrapper(
|
|
199
|
+
wrapConfig={configWrapper(tableLayout)} // tableLayout - refer to step #4
|
|
135
200
|
customTheme={customTheme}
|
|
136
201
|
classes={classes}
|
|
137
202
|
section={config.name}
|
|
@@ -144,6 +209,7 @@ const initTblState = (initailState) => ({
|
|
|
144
209
|
queryVariables={activeFilters}
|
|
145
210
|
totalRowCount={dashboardStats[config.count]}
|
|
146
211
|
activeTab={activeTab}
|
|
212
|
+
paginationOptions={paginationOptions}
|
|
147
213
|
/>
|
|
148
214
|
</Grid>
|
|
149
215
|
</Grid>
|
|
@@ -172,7 +238,7 @@ Wrapper component around table compnent.
|
|
|
172
238
|
* Configuration display component based on index
|
|
173
239
|
* CAUTION: If table is in wrapper component provide position of table component
|
|
174
240
|
*/
|
|
175
|
-
export const
|
|
241
|
+
export const tableLayout = [{
|
|
176
242
|
container: 'buttons',
|
|
177
243
|
size: 'xl',
|
|
178
244
|
clsName: 'container_header',
|
|
@@ -251,3 +317,58 @@ headerConfig - upper component on the table
|
|
|
251
317
|
| tooltipCofig | FALSE | appears on side of the refers button | dashboardTabData/ tooltipContent |
|
|
252
318
|
|
|
253
319
|
|
|
320
|
+
####
|
|
321
|
+
|
|
322
|
+
## 5 Pagination Configuration:
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
import {
|
|
326
|
+
TableContext,
|
|
327
|
+
onColumnViewChange, // dispact action
|
|
328
|
+
onColumnSort, // dispact action
|
|
329
|
+
onChangeSortDirection, // dispact action
|
|
330
|
+
onRowsPerPageChange, // dispact action
|
|
331
|
+
onPageAndTotalCountChange, // dispact action
|
|
332
|
+
onPageChange, // dispact action
|
|
333
|
+
onRowSeclect, // dispact action
|
|
334
|
+
setTotalRowCount, // dispact action
|
|
335
|
+
customPaginationAction, // dispact action
|
|
336
|
+
} from '@bento-core/paginated-table';
|
|
337
|
+
|
|
338
|
+
const tableContext = useContext(TableContext);
|
|
339
|
+
const { context } = tableContext;
|
|
340
|
+
const { dispatch } = context;
|
|
341
|
+
|
|
342
|
+
const paginationOptions = {
|
|
343
|
+
customizeOnRowSelect: (event, row) => {
|
|
344
|
+
const payload = {
|
|
345
|
+
page: 2,
|
|
346
|
+
rowPerPage: 10,
|
|
347
|
+
...
|
|
348
|
+
};
|
|
349
|
+
// updates table state,
|
|
350
|
+
dispatch(customPaginationAction(payload));
|
|
351
|
+
},
|
|
352
|
+
customizeToggleSelectAll: (event, Ids, includeIds) => {}, // Ids - selected ids
|
|
353
|
+
customizeSortByColumn: (column, order) => {},
|
|
354
|
+
customizeChangePage: (event, newPage) => {},
|
|
355
|
+
customizeChangeRowsPerPage: (event) => {},
|
|
356
|
+
customizeColumnViewChange: (column) => {},
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
<TableView
|
|
360
|
+
initState={initTblState}
|
|
361
|
+
themeConfig={themeConfig}
|
|
362
|
+
queryVariables={activeFilters}
|
|
363
|
+
totalRowCount={dashboardStats[config.count]}
|
|
364
|
+
activeTab={activeTab}
|
|
365
|
+
paginationOptions={paginationOptions}
|
|
366
|
+
/>
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
***More reference***
|
|
370
|
+
```
|
|
371
|
+
https://github.com/CBIIT/bento-icdc-frontend/tree/Bento-4.0/src/components/PaginatedTable
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
**Code for table view under bento-core/table - please refer to source code for more information**
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "ButtonView", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _ButtonView.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "TableContext", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -33,6 +39,12 @@ Object.defineProperty(exports, "btnTypes", {
|
|
|
33
39
|
return _AddFiles.btnTypes;
|
|
34
40
|
}
|
|
35
41
|
});
|
|
42
|
+
Object.defineProperty(exports, "customPaginationAction", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _Actions.customPaginationAction;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
36
48
|
Object.defineProperty(exports, "getQueryVariables", {
|
|
37
49
|
enumerable: true,
|
|
38
50
|
get: function get() {
|
|
@@ -99,6 +111,7 @@ var _Actions = require("./table/state/Actions");
|
|
|
99
111
|
var _Wrapper = _interopRequireWildcard(require("./wrapper/Wrapper"));
|
|
100
112
|
var _AddFiles = require("./wrapper/components/AddFiles");
|
|
101
113
|
var _WrapperService = require("./wrapper/WrapperService");
|
|
114
|
+
var _ButtonView = _interopRequireDefault(require("./wrapper/components/ButtonView"));
|
|
102
115
|
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); }
|
|
103
116
|
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; }
|
|
104
117
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -57,6 +57,7 @@ const TableController = props => {
|
|
|
57
57
|
const endIndex = startIndex + rowsPerPage;
|
|
58
58
|
const displayRows = [...sortedRows].slice(startIndex, endIndex);
|
|
59
59
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_table.TableView, _extends({}, props, {
|
|
60
|
+
totalRows: tblRows,
|
|
60
61
|
tableRows: displayRows
|
|
61
62
|
})));
|
|
62
63
|
};
|
|
@@ -26,7 +26,8 @@ const PaginatedTable = _ref => {
|
|
|
26
26
|
initState,
|
|
27
27
|
activeTab = true,
|
|
28
28
|
server = true,
|
|
29
|
-
tblRows = []
|
|
29
|
+
tblRows = [],
|
|
30
|
+
paginationOptions = {}
|
|
30
31
|
} = _ref;
|
|
31
32
|
/**
|
|
32
33
|
* Initailize useReducer state
|
|
@@ -89,6 +90,17 @@ const PaginatedTable = _ref => {
|
|
|
89
90
|
pageNumb: newPage
|
|
90
91
|
}));
|
|
91
92
|
};
|
|
93
|
+
// custonize pagination behavior
|
|
94
|
+
const {
|
|
95
|
+
customizeOnRowSelect,
|
|
96
|
+
customizeToggleSelectAll,
|
|
97
|
+
customizeSortByColumn,
|
|
98
|
+
customizeChangePage,
|
|
99
|
+
customizeChangeRowsPerPage,
|
|
100
|
+
customizeColumnViewChange,
|
|
101
|
+
customizeDeleteRow,
|
|
102
|
+
customizeDeleteAllRows
|
|
103
|
+
} = paginationOptions;
|
|
92
104
|
|
|
93
105
|
/**
|
|
94
106
|
* update selected Ids
|
|
@@ -138,7 +150,7 @@ const PaginatedTable = _ref => {
|
|
|
138
150
|
const handleColumnViewChange = column => {
|
|
139
151
|
const columns = table.columns.map(col => {
|
|
140
152
|
const updateColumnView = _objectSpread({}, col);
|
|
141
|
-
if (col.dataField === column.dataField) {
|
|
153
|
+
if (col.dataField && col.dataField === column.dataField) {
|
|
142
154
|
updateColumnView.display = !column.display;
|
|
143
155
|
}
|
|
144
156
|
return updateColumnView;
|
|
@@ -147,6 +159,39 @@ const PaginatedTable = _ref => {
|
|
|
147
159
|
columns
|
|
148
160
|
})));
|
|
149
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
|
+
|
|
150
195
|
/**
|
|
151
196
|
* A. client table
|
|
152
197
|
* table data provide by bento app (tblRows)
|
|
@@ -156,12 +201,14 @@ const PaginatedTable = _ref => {
|
|
|
156
201
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ClientController.default, {
|
|
157
202
|
tblRows: tblRows,
|
|
158
203
|
table: table,
|
|
159
|
-
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
160
|
-
onPageChange: handleChangePage,
|
|
161
|
-
onRowSelectChange: onRowSelectHandler,
|
|
162
|
-
onToggleSelectAll: handleToggleSelectAll,
|
|
163
|
-
onSortByColumn: handleSortByColumn,
|
|
164
|
-
onColumnViewChange: handleColumnViewChange,
|
|
204
|
+
onRowsPerPageChange: customizeChangeRowsPerPage || handleChangeRowsPerPage,
|
|
205
|
+
onPageChange: customizeChangePage || handleChangePage,
|
|
206
|
+
onRowSelectChange: customizeOnRowSelect || onRowSelectHandler,
|
|
207
|
+
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
208
|
+
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
209
|
+
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
210
|
+
onDeleteRow: customizeDeleteRow || onDeleteRow,
|
|
211
|
+
onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
|
|
165
212
|
themeConfig: themeConfig
|
|
166
213
|
}));
|
|
167
214
|
}
|
|
@@ -180,12 +227,15 @@ const PaginatedTable = _ref => {
|
|
|
180
227
|
queryVariables: queryVariables,
|
|
181
228
|
totalRowCount: totalRowCount,
|
|
182
229
|
table: table,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
230
|
+
server: server,
|
|
231
|
+
onRowsPerPageChange: customizeChangeRowsPerPage || handleChangeRowsPerPage,
|
|
232
|
+
onPageChange: customizeChangePage || handleChangePage,
|
|
233
|
+
onRowSelectChange: customizeOnRowSelect || onRowSelectHandler,
|
|
234
|
+
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
235
|
+
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
236
|
+
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
237
|
+
onDeleteRow: customizeDeleteRow || onDeleteRow,
|
|
238
|
+
onDeleteAllFiles: customizeDeleteAllRows || onDeleteAllRows,
|
|
189
239
|
themeConfig: themeConfig
|
|
190
240
|
}));
|
|
191
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.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',
|
|
@@ -12,7 +12,10 @@ const actionTypes = {
|
|
|
12
12
|
ON_PAGE_CHANGE: 'ON_PAGE_CHANGE',
|
|
13
13
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
14
14
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
15
|
-
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE'
|
|
15
|
+
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
|
|
16
|
+
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
|
|
17
|
+
ON_ROWS_DELETE: 'ON_ROWS_DELETE',
|
|
18
|
+
ON_ROW_DELETE: 'ON_ROW_DELETE'
|
|
16
19
|
};
|
|
17
20
|
exports.actionTypes = actionTypes;
|
|
18
21
|
const onColumnViewChange = columns => ({
|
|
@@ -54,4 +57,19 @@ const setTotalRowCount = count => ({
|
|
|
54
57
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
55
58
|
payload: count
|
|
56
59
|
});
|
|
57
|
-
exports.setTotalRowCount = setTotalRowCount;
|
|
60
|
+
exports.setTotalRowCount = setTotalRowCount;
|
|
61
|
+
const customPaginationAction = value => ({
|
|
62
|
+
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
63
|
+
payload: value
|
|
64
|
+
});
|
|
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;
|
|
@@ -16,6 +16,8 @@ const reducer = (state, action) => {
|
|
|
16
16
|
payload
|
|
17
17
|
} = action;
|
|
18
18
|
switch (type) {
|
|
19
|
+
case _Actions.actionTypes.CUSTOMIZE_PAGINATION_ACTION:
|
|
20
|
+
return _objectSpread(_objectSpread({}, state), payload);
|
|
19
21
|
case _Actions.actionTypes.ON_COLUMN_SORT:
|
|
20
22
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
21
23
|
sortOrder: payload.sort,
|
|
@@ -45,6 +47,16 @@ const reducer = (state, action) => {
|
|
|
45
47
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
46
48
|
totalRowCount: payload
|
|
47
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
|
+
});
|
|
48
60
|
default:
|
|
49
61
|
return state;
|
|
50
62
|
}
|
|
@@ -14,7 +14,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
14
14
|
*/
|
|
15
15
|
const getQueryVariables = variables => {
|
|
16
16
|
const queryVariables = _objectSpread({}, variables);
|
|
17
|
-
queryVariables.first =
|
|
17
|
+
queryVariables.first = 10000;
|
|
18
18
|
return queryVariables;
|
|
19
19
|
};
|
|
20
20
|
exports.getQueryVariables = getQueryVariables;
|
|
@@ -9,6 +9,8 @@ var _core = require("@material-ui/core");
|
|
|
9
9
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
10
10
|
var _WrapperService = require("../../WrapperService");
|
|
11
11
|
var _AddToCartDialogView = _interopRequireDefault(require("../AddToCartDialog/AddToCartDialogView"));
|
|
12
|
+
var _TooltipView = _interopRequireDefault(require("../TooltipView"));
|
|
13
|
+
var _util = _interopRequireDefault(require("../util"));
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
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); }
|
|
14
16
|
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; }
|
|
@@ -23,7 +25,10 @@ const AddAllFilesComponent = props => {
|
|
|
23
25
|
addFiles,
|
|
24
26
|
setAlterDisplay,
|
|
25
27
|
setOpenSnackbar,
|
|
26
|
-
client
|
|
28
|
+
client,
|
|
29
|
+
tooltipCofig,
|
|
30
|
+
maxFileLimit = 1000,
|
|
31
|
+
DisplayCustomText
|
|
27
32
|
} = props;
|
|
28
33
|
/**
|
|
29
34
|
* conditionally display dialog view
|
|
@@ -41,19 +46,16 @@ const AddAllFilesComponent = props => {
|
|
|
41
46
|
variables: activeFilters,
|
|
42
47
|
query: addFileQuery
|
|
43
48
|
});
|
|
49
|
+
let filesInCart = 0;
|
|
50
|
+
if (localStorage.getItem('CartFileIds')) {
|
|
51
|
+
const filesId = JSON.parse(localStorage.getItem('CartFileIds')) || [];
|
|
52
|
+
filesInCart = filesId.length;
|
|
53
|
+
}
|
|
44
54
|
fileIds().then(response => {
|
|
45
55
|
const data = response[responseKeys[0]];
|
|
46
56
|
if (data && data.length > 0) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
if (id && id[responseKeys[1]]) {
|
|
50
|
-
// if object convert to array
|
|
51
|
-
const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
52
|
-
acc.push(...items);
|
|
53
|
-
}
|
|
54
|
-
return acc;
|
|
55
|
-
}, []);
|
|
56
|
-
if (ids.length > 1000) {
|
|
57
|
+
const ids = (0, _util.default)(response, responseKeys);
|
|
58
|
+
if (ids.length + filesInCart > maxFileLimit) {
|
|
57
59
|
setAlterDisplay(true);
|
|
58
60
|
} else {
|
|
59
61
|
setOpen(true);
|
|
@@ -78,10 +80,12 @@ const AddAllFilesComponent = props => {
|
|
|
78
80
|
onClick: addAllFiles,
|
|
79
81
|
className: (0, _clsx.default)(clsName, "".concat(clsName, "_").concat(section)),
|
|
80
82
|
disableRipple: true
|
|
81
|
-
}, title), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
|
|
83
|
+
}, title), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
|
|
82
84
|
open: openAddDialog,
|
|
83
85
|
onYesClick: addFilesToCart,
|
|
84
|
-
onNoClick: toggleOpen
|
|
86
|
+
onNoClick: toggleOpen,
|
|
87
|
+
DisplayCustomText: DisplayCustomText,
|
|
88
|
+
activeFilters: activeFilters
|
|
85
89
|
}));
|
|
86
90
|
};
|
|
87
91
|
var _default = AddAllFilesComponent;
|