@bento-core/paginated-table 1.0.0 → 1.0.1-icdc.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/{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 +25 -14
- package/dist/table/state/Actions.js +9 -3
- package/dist/table/state/Reducer.js +2 -0
- package/dist/wrapper/WrapperService.js +1 -1
- package/dist/wrapper/components/AddAllFiles/AddAllView.js +11 -13
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +9 -5
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -0
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +9 -3
- package/dist/wrapper/components/util.js +33 -0
- package/package.json +11 -5
- package/src/index.js +4 -0
- package/src/table/ClientController.js +1 -0
- package/src/table/PaginatedTable.js +24 -13
- package/src/table/state/Actions.js +6 -0
- package/src/table/state/Reducer.js +5 -0
- package/src/wrapper/WrapperService.js +1 -1
- package/src/wrapper/components/AddAllFiles/AddAllView.js +9 -10
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +8 -4
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +1 -1
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +18 -8
- package/src/wrapper/components/util.js +26 -0
- package/src/table/README.md +0 -253
|
@@ -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,15 @@ 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
|
+
} = paginationOptions;
|
|
92
102
|
|
|
93
103
|
/**
|
|
94
104
|
* update selected Ids
|
|
@@ -138,7 +148,7 @@ const PaginatedTable = _ref => {
|
|
|
138
148
|
const handleColumnViewChange = column => {
|
|
139
149
|
const columns = table.columns.map(col => {
|
|
140
150
|
const updateColumnView = _objectSpread({}, col);
|
|
141
|
-
if (col.dataField === column.dataField) {
|
|
151
|
+
if (col.dataField && col.dataField === column.dataField) {
|
|
142
152
|
updateColumnView.display = !column.display;
|
|
143
153
|
}
|
|
144
154
|
return updateColumnView;
|
|
@@ -156,12 +166,12 @@ const PaginatedTable = _ref => {
|
|
|
156
166
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ClientController.default, {
|
|
157
167
|
tblRows: tblRows,
|
|
158
168
|
table: table,
|
|
159
|
-
onRowsPerPageChange: handleChangeRowsPerPage,
|
|
160
|
-
onPageChange: handleChangePage,
|
|
161
|
-
onRowSelectChange: onRowSelectHandler,
|
|
162
|
-
onToggleSelectAll: handleToggleSelectAll,
|
|
163
|
-
onSortByColumn: handleSortByColumn,
|
|
164
|
-
onColumnViewChange: handleColumnViewChange,
|
|
169
|
+
onRowsPerPageChange: customizeChangeRowsPerPage || handleChangeRowsPerPage,
|
|
170
|
+
onPageChange: customizeChangePage || handleChangePage,
|
|
171
|
+
onRowSelectChange: customizeOnRowSelect || onRowSelectHandler,
|
|
172
|
+
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
173
|
+
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
174
|
+
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
165
175
|
themeConfig: themeConfig
|
|
166
176
|
}));
|
|
167
177
|
}
|
|
@@ -180,12 +190,13 @@ const PaginatedTable = _ref => {
|
|
|
180
190
|
queryVariables: queryVariables,
|
|
181
191
|
totalRowCount: totalRowCount,
|
|
182
192
|
table: table,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
193
|
+
server: server,
|
|
194
|
+
onRowsPerPageChange: customizeChangeRowsPerPage || handleChangeRowsPerPage,
|
|
195
|
+
onPageChange: customizeChangePage || handleChangePage,
|
|
196
|
+
onRowSelectChange: customizeOnRowSelect || onRowSelectHandler,
|
|
197
|
+
onToggleSelectAll: customizeToggleSelectAll || handleToggleSelectAll,
|
|
198
|
+
onSortByColumn: customizeSortByColumn || handleSortByColumn,
|
|
199
|
+
onColumnViewChange: customizeColumnViewChange || handleColumnViewChange,
|
|
189
200
|
themeConfig: themeConfig
|
|
190
201
|
}));
|
|
191
202
|
};
|
|
@@ -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.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = 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,8 @@ 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'
|
|
16
17
|
};
|
|
17
18
|
exports.actionTypes = actionTypes;
|
|
18
19
|
const onColumnViewChange = columns => ({
|
|
@@ -54,4 +55,9 @@ const setTotalRowCount = count => ({
|
|
|
54
55
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
55
56
|
payload: count
|
|
56
57
|
});
|
|
57
|
-
exports.setTotalRowCount = setTotalRowCount;
|
|
58
|
+
exports.setTotalRowCount = setTotalRowCount;
|
|
59
|
+
const customPaginationAction = value => ({
|
|
60
|
+
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
61
|
+
payload: value
|
|
62
|
+
});
|
|
63
|
+
exports.customPaginationAction = customPaginationAction;
|
|
@@ -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,
|
|
@@ -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
|
|
@@ -44,16 +49,8 @@ const AddAllFilesComponent = props => {
|
|
|
44
49
|
fileIds().then(response => {
|
|
45
50
|
const data = response[responseKeys[0]];
|
|
46
51
|
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) {
|
|
52
|
+
const ids = (0, _util.default)(response, responseKeys);
|
|
53
|
+
if (ids.length > maxFileLimit) {
|
|
57
54
|
setAlterDisplay(true);
|
|
58
55
|
} else {
|
|
59
56
|
setOpen(true);
|
|
@@ -78,10 +75,11 @@ const AddAllFilesComponent = props => {
|
|
|
78
75
|
onClick: addAllFiles,
|
|
79
76
|
className: (0, _clsx.default)(clsName, "".concat(clsName, "_").concat(section)),
|
|
80
77
|
disableRipple: true
|
|
81
|
-
}, title), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
|
|
78
|
+
}, title), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props), /*#__PURE__*/_react.default.createElement(_AddToCartDialogView.default, {
|
|
82
79
|
open: openAddDialog,
|
|
83
80
|
onYesClick: addFilesToCart,
|
|
84
|
-
onNoClick: toggleOpen
|
|
81
|
+
onNoClick: toggleOpen,
|
|
82
|
+
DisplayCustomText: DisplayCustomText
|
|
85
83
|
}));
|
|
86
84
|
};
|
|
87
85
|
var _default = AddAllFilesComponent;
|
|
@@ -12,6 +12,7 @@ var _ContextProvider = require("../../../table/ContextProvider");
|
|
|
12
12
|
var _Actions = require("../../../table/state/Actions");
|
|
13
13
|
var _AddSelectedFilesView = _interopRequireDefault(require("./AddSelectedFilesView"));
|
|
14
14
|
var _WrapperService = require("../../WrapperService");
|
|
15
|
+
var _util = _interopRequireDefault(require("../util"));
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
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); }
|
|
17
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; }
|
|
@@ -26,7 +27,8 @@ const AddSelectedFilesController = props => {
|
|
|
26
27
|
addFiles,
|
|
27
28
|
setOpenSnackbar,
|
|
28
29
|
setAlterDisplay,
|
|
29
|
-
client
|
|
30
|
+
client,
|
|
31
|
+
maxFileLimit = 1000
|
|
30
32
|
} = props;
|
|
31
33
|
const tableContext = (0, _react.useContext)(_ContextProvider.TableContext);
|
|
32
34
|
const {
|
|
@@ -36,8 +38,10 @@ const AddSelectedFilesController = props => {
|
|
|
36
38
|
selectedRows = [],
|
|
37
39
|
dispatch
|
|
38
40
|
} = context;
|
|
39
|
-
const variables = {
|
|
40
|
-
|
|
41
|
+
const variables = {
|
|
42
|
+
first: 10000,
|
|
43
|
+
[dataKey]: selectedRows
|
|
44
|
+
};
|
|
41
45
|
// add selected files id
|
|
42
46
|
const addSelectedFiles = () => {
|
|
43
47
|
const fileIds = (0, _WrapperService.getFilesID)({
|
|
@@ -47,8 +51,8 @@ const AddSelectedFilesController = props => {
|
|
|
47
51
|
query: addFileQuery
|
|
48
52
|
});
|
|
49
53
|
fileIds().then(response => {
|
|
50
|
-
const ids =
|
|
51
|
-
if (ids.length >=
|
|
54
|
+
const ids = (0, _util.default)(response, responseKeys);
|
|
55
|
+
if (ids.length >= maxFileLimit) {
|
|
52
56
|
setAlterDisplay(true);
|
|
53
57
|
} else {
|
|
54
58
|
addFiles(ids);
|
|
@@ -15,7 +15,8 @@ function AddToCartDialogView(props) {
|
|
|
15
15
|
onYesClick,
|
|
16
16
|
onNoClick,
|
|
17
17
|
cartWillFull = false,
|
|
18
|
-
alertMessage
|
|
18
|
+
alertMessage,
|
|
19
|
+
DisplayCustomText
|
|
19
20
|
} = props;
|
|
20
21
|
if (cartWillFull) {
|
|
21
22
|
return /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
|
|
@@ -28,9 +29,14 @@ function AddToCartDialogView(props) {
|
|
|
28
29
|
open: open,
|
|
29
30
|
"aria-labelledby": "alert-dialog-title",
|
|
30
31
|
"aria-describedby": "alert-dialog-description"
|
|
31
|
-
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, /*#__PURE__*/_react.default.createElement(
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_core.DialogContent, null, DisplayCustomText ? /*#__PURE__*/_react.default.createElement(DisplayCustomText, {
|
|
33
|
+
onYesClick: onYesClick,
|
|
34
|
+
onNoClick: onNoClick
|
|
35
|
+
}) : /*#__PURE__*/_react.default.createElement(_core.DialogContentText, {
|
|
32
36
|
id: "alert-dialog-description"
|
|
33
|
-
}, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions,
|
|
37
|
+
}, "Are you sure to add All Files", ' ', numberOfFilesSelected, ' ', "to cart")), /*#__PURE__*/_react.default.createElement(_core.DialogActions, {
|
|
38
|
+
className: "dialog_actions"
|
|
39
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
34
40
|
className: "yesBtn",
|
|
35
41
|
onClick: () => onYesClick()
|
|
36
42
|
}, "Yes"), /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* max two response keys
|
|
9
|
+
* add file query response handler
|
|
10
|
+
* return - list of files name/id
|
|
11
|
+
*/
|
|
12
|
+
const addFilesResponseHandler = function addFilesResponseHandler(response) {
|
|
13
|
+
let responseKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
14
|
+
if (responseKeys.length === 2) {
|
|
15
|
+
const data = response[responseKeys[0]];
|
|
16
|
+
if (data && data.length > 0) {
|
|
17
|
+
const isArray = Array.isArray(data[0][responseKeys[1]]);
|
|
18
|
+
const ids = data.reduce((acc, id) => {
|
|
19
|
+
if (id && id[responseKeys[1]]) {
|
|
20
|
+
// if object convert to array
|
|
21
|
+
const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
22
|
+
acc.push(...items);
|
|
23
|
+
}
|
|
24
|
+
return acc;
|
|
25
|
+
}, []);
|
|
26
|
+
return ids;
|
|
27
|
+
}
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
return response[responseKeys[0]] || [];
|
|
31
|
+
};
|
|
32
|
+
var _default = addFilesResponseHandler;
|
|
33
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/paginated-table",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.1-icdc.2",
|
|
4
|
+
"description": "### Bento core paginated table design:",
|
|
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":
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/CBIIT/bento-frontend.git"
|
|
14
|
+
},
|
|
12
15
|
"publishConfig": {
|
|
13
|
-
"
|
|
16
|
+
"@model_navigator:registry": "https://registry.npmjs.org/@bento-core/paginated-table"
|
|
14
17
|
},
|
|
15
18
|
"dependencies": {
|
|
16
19
|
"@bento-core/cart": "^1.0.0",
|
|
@@ -28,5 +31,8 @@
|
|
|
28
31
|
},
|
|
29
32
|
"author": "CTOS Bento Team",
|
|
30
33
|
"license": "ISC",
|
|
31
|
-
"
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/CBIIT/bento-frontend/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/CBIIT/bento-frontend#readme"
|
|
32
38
|
}
|
package/src/index.js
CHANGED
|
@@ -12,7 +12,11 @@ export {
|
|
|
12
12
|
onPageChange,
|
|
13
13
|
onRowSeclect,
|
|
14
14
|
setTotalRowCount,
|
|
15
|
+
customPaginationAction,
|
|
15
16
|
} from './table/state/Actions';
|
|
16
17
|
export { default as Wrapper, types } from './wrapper/Wrapper';
|
|
17
18
|
export { btnTypes } from './wrapper/components/AddFiles';
|
|
18
19
|
export { getQueryVariables } from './wrapper/WrapperService';
|
|
20
|
+
export {
|
|
21
|
+
default as ButtonView,
|
|
22
|
+
} from './wrapper/components/ButtonView';
|
|
@@ -21,6 +21,7 @@ const PaginatedTable = ({
|
|
|
21
21
|
activeTab = true,
|
|
22
22
|
server = true,
|
|
23
23
|
tblRows = [],
|
|
24
|
+
paginationOptions = {},
|
|
24
25
|
}) => {
|
|
25
26
|
/**
|
|
26
27
|
* Initailize useReducer state
|
|
@@ -74,6 +75,15 @@ const PaginatedTable = ({
|
|
|
74
75
|
const handleChangePage = (event, newPage) => {
|
|
75
76
|
dispatch(onPageChange({ pageNumb: newPage }));
|
|
76
77
|
};
|
|
78
|
+
// custonize pagination behavior
|
|
79
|
+
const {
|
|
80
|
+
customizeOnRowSelect,
|
|
81
|
+
customizeToggleSelectAll,
|
|
82
|
+
customizeSortByColumn,
|
|
83
|
+
customizeChangePage,
|
|
84
|
+
customizeChangeRowsPerPage,
|
|
85
|
+
customizeColumnViewChange,
|
|
86
|
+
} = paginationOptions;
|
|
77
87
|
|
|
78
88
|
/**
|
|
79
89
|
* update selected Ids
|
|
@@ -120,7 +130,7 @@ const PaginatedTable = ({
|
|
|
120
130
|
const handleColumnViewChange = (column) => {
|
|
121
131
|
const columns = table.columns.map((col) => {
|
|
122
132
|
const updateColumnView = { ...col };
|
|
123
|
-
if (col.dataField === column.dataField) {
|
|
133
|
+
if (col.dataField && col.dataField === column.dataField) {
|
|
124
134
|
updateColumnView.display = !column.display;
|
|
125
135
|
}
|
|
126
136
|
return updateColumnView;
|
|
@@ -141,12 +151,12 @@ const PaginatedTable = ({
|
|
|
141
151
|
<ClientTableView
|
|
142
152
|
tblRows={tblRows}
|
|
143
153
|
table={table}
|
|
144
|
-
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
145
|
-
onPageChange={handleChangePage}
|
|
146
|
-
onRowSelectChange={onRowSelectHandler}
|
|
147
|
-
onToggleSelectAll={handleToggleSelectAll}
|
|
148
|
-
onSortByColumn={handleSortByColumn}
|
|
149
|
-
onColumnViewChange={handleColumnViewChange}
|
|
154
|
+
onRowsPerPageChange={customizeChangeRowsPerPage || handleChangeRowsPerPage}
|
|
155
|
+
onPageChange={customizeChangePage || handleChangePage}
|
|
156
|
+
onRowSelectChange={customizeOnRowSelect || onRowSelectHandler}
|
|
157
|
+
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
158
|
+
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
159
|
+
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
150
160
|
themeConfig={themeConfig}
|
|
151
161
|
/>
|
|
152
162
|
</>
|
|
@@ -170,12 +180,13 @@ const PaginatedTable = ({
|
|
|
170
180
|
queryVariables={queryVariables}
|
|
171
181
|
totalRowCount={totalRowCount}
|
|
172
182
|
table={table}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
183
|
+
server={server}
|
|
184
|
+
onRowsPerPageChange={customizeChangeRowsPerPage || handleChangeRowsPerPage}
|
|
185
|
+
onPageChange={customizeChangePage || handleChangePage}
|
|
186
|
+
onRowSelectChange={customizeOnRowSelect || onRowSelectHandler}
|
|
187
|
+
onToggleSelectAll={customizeToggleSelectAll || handleToggleSelectAll}
|
|
188
|
+
onSortByColumn={customizeSortByColumn || handleSortByColumn}
|
|
189
|
+
onColumnViewChange={customizeColumnViewChange || handleColumnViewChange}
|
|
179
190
|
themeConfig={themeConfig}
|
|
180
191
|
/>
|
|
181
192
|
</>
|
|
@@ -7,6 +7,7 @@ export const actionTypes = {
|
|
|
7
7
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
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
|
+
CUSTOMIZE_PAGINATION_ACTION: 'CUSTOMIZE_PAGINATION_ACTION',
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const onColumnViewChange = (columns) => ({
|
|
@@ -48,3 +49,8 @@ export const setTotalRowCount = (count) => ({
|
|
|
48
49
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
49
50
|
payload: count,
|
|
50
51
|
});
|
|
52
|
+
|
|
53
|
+
export const customPaginationAction = (value) => ({
|
|
54
|
+
type: actionTypes.CUSTOMIZE_PAGINATION_ACTION,
|
|
55
|
+
payload: value,
|
|
56
|
+
});
|
|
@@ -3,6 +3,11 @@ import { actionTypes } from './Actions';
|
|
|
3
3
|
const reducer = (state, action) => {
|
|
4
4
|
const { type, payload } = action;
|
|
5
5
|
switch (type) {
|
|
6
|
+
case actionTypes.CUSTOMIZE_PAGINATION_ACTION:
|
|
7
|
+
return {
|
|
8
|
+
...state,
|
|
9
|
+
...payload,
|
|
10
|
+
};
|
|
6
11
|
case actionTypes.ON_COLUMN_SORT:
|
|
7
12
|
return {
|
|
8
13
|
...state,
|
|
@@ -3,6 +3,8 @@ import { Button } from '@material-ui/core';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import { getFilesID } from '../../WrapperService';
|
|
5
5
|
import AddToCartDialogView from '../AddToCartDialog/AddToCartDialogView';
|
|
6
|
+
import ToolTipView from '../TooltipView';
|
|
7
|
+
import addFilesResponseHandler from '../util';
|
|
6
8
|
|
|
7
9
|
const AddAllFilesComponent = (props) => {
|
|
8
10
|
const {
|
|
@@ -16,6 +18,9 @@ const AddAllFilesComponent = (props) => {
|
|
|
16
18
|
setAlterDisplay,
|
|
17
19
|
setOpenSnackbar,
|
|
18
20
|
client,
|
|
21
|
+
tooltipCofig,
|
|
22
|
+
maxFileLimit = 1000,
|
|
23
|
+
DisplayCustomText,
|
|
19
24
|
} = props;
|
|
20
25
|
/**
|
|
21
26
|
* conditionally display dialog view
|
|
@@ -36,16 +41,8 @@ const AddAllFilesComponent = (props) => {
|
|
|
36
41
|
fileIds().then((response) => {
|
|
37
42
|
const data = response[responseKeys[0]];
|
|
38
43
|
if (data && data.length > 0) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
if (id && id[responseKeys[1]]) {
|
|
42
|
-
// if object convert to array
|
|
43
|
-
const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
44
|
-
acc.push(...items);
|
|
45
|
-
}
|
|
46
|
-
return acc;
|
|
47
|
-
}, []);
|
|
48
|
-
if (ids.length > 1000) {
|
|
44
|
+
const ids = addFilesResponseHandler(response, responseKeys);
|
|
45
|
+
if (ids.length > maxFileLimit) {
|
|
49
46
|
setAlterDisplay(true);
|
|
50
47
|
} else {
|
|
51
48
|
setOpen(true);
|
|
@@ -76,10 +73,12 @@ const AddAllFilesComponent = (props) => {
|
|
|
76
73
|
>
|
|
77
74
|
{title}
|
|
78
75
|
</Button>
|
|
76
|
+
{tooltipCofig && (<ToolTipView {...props} />)}
|
|
79
77
|
<AddToCartDialogView
|
|
80
78
|
open={openAddDialog}
|
|
81
79
|
onYesClick={addFilesToCart}
|
|
82
80
|
onNoClick={toggleOpen}
|
|
81
|
+
DisplayCustomText={DisplayCustomText}
|
|
83
82
|
/>
|
|
84
83
|
</>
|
|
85
84
|
);
|
|
@@ -6,6 +6,7 @@ import { TableContext } from '../../../table/ContextProvider';
|
|
|
6
6
|
import { onRowSeclect } from '../../../table/state/Actions';
|
|
7
7
|
import AddSelectedFileComponent from './AddSelectedFilesView';
|
|
8
8
|
import { getFilesID } from '../../WrapperService';
|
|
9
|
+
import addFilesResponseHandler from '../util';
|
|
9
10
|
|
|
10
11
|
const AddSelectedFilesController = (props) => {
|
|
11
12
|
const {
|
|
@@ -18,6 +19,7 @@ const AddSelectedFilesController = (props) => {
|
|
|
18
19
|
setOpenSnackbar,
|
|
19
20
|
setAlterDisplay,
|
|
20
21
|
client,
|
|
22
|
+
maxFileLimit = 1000,
|
|
21
23
|
} = props;
|
|
22
24
|
|
|
23
25
|
const tableContext = useContext(TableContext);
|
|
@@ -26,8 +28,10 @@ const AddSelectedFilesController = (props) => {
|
|
|
26
28
|
selectedRows = [],
|
|
27
29
|
dispatch,
|
|
28
30
|
} = context;
|
|
29
|
-
const variables = {
|
|
30
|
-
|
|
31
|
+
const variables = {
|
|
32
|
+
first: 10000,
|
|
33
|
+
[dataKey]: selectedRows,
|
|
34
|
+
};
|
|
31
35
|
// add selected files id
|
|
32
36
|
const addSelectedFiles = () => {
|
|
33
37
|
const fileIds = getFilesID({
|
|
@@ -38,8 +42,8 @@ const AddSelectedFilesController = (props) => {
|
|
|
38
42
|
});
|
|
39
43
|
|
|
40
44
|
fileIds().then((response) => {
|
|
41
|
-
const ids = response
|
|
42
|
-
if (ids.length >=
|
|
45
|
+
const ids = addFilesResponseHandler(response, responseKeys);
|
|
46
|
+
if (ids.length >= maxFileLimit) {
|
|
43
47
|
setAlterDisplay(true);
|
|
44
48
|
} else {
|
|
45
49
|
addFiles(ids);
|
|
@@ -12,6 +12,7 @@ function AddToCartDialogView(props) {
|
|
|
12
12
|
onNoClick,
|
|
13
13
|
cartWillFull = false,
|
|
14
14
|
alertMessage,
|
|
15
|
+
DisplayCustomText,
|
|
15
16
|
} = props;
|
|
16
17
|
|
|
17
18
|
if (cartWillFull) {
|
|
@@ -32,15 +33,24 @@ function AddToCartDialogView(props) {
|
|
|
32
33
|
aria-describedby="alert-dialog-description"
|
|
33
34
|
>
|
|
34
35
|
<DialogContent>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
{
|
|
37
|
+
DisplayCustomText ? (
|
|
38
|
+
<DisplayCustomText
|
|
39
|
+
onYesClick={onYesClick}
|
|
40
|
+
onNoClick={onNoClick}
|
|
41
|
+
/>
|
|
42
|
+
) : (
|
|
43
|
+
<DialogContentText id="alert-dialog-description">
|
|
44
|
+
Are you sure to add All Files
|
|
45
|
+
{' '}
|
|
46
|
+
{numberOfFilesSelected}
|
|
47
|
+
{' '}
|
|
48
|
+
to cart
|
|
49
|
+
</DialogContentText>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
42
52
|
</DialogContent>
|
|
43
|
-
<DialogActions>
|
|
53
|
+
<DialogActions className="dialog_actions">
|
|
44
54
|
<Button className="yesBtn" onClick={() => onYesClick()}>
|
|
45
55
|
Yes
|
|
46
56
|
</Button>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* max two response keys
|
|
3
|
+
* add file query response handler
|
|
4
|
+
* return - list of files name/id
|
|
5
|
+
*/
|
|
6
|
+
const addFilesResponseHandler = (response, responseKeys = []) => {
|
|
7
|
+
if (responseKeys.length === 2) {
|
|
8
|
+
const data = response[responseKeys[0]];
|
|
9
|
+
if (data && data.length > 0) {
|
|
10
|
+
const isArray = Array.isArray(data[0][responseKeys[1]]);
|
|
11
|
+
const ids = data.reduce((acc, id) => {
|
|
12
|
+
if (id && id[responseKeys[1]]) {
|
|
13
|
+
// if object convert to array
|
|
14
|
+
const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
15
|
+
acc.push(...items);
|
|
16
|
+
}
|
|
17
|
+
return acc;
|
|
18
|
+
}, []);
|
|
19
|
+
return ids;
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return response[responseKeys[0]] || [];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default addFilesResponseHandler;
|
package/src/table/README.md
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
# PAGINATED TABLE COMPONENT DESIGN
|
|
2
|
-
|
|
3
|
-
### Bento core paginated table design:
|
|
4
|
-
|
|
5
|
-
* Use of UseReducer to track table state and local state to display dialog component
|
|
6
|
-
* use of useContext to access table state
|
|
7
|
-
* Limit use of props drilling
|
|
8
|
-
* Core layout defined by Bento Core table component
|
|
9
|
-
* Build on top of Mui table (demo - https://mui.com/material-ui/react-table/#custom-pagination-actions)
|
|
10
|
-
* Apply SOLID principles in react (https://konstantinlebedev.com/solid-in-react/)
|
|
11
|
-
|
|
12
|
-
## 1 UseReducer configuration
|
|
13
|
-
|
|
14
|
-
### Generate and integrate redux dispatch actions
|
|
15
|
-
```
|
|
16
|
-
const initTblState = (initailState) => ({
|
|
17
|
-
...initailState,
|
|
18
|
-
title: config.name,
|
|
19
|
-
query: config.api,
|
|
20
|
-
dataKey: config.dataKey,
|
|
21
|
-
columns: configColumn(config.columns),
|
|
22
|
-
count: dashboardStats[config.count],
|
|
23
|
-
selectedRows: [],
|
|
24
|
-
tableMsg: config.tableMsg,
|
|
25
|
-
paginationAPIField: config.paginationAPIField,
|
|
26
|
-
sortBy: config.defaultSortField,
|
|
27
|
-
sortOrder: config.defaultSortDirection,
|
|
28
|
-
rowsPerPage: 10,
|
|
29
|
-
page: 0,
|
|
30
|
-
});
|
|
31
|
-
```
|
|
32
|
-
**Paginated Table Init State TABLE-1**
|
|
33
|
-
| Table State | Required | description | Configuration |
|
|
34
|
-
| :--- | :----:| :----: | ----: |
|
|
35
|
-
| title | TRUE | table name (Case, Sample, Files), required for class name | |
|
|
36
|
-
| query | TRUE | GraphQL Query for paginated Table (e.g. GET_CASES_OVERVIEW_QUERY) | api |
|
|
37
|
-
| dataKey | TRUE | Tracking selected rows (case - dataKey: 'subject_id') | dashboardTabData/tabContainers |
|
|
38
|
-
| columns | TRUE | columns defined by dashboardTabData (tabContainers) | add fucntion attribut customCellRender/customColHeaderRender to configure custom cell (see bento frontend) |
|
|
39
|
-
| count | TRUE | Total row cound for (Cases, Samples, Files), update based on filter event | |
|
|
40
|
-
| selectedRows | TRUE | Tracks selected Rows | |
|
|
41
|
-
| tableMsg | TRUE | Display noMatch Msg | dashboardTabData/tabContainers/tableMsg |
|
|
42
|
-
| theme | FALSE | override style with themeprovider use ClassName provided by bento-core table to apply style (refer to class name table) | |
|
|
43
|
-
| paginationAPIField | TRUE | Access http response data - defined by dashboardTabData (tabContainers) | ```paginationAPIField: 'subjectOverview'```|
|
|
44
|
-
| sortBy | TRUE | default sort column | defaultSortField: 'subject_id',|
|
|
45
|
-
| sortOrder | FALSE | default sort column 'ASC' | ```defaultSortDirection: 'asc',```|
|
|
46
|
-
| rowsPerPage | FALSE | default 10 | |
|
|
47
|
-
| page | FALSE | 0 | |
|
|
48
|
-
| extendedViewConfig | FALSE | extended view of table header component | refer bento-frontend tabContainers, dashboardTabData.js |
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
### 2 Importing Component and Configuration
|
|
52
|
-
```
|
|
53
|
-
import TableView from 'bento-core/PaginationTable/PaginatedTable';
|
|
54
|
-
// active filter json structure
|
|
55
|
-
<TableView
|
|
56
|
-
initState={initTblState}
|
|
57
|
-
themeConfig={themeConfig}
|
|
58
|
-
activeFilters={activeFilters}
|
|
59
|
-
totalRowCount={dashboardStats[config.count]}
|
|
60
|
-
activeTab={activeTab}
|
|
61
|
-
/>
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**Paginated Table Props Config TABLE-2**
|
|
65
|
-
| Table | Required | description | Configuration |
|
|
66
|
-
| :--- | :----:| :----: | ----: |
|
|
67
|
-
| table state | TRUE | as describe on TABLE-1 | |
|
|
68
|
-
| viewConfig | FALSE | (Optional) table view config, set hide/diaply pagination above table header | |
|
|
69
|
-
| themeConfig | FALSE | override style with themeprovider use ClassName provided by bento-core table to apply style (refer to class name table) | |
|
|
70
|
-
| totalRowCount | TRUE | Total row cound for (Cases, Samples, Files), update based on filter event | |
|
|
71
|
-
| activeTab | TRUE | prevents http call for inactive tabs (dashboard) /set true to myFile cart | |
|
|
72
|
-
|
|
73
|
-
## 3 Table component themeConfig Configuration
|
|
74
|
-
```
|
|
75
|
-
export const tblHeader = {
|
|
76
|
-
MuiTableSortLabel: {
|
|
77
|
-
root: {
|
|
78
|
-
...define style
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const tblPgn = {
|
|
84
|
-
MuiTablePagination: {
|
|
85
|
-
root: {
|
|
86
|
-
paddingRight: '50px',
|
|
87
|
-
borderTop: '5px solid #e7e5e5',
|
|
88
|
-
borderBottom: '3px solid #e7e5e5',
|
|
89
|
-
},
|
|
90
|
-
toolbar: {
|
|
91
|
-
minHeight: '45px',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
// define mui styles for table component
|
|
96
|
-
export const themeConfig = {
|
|
97
|
-
tblHeader,
|
|
98
|
-
tblTopPgn,
|
|
99
|
-
tblPgn,
|
|
100
|
-
tblBody,
|
|
101
|
-
};
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## 3 Table state Context provider Configuration
|
|
105
|
-
```
|
|
106
|
-
Reference - TabPanel.js (bento-frontend)
|
|
107
|
-
|
|
108
|
-
import {
|
|
109
|
-
TableContextProvider,
|
|
110
|
-
TableView,
|
|
111
|
-
Wrapper,
|
|
112
|
-
} from '@bento-core/paginated-table';
|
|
113
|
-
|
|
114
|
-
const initTblState = (initailState) => ({
|
|
115
|
-
...initailState,
|
|
116
|
-
title: config.name,
|
|
117
|
-
query: config.api,
|
|
118
|
-
paginationAPIField: config.paginationAPIField,
|
|
119
|
-
dataKey: config.dataKey,
|
|
120
|
-
columns: configColumn(config.columns),
|
|
121
|
-
count: dashboardStats[config.count],
|
|
122
|
-
selectedRows: [],
|
|
123
|
-
enableRowSelection: config.enableRowSelection,
|
|
124
|
-
tableMsg: config.tableMsg,
|
|
125
|
-
sortBy: config.defaultSortField,
|
|
126
|
-
sortOrder: config.defaultSortDirection,
|
|
127
|
-
extendedViewConfig: config.extendedViewConfig,
|
|
128
|
-
rowsPerPage: 10,
|
|
129
|
-
page: 0,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
<TableContextProvider>
|
|
133
|
-
<Wrapper
|
|
134
|
-
wrapConfig={configWrapper(config, wrapperConfig)}
|
|
135
|
-
customTheme={customTheme}
|
|
136
|
-
classes={classes}
|
|
137
|
-
section={config.name}
|
|
138
|
-
>
|
|
139
|
-
<Grid container>
|
|
140
|
-
<Grid item xs={12} id={config.tableID}>
|
|
141
|
-
<TableView
|
|
142
|
-
initState={initTblState}
|
|
143
|
-
themeConfig={themeConfig}
|
|
144
|
-
queryVariables={activeFilters}
|
|
145
|
-
totalRowCount={dashboardStats[config.count]}
|
|
146
|
-
activeTab={activeTab}
|
|
147
|
-
/>
|
|
148
|
-
</Grid>
|
|
149
|
-
</Grid>
|
|
150
|
-
</Wrapper>
|
|
151
|
-
</TableContextProvider>
|
|
152
|
-
|
|
153
|
-
//child component
|
|
154
|
-
|
|
155
|
-
import { TableContext } from 'bento-core';
|
|
156
|
-
|
|
157
|
-
const tableContext = useContext(TableContext);
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
TableContextProvider provides table state to Wrapper Component or it can be used in higher parent component as needed.
|
|
161
|
-
|
|
162
|
-
####
|
|
163
|
-
|
|
164
|
-
## 4 Wrapper Configuration:
|
|
165
|
-
Wrapper component around table compnent.
|
|
166
|
-
1. ADD ALL FILES button
|
|
167
|
-
2. ADD SELECTED ROWS button
|
|
168
|
-
3. Go to My File link
|
|
169
|
-
|
|
170
|
-
```
|
|
171
|
-
/**
|
|
172
|
-
* Configuration display component based on index
|
|
173
|
-
* CAUTION: If table is in wrapper component provide position of table component
|
|
174
|
-
*/
|
|
175
|
-
export const wrapperConfig = [{
|
|
176
|
-
container: 'buttons',
|
|
177
|
-
size: 'xl',
|
|
178
|
-
clsName: 'container_header',
|
|
179
|
-
items: [
|
|
180
|
-
{
|
|
181
|
-
title: 'ADD ALL FILES',
|
|
182
|
-
clsName: 'add_all_button',
|
|
183
|
-
type: types.BUTTON,
|
|
184
|
-
role: btnTypes.ADD_ALL_FILES,
|
|
185
|
-
btnType: btnTypes.ADD_ALL_FILES,
|
|
186
|
-
conditional: false,
|
|
187
|
-
alertMessage,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
title: 'ADD SELECTED FILES',
|
|
191
|
-
clsName: 'add_selected_button',
|
|
192
|
-
type: types.BUTTON,
|
|
193
|
-
role: btnTypes.ADD_SELECTED_FILES,
|
|
194
|
-
btnType: btnTypes.ADD_SELECTED_FILES,
|
|
195
|
-
tooltipCofig: tooltipContent,
|
|
196
|
-
conditional: true,
|
|
197
|
-
}],
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
container: 'paginatedTable',
|
|
201
|
-
paginatedTable: true,
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
container: 'buttons',
|
|
205
|
-
size: 'xl',
|
|
206
|
-
clsName: 'container_footer',
|
|
207
|
-
items: [
|
|
208
|
-
{
|
|
209
|
-
title: 'ADD SELECTED FILES',
|
|
210
|
-
clsName: 'add_selected_button',
|
|
211
|
-
type: types.BUTTON,
|
|
212
|
-
role: btnTypes.ADD_SELECTED_FILES,
|
|
213
|
-
btnType: btnTypes.ADD_SELECTED_FILES,
|
|
214
|
-
tooltipCofig: tooltipContent,
|
|
215
|
-
conditional: true,
|
|
216
|
-
}],
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
container: 'buttons',
|
|
220
|
-
size: 'xl',
|
|
221
|
-
clsName: 'container_footer_link',
|
|
222
|
-
items: [
|
|
223
|
-
{
|
|
224
|
-
title: 'Go to Cart >',
|
|
225
|
-
clsName: 'go_to_cart',
|
|
226
|
-
url: '#/fileCentricCart',
|
|
227
|
-
type: types.LINK,
|
|
228
|
-
}],
|
|
229
|
-
},
|
|
230
|
-
];
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
Each item in headerConfig and footerConfig represent container
|
|
234
|
-
**container Config TABLE-3**
|
|
235
|
-
headerConfig - upper component on the table
|
|
236
|
-
footerConfig - button component on the table
|
|
237
|
-
| Attris | Required | description | Configuration |
|
|
238
|
-
| :--- | :----:| :----: | ----: |
|
|
239
|
-
| container | TRUE | describe container | |
|
|
240
|
-
| size | TRUE | container size | xl, md, sm |
|
|
241
|
-
| clsName | TRUE | class name to apply style using themeprovider | |
|
|
242
|
-
| item | TRUE | number of button component ***(refer to table 4)*** | |
|
|
243
|
-
|
|
244
|
-
**Button component Config TABLE-4**
|
|
245
|
-
headerConfig - upper component on the table
|
|
246
|
-
| Attris | Required | description | Configuration |
|
|
247
|
-
| :--- | :----:| :----: | ----: |
|
|
248
|
-
| title | TRUE | button label | 'ADD SELECTED FILES' |
|
|
249
|
-
| clsName | TRUE | class name to apply style using themeprovider | |
|
|
250
|
-
| type | TRUE | add all files or add selected files| btnTypes.ADD_SELECTED_FILES |
|
|
251
|
-
| tooltipCofig | FALSE | appears on side of the refers button | dashboardTabData/ tooltipContent |
|
|
252
|
-
|
|
253
|
-
|