@bento-core/paginated-table 1.0.1-ccdihub.15 → 1.0.1-ccdihub.151
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/PaginatedTable.js +74 -4
- package/dist/table/ServerController.js +4 -2
- package/dist/table/TableService.js +24 -3
- package/dist/table/state/Actions.js +7 -1
- package/dist/table/state/Reducer.js +4 -0
- package/dist/wrapper/Wrapper.js +15 -4
- package/dist/wrapper/WrapperService.js +1 -1
- package/dist/wrapper/components/AddAllFiles/AddAllView.js +75 -23
- package/dist/wrapper/components/AddFiles.js +6 -3
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +32 -7
- package/dist/wrapper/components/ButtonView.js +2 -2
- package/dist/wrapper/components/DownloadManifestBtn.js +4 -2
- package/dist/wrapper/components/ReduxAddFile.js +2 -1
- package/dist/wrapper/components/ReduxDownloadManifestBtn.js +16 -0
- package/package.json +3 -3
- package/src/table/PaginatedTable.js +87 -2
- package/src/table/ServerController.js +2 -2
- package/src/table/TableService.js +23 -3
- package/src/table/state/Actions.js +6 -0
- package/src/table/state/Reducer.js +5 -0
- package/src/wrapper/Wrapper.js +27 -1
- package/src/wrapper/WrapperService.js +1 -1
- package/src/wrapper/components/AddAllFiles/AddAllView.js +72 -22
- package/src/wrapper/components/AddFiles.js +3 -0
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +32 -7
- package/src/wrapper/components/ButtonView.js +1 -1
- package/src/wrapper/components/DownloadManifestBtn.js +3 -1
- package/src/wrapper/components/ReduxAddFile.js +1 -0
- package/src/wrapper/components/ReduxDownloadManifestBtn.js +11 -0
|
@@ -26,7 +26,12 @@ const PaginatedTable = _ref => {
|
|
|
26
26
|
initState,
|
|
27
27
|
activeTab = true,
|
|
28
28
|
server = true,
|
|
29
|
-
tblRows = []
|
|
29
|
+
tblRows = [],
|
|
30
|
+
navigation = () => {},
|
|
31
|
+
onSearch,
|
|
32
|
+
searchValue,
|
|
33
|
+
onSearchResultCount,
|
|
34
|
+
onColumnStateChange
|
|
30
35
|
} = _ref;
|
|
31
36
|
/**
|
|
32
37
|
* Initailize useReducer state
|
|
@@ -98,9 +103,19 @@ const PaginatedTable = _ref => {
|
|
|
98
103
|
const onRowSelectHandler = (event, row) => {
|
|
99
104
|
event.stopPropagation();
|
|
100
105
|
let selectedIds = [...table.selectedRows];
|
|
106
|
+
let hiddenSelectedRows = [...table.hiddenSelectedRows];
|
|
101
107
|
const selectedId = row[table.dataKey];
|
|
108
|
+
let hiddenNewObject = {};
|
|
109
|
+
if (table.hiddenDataKeys && table.hiddenDataKeys.length > 0) {
|
|
110
|
+
table.hiddenDataKeys.forEach(dataK => {
|
|
111
|
+
hiddenNewObject = _objectSpread(_objectSpread({}, hiddenNewObject), {}, {
|
|
112
|
+
[dataK]: row[dataK]
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
102
116
|
if (!row.isChecked) {
|
|
103
117
|
selectedIds.push(selectedId);
|
|
118
|
+
hiddenSelectedRows.push(hiddenNewObject);
|
|
104
119
|
} else {
|
|
105
120
|
selectedIds = selectedIds.reduce((acc, id) => {
|
|
106
121
|
if (selectedId !== id) {
|
|
@@ -108,10 +123,35 @@ const PaginatedTable = _ref => {
|
|
|
108
123
|
}
|
|
109
124
|
return acc;
|
|
110
125
|
}, []);
|
|
126
|
+
hiddenSelectedRows = hiddenSelectedRows.reduce((acc, hiddenObject) => {
|
|
127
|
+
if (JSON.stringify(hiddenNewObject) !== JSON.stringify(hiddenObject)) {
|
|
128
|
+
acc.push(hiddenObject);
|
|
129
|
+
}
|
|
130
|
+
return acc;
|
|
131
|
+
}, []);
|
|
111
132
|
}
|
|
112
133
|
dispatch((0, _Actions.onRowSeclect)(selectedIds));
|
|
134
|
+
dispatch((0, _Actions.onRowSelectHidden)(hiddenSelectedRows));
|
|
113
135
|
};
|
|
114
|
-
const handleToggleSelectAll = (event, Ids, includeIds) => {
|
|
136
|
+
const handleToggleSelectAll = (event, Ids, includeIds, rows) => {
|
|
137
|
+
if (event.target.checked) {
|
|
138
|
+
const filteredRows = [];
|
|
139
|
+
let hiddenNewObject = {};
|
|
140
|
+
rows.forEach(row => {
|
|
141
|
+
hiddenNewObject = {};
|
|
142
|
+
table.hiddenDataKeys.forEach(dataK => {
|
|
143
|
+
hiddenNewObject = _objectSpread(_objectSpread({}, hiddenNewObject), {}, {
|
|
144
|
+
[dataK]: row[dataK]
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
filteredRows.push(hiddenNewObject);
|
|
148
|
+
});
|
|
149
|
+
const finalHiddenRowData = [...table.hiddenSelectedRows, ...filteredRows];
|
|
150
|
+
dispatch((0, _Actions.onRowSelectHidden)(finalHiddenRowData));
|
|
151
|
+
} else {
|
|
152
|
+
const filteredHiddenRows = table.hiddenSelectedRows.filter(hiddenRow => !rows.some(row => table.hiddenDataKeys.every(dataK => hiddenRow[dataK] === row[dataK])));
|
|
153
|
+
dispatch((0, _Actions.onRowSelectHidden)(filteredHiddenRows));
|
|
154
|
+
}
|
|
115
155
|
if (event.target.checked && !includeIds) {
|
|
116
156
|
const selecedIds = Ids.concat(table.selectedRows);
|
|
117
157
|
dispatch((0, _Actions.onRowSeclect)(selecedIds));
|
|
@@ -146,6 +186,27 @@ const PaginatedTable = _ref => {
|
|
|
146
186
|
dispatch((0, _Actions.onColumnViewChange)(_objectSpread(_objectSpread({}, table), {}, {
|
|
147
187
|
columns
|
|
148
188
|
})));
|
|
189
|
+
// Save column state for persistence across search state changes
|
|
190
|
+
if (onColumnStateChange) {
|
|
191
|
+
onColumnStateChange(columns);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const handleAllColumnViewChange = checked => {
|
|
195
|
+
const columns = table.columns.map(col => {
|
|
196
|
+
const updateColumnView = _objectSpread({}, col);
|
|
197
|
+
if (!col.hideable) {
|
|
198
|
+
return updateColumnView;
|
|
199
|
+
}
|
|
200
|
+
updateColumnView.display = checked;
|
|
201
|
+
return updateColumnView;
|
|
202
|
+
});
|
|
203
|
+
dispatch((0, _Actions.onColumnViewChange)(_objectSpread(_objectSpread({}, table), {}, {
|
|
204
|
+
columns
|
|
205
|
+
})));
|
|
206
|
+
// Save column state for persistence across search state changes
|
|
207
|
+
if (onColumnStateChange) {
|
|
208
|
+
onColumnStateChange(columns);
|
|
209
|
+
}
|
|
149
210
|
};
|
|
150
211
|
/**
|
|
151
212
|
* A. client table
|
|
@@ -162,7 +223,11 @@ const PaginatedTable = _ref => {
|
|
|
162
223
|
onToggleSelectAll: handleToggleSelectAll,
|
|
163
224
|
onSortByColumn: handleSortByColumn,
|
|
164
225
|
onColumnViewChange: handleColumnViewChange,
|
|
165
|
-
|
|
226
|
+
onAllColumnViewChange: handleAllColumnViewChange,
|
|
227
|
+
themeConfig: themeConfig,
|
|
228
|
+
onSearch: onSearch,
|
|
229
|
+
searchValue: searchValue,
|
|
230
|
+
onSearchResultCount: onSearchResultCount
|
|
166
231
|
}));
|
|
167
232
|
}
|
|
168
233
|
|
|
@@ -186,7 +251,12 @@ const PaginatedTable = _ref => {
|
|
|
186
251
|
onToggleSelectAll: handleToggleSelectAll,
|
|
187
252
|
onSortByColumn: handleSortByColumn,
|
|
188
253
|
onColumnViewChange: handleColumnViewChange,
|
|
189
|
-
|
|
254
|
+
onAllColumnViewChange: handleAllColumnViewChange,
|
|
255
|
+
themeConfig: themeConfig,
|
|
256
|
+
navigation: navigation,
|
|
257
|
+
onSearch: onSearch,
|
|
258
|
+
searchValue: searchValue,
|
|
259
|
+
onSearchResultCount: onSearchResultCount
|
|
190
260
|
}));
|
|
191
261
|
};
|
|
192
262
|
var _default = PaginatedTable;
|
|
@@ -16,13 +16,15 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
16
16
|
const TableController = props => {
|
|
17
17
|
const {
|
|
18
18
|
queryVariables,
|
|
19
|
-
table
|
|
19
|
+
table,
|
|
20
|
+
onSearchResultCount
|
|
20
21
|
} = props;
|
|
21
22
|
const {
|
|
22
23
|
tableData
|
|
23
24
|
} = (0, _TableService.getTableData)({
|
|
24
25
|
queryVariables,
|
|
25
|
-
table
|
|
26
|
+
table,
|
|
27
|
+
onSearchResultCount
|
|
26
28
|
});
|
|
27
29
|
if (!tableData) {
|
|
28
30
|
return /*#__PURE__*/_react.default.createElement(_core.Container, {
|
|
@@ -58,12 +58,14 @@ const getPaginatedQueryVariables = (queryVariables, table) => {
|
|
|
58
58
|
* @param {*} queryVariables
|
|
59
59
|
* @param {*} table (table state)
|
|
60
60
|
* @param {*} tab (tab)
|
|
61
|
+
* @param {*} onSearchResultCount (callback to update search result count)
|
|
61
62
|
* @returns table data
|
|
62
63
|
*/
|
|
63
64
|
const getTableData = _ref => {
|
|
64
65
|
let {
|
|
65
66
|
queryVariables,
|
|
66
|
-
table
|
|
67
|
+
table,
|
|
68
|
+
onSearchResultCount
|
|
67
69
|
} = _ref;
|
|
68
70
|
const client = (0, _client.useApolloClient)();
|
|
69
71
|
const {
|
|
@@ -86,7 +88,26 @@ const getTableData = _ref => {
|
|
|
86
88
|
const controller = new AbortController();
|
|
87
89
|
getData().then(result => {
|
|
88
90
|
if (table.paginationAPIField && result[table.paginationAPIField]) {
|
|
89
|
-
|
|
91
|
+
const apiResult = result[table.paginationAPIField];
|
|
92
|
+
|
|
93
|
+
// Check if this is the new getFilenames structure with files and totalCount
|
|
94
|
+
if (apiResult && typeof apiResult === 'object' && 'files' in apiResult && 'totalCount' in apiResult) {
|
|
95
|
+
// Handle getFilenames response structure
|
|
96
|
+
setTableData(apiResult.files);
|
|
97
|
+
|
|
98
|
+
// Update total count for search results
|
|
99
|
+
if (onSearchResultCount && apiResult.totalCount !== undefined) {
|
|
100
|
+
onSearchResultCount(apiResult.totalCount);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
// Handle regular array response (fileOverview, etc.)
|
|
104
|
+
setTableData(apiResult);
|
|
105
|
+
|
|
106
|
+
// For non-search queries, don't update the count
|
|
107
|
+
if (onSearchResultCount) {
|
|
108
|
+
onSearchResultCount(null);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
90
111
|
} else {
|
|
91
112
|
setTableData(result);
|
|
92
113
|
}
|
|
@@ -95,7 +116,7 @@ const getTableData = _ref => {
|
|
|
95
116
|
// cancel the request before component unmounts
|
|
96
117
|
controller.abort();
|
|
97
118
|
};
|
|
98
|
-
}, [queryVariables, page, rowsPerPage, sortOrder, sortBy]);
|
|
119
|
+
}, [queryVariables, page, rowsPerPage, sortOrder, sortBy, query, table.paginationAPIField]);
|
|
99
120
|
return {
|
|
100
121
|
tableData
|
|
101
122
|
};
|
|
@@ -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.onRowSelectHidden = exports.onRowSeclect = exports.onPageChange = exports.onPageAndTotalCountChange = exports.onColumnViewChange = exports.onColumnSort = exports.onChangeSortDirection = exports.actionTypes = void 0;
|
|
7
7
|
const actionTypes = {
|
|
8
8
|
VIEW_COLUMN_CHANGE: 'VIEW_COLUMN_CHANGE',
|
|
9
9
|
ON_COLUMN_SORT: 'ON_COLUMN_SORT',
|
|
@@ -11,6 +11,7 @@ const actionTypes = {
|
|
|
11
11
|
ON_ROWS_PER_PAGE_CHANGE: 'ON_ROWS_PER_PAGE_CHANGE',
|
|
12
12
|
ON_PAGE_CHANGE: 'ON_PAGE_CHANGE',
|
|
13
13
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
14
|
+
ON_ROW_SELECT_HIDDEN: 'ON_ROW_SELECT_HIDDEN',
|
|
14
15
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
15
16
|
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE'
|
|
16
17
|
};
|
|
@@ -50,6 +51,11 @@ const onRowSeclect = rows => ({
|
|
|
50
51
|
payload: rows
|
|
51
52
|
});
|
|
52
53
|
exports.onRowSeclect = onRowSeclect;
|
|
54
|
+
const onRowSelectHidden = rows => ({
|
|
55
|
+
type: actionTypes.ON_ROW_SELECT_HIDDEN,
|
|
56
|
+
payload: rows
|
|
57
|
+
});
|
|
58
|
+
exports.onRowSelectHidden = onRowSelectHidden;
|
|
53
59
|
const setTotalRowCount = count => ({
|
|
54
60
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
55
61
|
payload: count
|
|
@@ -36,6 +36,10 @@ const reducer = (state, action) => {
|
|
|
36
36
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
37
37
|
selectedRows: payload
|
|
38
38
|
});
|
|
39
|
+
case _Actions.actionTypes.ON_ROW_SELECT_HIDDEN:
|
|
40
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
41
|
+
hiddenSelectedRows: payload
|
|
42
|
+
});
|
|
39
43
|
case _Actions.actionTypes.ON_PAGE_AND_TOTAL_COUNT_CHANGE:
|
|
40
44
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
41
45
|
totalRowCount: payload.totalRowCount,
|
package/dist/wrapper/Wrapper.js
CHANGED
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _core = require("@material-ui/core");
|
|
9
9
|
var _ButtonView = _interopRequireDefault(require("./components/ButtonView"));
|
|
10
10
|
var _TextFieldView = _interopRequireDefault(require("./components/TextFieldView"));
|
|
11
|
+
var _TooltipView = _interopRequireDefault(require("./components/TooltipView"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
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
14
|
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; }
|
|
@@ -77,7 +78,10 @@ const Text = _ref2 => {
|
|
|
77
78
|
const ViewComponent = props => {
|
|
78
79
|
const {
|
|
79
80
|
type,
|
|
80
|
-
customViewElem
|
|
81
|
+
customViewElem,
|
|
82
|
+
CohortViewElem,
|
|
83
|
+
tooltipCofig,
|
|
84
|
+
section
|
|
81
85
|
} = props;
|
|
82
86
|
switch (type) {
|
|
83
87
|
case types.BUTTON:
|
|
@@ -92,6 +96,11 @@ const ViewComponent = props => {
|
|
|
92
96
|
return /*#__PURE__*/_react.default.createElement(_TextFieldView.default, props);
|
|
93
97
|
case types.CUSTOM_ELEM:
|
|
94
98
|
return customViewElem();
|
|
99
|
+
case types.COHORT_ELEM:
|
|
100
|
+
if (section !== 'Participants') {
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
102
|
+
}
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(CohortViewElem, null), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props));
|
|
95
104
|
default:
|
|
96
105
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
97
106
|
}
|
|
@@ -141,7 +150,7 @@ const CustomLayout = props => {
|
|
|
141
150
|
}, /*#__PURE__*/_react.default.createElement(_core.Container, {
|
|
142
151
|
maxWidth: container.size,
|
|
143
152
|
className: container.clsName
|
|
144
|
-
}, container.items.map(item => /*#__PURE__*/_react.default.createElement(ViewComponent, _extends({}, item, props)))));
|
|
153
|
+
}, container.text && /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("span", null, container.textTitle), container.text), container.items.map(item => /*#__PURE__*/_react.default.createElement(ViewComponent, _extends({}, item, props)))));
|
|
145
154
|
}));
|
|
146
155
|
};
|
|
147
156
|
const CustomWrapper = props => {
|
|
@@ -152,7 +161,8 @@ const CustomWrapper = props => {
|
|
|
152
161
|
section,
|
|
153
162
|
classes,
|
|
154
163
|
activeFilters,
|
|
155
|
-
tblDispatch
|
|
164
|
+
tblDispatch,
|
|
165
|
+
fileCount
|
|
156
166
|
} = props;
|
|
157
167
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(CustomLayout, {
|
|
158
168
|
configs: wrapConfig,
|
|
@@ -160,7 +170,8 @@ const CustomWrapper = props => {
|
|
|
160
170
|
section: section,
|
|
161
171
|
classes: classes,
|
|
162
172
|
activeFilters: activeFilters,
|
|
163
|
-
tblDispatch: tblDispatch
|
|
173
|
+
tblDispatch: tblDispatch,
|
|
174
|
+
fileCount: fileCount
|
|
164
175
|
}, children));
|
|
165
176
|
};
|
|
166
177
|
var _default = CustomWrapper;
|
|
@@ -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 = 200000;
|
|
18
18
|
return queryVariables;
|
|
19
19
|
};
|
|
20
20
|
exports.getQueryVariables = getQueryVariables;
|
|
@@ -40,7 +40,18 @@ const ToolTipView = props => {
|
|
|
40
40
|
alt: alt
|
|
41
41
|
}));
|
|
42
42
|
};
|
|
43
|
+
|
|
44
|
+
// const checkDuplicate = (cartFiles, ids) => {
|
|
45
|
+
// const newIds = [];
|
|
46
|
+
// for (let i = 0; i < ids.length; i += 1) {
|
|
47
|
+
// if (!cartFiles.includes(ids[i])) {
|
|
48
|
+
// newIds.push(ids[i]);
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
// return newIds;
|
|
52
|
+
// };
|
|
43
53
|
exports.ToolTipView = ToolTipView;
|
|
54
|
+
const checkDuplicate = (cartFiles, ids) => ids.filter(id => !cartFiles[id]);
|
|
44
55
|
const AddAllFilesComponent = props => {
|
|
45
56
|
const {
|
|
46
57
|
title,
|
|
@@ -53,7 +64,9 @@ const AddAllFilesComponent = props => {
|
|
|
53
64
|
setAlterDisplay,
|
|
54
65
|
setOpenSnackbar,
|
|
55
66
|
client,
|
|
56
|
-
tooltipCofig
|
|
67
|
+
tooltipCofig,
|
|
68
|
+
fileCount,
|
|
69
|
+
cartFiles
|
|
57
70
|
} = props;
|
|
58
71
|
/**
|
|
59
72
|
* conditionally display dialog view
|
|
@@ -61,6 +74,16 @@ const AddAllFilesComponent = props => {
|
|
|
61
74
|
const [openAddDialog, setOpen] = (0, _react.useState)(false);
|
|
62
75
|
const toggleOpen = () => setOpen(!openAddDialog);
|
|
63
76
|
const [addFilesId, setAddFilesId] = (0, _react.useState)([]);
|
|
77
|
+
const [isDataloading, setIsDataloading] = (0, _react.useState)(false);
|
|
78
|
+
const cartFilesDict = {};
|
|
79
|
+
cartFiles.forEach(file => {
|
|
80
|
+
cartFilesDict[file] = true;
|
|
81
|
+
});
|
|
82
|
+
const backdropCls = {
|
|
83
|
+
width: '100%',
|
|
84
|
+
zIndex: 99999,
|
|
85
|
+
background: 'rgba(0, 0, 0, 0.1)'
|
|
86
|
+
};
|
|
64
87
|
|
|
65
88
|
/**
|
|
66
89
|
* verify and set file ids
|
|
@@ -71,29 +94,52 @@ const AddAllFilesComponent = props => {
|
|
|
71
94
|
variables: activeFilters,
|
|
72
95
|
query: addFileQuery
|
|
73
96
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
const upperLimit = 200000;
|
|
98
|
+
const cartCount = cartFiles.length;
|
|
99
|
+
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
100
|
+
setIsDataloading(true);
|
|
101
|
+
fileIds().then(response => {
|
|
102
|
+
const data = response[responseKeys[0]];
|
|
103
|
+
if (data && data.length > 0) {
|
|
104
|
+
const isArray = Array.isArray(data[0][responseKeys[1]]);
|
|
105
|
+
// const idsInitial = data.reduce((acc, id) => {
|
|
106
|
+
// if (id && id[responseKeys[1]]) {
|
|
107
|
+
// // if object convert to array
|
|
108
|
+
// const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
109
|
+
// acc.push(...items);
|
|
110
|
+
// }
|
|
111
|
+
// return acc;
|
|
112
|
+
// }, []);
|
|
113
|
+
const idsInitial = [];
|
|
114
|
+
data.forEach(item => {
|
|
115
|
+
if (item && item[responseKeys[1]]) {
|
|
116
|
+
const items = isArray ? item[responseKeys[1]] : [item[responseKeys[1]]];
|
|
117
|
+
items.forEach(it => {
|
|
118
|
+
idsInitial.push(it);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const ids = [...new Set(idsInitial)];
|
|
123
|
+
if (cartCount + ids.length <= upperLimit) {
|
|
124
|
+
setIsDataloading(false);
|
|
125
|
+
setOpen(true);
|
|
126
|
+
setAddFilesId(ids);
|
|
127
|
+
} else {
|
|
128
|
+
const newIds = checkDuplicate(cartFilesDict, ids);
|
|
129
|
+
setIsDataloading(false);
|
|
130
|
+
if (cartCount + newIds.length <= upperLimit) {
|
|
131
|
+
setOpen(true);
|
|
132
|
+
setAddFilesId(newIds);
|
|
133
|
+
} else {
|
|
134
|
+
setAlterDisplay(true);
|
|
135
|
+
}
|
|
83
136
|
}
|
|
84
|
-
return acc;
|
|
85
|
-
}, []);
|
|
86
|
-
if (ids.length > 1000) {
|
|
87
|
-
setAlterDisplay(true);
|
|
88
|
-
} else {
|
|
89
|
-
setOpen(true);
|
|
90
|
-
setAddFilesId(ids);
|
|
91
137
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
138
|
+
return [];
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
setAlterDisplay(true);
|
|
142
|
+
}
|
|
97
143
|
};
|
|
98
144
|
|
|
99
145
|
/**
|
|
@@ -112,7 +158,13 @@ const AddAllFilesComponent = props => {
|
|
|
112
158
|
open: openAddDialog,
|
|
113
159
|
onYesClick: addFilesToCart,
|
|
114
160
|
onNoClick: toggleOpen
|
|
115
|
-
})
|
|
161
|
+
}), /*#__PURE__*/_react.default.createElement(_core.Backdrop, {
|
|
162
|
+
className: backdropCls,
|
|
163
|
+
style: backdropCls,
|
|
164
|
+
open: isDataloading
|
|
165
|
+
}, /*#__PURE__*/_react.default.createElement(_core.CircularProgress, {
|
|
166
|
+
color: "inherit"
|
|
167
|
+
})));
|
|
116
168
|
};
|
|
117
169
|
var _default = AddAllFilesComponent;
|
|
118
170
|
exports.default = _default;
|
|
@@ -28,7 +28,8 @@ const AddFilesView = props => {
|
|
|
28
28
|
const {
|
|
29
29
|
btnType,
|
|
30
30
|
count,
|
|
31
|
-
alertMessage
|
|
31
|
+
alertMessage,
|
|
32
|
+
cartFiles
|
|
32
33
|
} = props;
|
|
33
34
|
/**
|
|
34
35
|
* snackbar state
|
|
@@ -46,11 +47,13 @@ const AddFilesView = props => {
|
|
|
46
47
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, btnTypes.ADD_SELECTED_FILES === btnType && /*#__PURE__*/_react.default.createElement(_AddSelectedFilesController.default, _extends({}, props, {
|
|
47
48
|
client: client,
|
|
48
49
|
setAlterDisplay: setAlterDisplay,
|
|
49
|
-
setOpenSnackbar: setOpenSnackbar
|
|
50
|
+
setOpenSnackbar: setOpenSnackbar,
|
|
51
|
+
cartFiles: cartFiles
|
|
50
52
|
})), btnTypes.ADD_ALL_FILES === btnType && /*#__PURE__*/_react.default.createElement(_AddAllView.default, _extends({}, props, {
|
|
51
53
|
client: client,
|
|
52
54
|
setAlterDisplay: setAlterDisplay,
|
|
53
|
-
setOpenSnackbar: setOpenSnackbar
|
|
55
|
+
setOpenSnackbar: setOpenSnackbar,
|
|
56
|
+
cartFiles: cartFiles
|
|
54
57
|
})), /*#__PURE__*/_react.default.createElement(_Snackbar.default, {
|
|
55
58
|
open: openSnackbar,
|
|
56
59
|
count: count,
|
|
@@ -16,6 +16,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
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
17
|
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; }
|
|
18
18
|
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); }
|
|
19
|
+
const checkDuplicate = (cartFiles, ids) => {
|
|
20
|
+
let duplicateCount = 0;
|
|
21
|
+
for (let i = 0; i < cartFiles.length; i += 1) {
|
|
22
|
+
if (ids.includes(cartFiles[i])) {
|
|
23
|
+
duplicateCount += 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return duplicateCount;
|
|
27
|
+
};
|
|
19
28
|
const AddSelectedFilesController = props => {
|
|
20
29
|
const {
|
|
21
30
|
clsName,
|
|
@@ -26,7 +35,8 @@ const AddSelectedFilesController = props => {
|
|
|
26
35
|
addFiles,
|
|
27
36
|
setOpenSnackbar,
|
|
28
37
|
setAlterDisplay,
|
|
29
|
-
client
|
|
38
|
+
client,
|
|
39
|
+
cartFiles
|
|
30
40
|
} = props;
|
|
31
41
|
const tableContext = (0, _react.useContext)(_ContextProvider.TableContext);
|
|
32
42
|
const {
|
|
@@ -46,14 +56,29 @@ const AddSelectedFilesController = props => {
|
|
|
46
56
|
fileIds: selectedRows,
|
|
47
57
|
query: addFileQuery
|
|
48
58
|
});
|
|
59
|
+
const cartCount = cartFiles.length;
|
|
49
60
|
fileIds().then(response => {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
const idsInitial = response[responseKeys[0]] || [];
|
|
62
|
+
const ids = [...new Set(idsInitial)];
|
|
63
|
+
const fileCount = ids.length;
|
|
64
|
+
const upperLimit = 200000;
|
|
65
|
+
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
66
|
+
if (cartCount + fileCount <= upperLimit) {
|
|
67
|
+
addFiles(ids);
|
|
68
|
+
setOpenSnackbar(true);
|
|
69
|
+
dispatch((0, _Actions.onRowSeclect)([]));
|
|
70
|
+
} else {
|
|
71
|
+
const duplicate = checkDuplicate(cartFiles, ids);
|
|
72
|
+
if (cartCount + fileCount - duplicate <= upperLimit) {
|
|
73
|
+
addFiles(ids);
|
|
74
|
+
setOpenSnackbar(true);
|
|
75
|
+
dispatch((0, _Actions.onRowSeclect)([]));
|
|
76
|
+
} else {
|
|
77
|
+
setAlterDisplay(true);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
53
80
|
} else {
|
|
54
|
-
|
|
55
|
-
setOpenSnackbar(true);
|
|
56
|
-
dispatch((0, _Actions.onRowSeclect)([]));
|
|
81
|
+
setAlterDisplay(true);
|
|
57
82
|
}
|
|
58
83
|
});
|
|
59
84
|
};
|
|
@@ -7,14 +7,14 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _AddFiles = require("./AddFiles");
|
|
9
9
|
var _ReduxAddFile = _interopRequireDefault(require("./ReduxAddFile"));
|
|
10
|
-
var
|
|
10
|
+
var _ReduxDownloadManifestBtn = _interopRequireDefault(require("./ReduxDownloadManifestBtn"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
const ButtonView = props => {
|
|
13
13
|
const {
|
|
14
14
|
btnType
|
|
15
15
|
} = props;
|
|
16
16
|
if (_AddFiles.btnTypes.DOWNLOAD_MANIFEST === btnType) {
|
|
17
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement(_ReduxDownloadManifestBtn.default, props);
|
|
18
18
|
}
|
|
19
19
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ReduxAddFile.default, props));
|
|
20
20
|
};
|
|
@@ -21,7 +21,8 @@ const DownloadManifestView = props => {
|
|
|
21
21
|
const {
|
|
22
22
|
tooltipCofig,
|
|
23
23
|
clsName,
|
|
24
|
-
title
|
|
24
|
+
title,
|
|
25
|
+
cartFiles
|
|
25
26
|
} = props;
|
|
26
27
|
/**
|
|
27
28
|
* get cart state
|
|
@@ -36,7 +37,7 @@ const DownloadManifestView = props => {
|
|
|
36
37
|
const getQueryVeriables = queryVariables => {
|
|
37
38
|
const variables = _objectSpread({}, queryVariables);
|
|
38
39
|
variables.offset = 0;
|
|
39
|
-
variables.first =
|
|
40
|
+
variables.first = 200000;
|
|
40
41
|
return variables;
|
|
41
42
|
};
|
|
42
43
|
const client = (0, _client.useApolloClient)();
|
|
@@ -67,6 +68,7 @@ const DownloadManifestView = props => {
|
|
|
67
68
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
|
|
68
69
|
className: clsName,
|
|
69
70
|
disableRipple: true,
|
|
71
|
+
disabled: cartFiles.length === 0,
|
|
70
72
|
onClick: () => DocumentDownload()
|
|
71
73
|
}, title), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props));
|
|
72
74
|
};
|
|
@@ -15,7 +15,8 @@ const AddFilesRedux = props => /*#__PURE__*/_react.default.createElement(_AddFil
|
|
|
15
15
|
* create query variable with actie filters
|
|
16
16
|
*/
|
|
17
17
|
const mapStateToProps = state => ({
|
|
18
|
-
count: state.cartReducer && state.cartReducer.count
|
|
18
|
+
count: state.cartReducer && state.cartReducer.count,
|
|
19
|
+
cartFiles: state.cartReducer && state.cartReducer.filesId
|
|
19
20
|
});
|
|
20
21
|
const mapDispatchToProps = dispatch => ({
|
|
21
22
|
addFiles: files => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactRedux = require("react-redux");
|
|
9
|
+
var _DownloadManifestBtn = _interopRequireDefault(require("./DownloadManifestBtn"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const DownloadManifestRedux = props => /*#__PURE__*/_react.default.createElement(_DownloadManifestBtn.default, props);
|
|
12
|
+
const mapStateToProps = state => ({
|
|
13
|
+
cartFiles: state.cartReducer && state.cartReducer.filesId
|
|
14
|
+
});
|
|
15
|
+
var _default = (0, _reactRedux.connect)(mapStateToProps)(DownloadManifestRedux);
|
|
16
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/paginated-table",
|
|
3
|
-
"version": "1.0.1-ccdihub.
|
|
3
|
+
"version": "1.0.1-ccdihub.151",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@bento-core/cart": "
|
|
19
|
-
"@bento-core/table": "1.0.1-ccdihub.
|
|
18
|
+
"@bento-core/cart": "1.0.1-ccdihub.9",
|
|
19
|
+
"@bento-core/table": "1.0.1-ccdihub.120",
|
|
20
20
|
"@bento-core/tool-tip": "^1.0.0",
|
|
21
21
|
"@bento-core/util": "^1.0.0"
|
|
22
22
|
},
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
onColumnSort,
|
|
10
10
|
onPageAndTotalCountChange,
|
|
11
11
|
onColumnViewChange,
|
|
12
|
+
onRowSelectHidden,
|
|
12
13
|
} from './state/Actions';
|
|
13
14
|
import { TableContext } from './ContextProvider';
|
|
14
15
|
import reducer from './state/Reducer';
|
|
@@ -21,6 +22,11 @@ const PaginatedTable = ({
|
|
|
21
22
|
activeTab = true,
|
|
22
23
|
server = true,
|
|
23
24
|
tblRows = [],
|
|
25
|
+
navigation = () => {},
|
|
26
|
+
onSearch,
|
|
27
|
+
searchValue,
|
|
28
|
+
onSearchResultCount,
|
|
29
|
+
onColumnStateChange,
|
|
24
30
|
}) => {
|
|
25
31
|
/**
|
|
26
32
|
* Initailize useReducer state
|
|
@@ -83,9 +89,24 @@ const PaginatedTable = ({
|
|
|
83
89
|
const onRowSelectHandler = (event, row) => {
|
|
84
90
|
event.stopPropagation();
|
|
85
91
|
let selectedIds = [...table.selectedRows];
|
|
92
|
+
let hiddenSelectedRows = [...table.hiddenSelectedRows];
|
|
93
|
+
|
|
86
94
|
const selectedId = row[table.dataKey];
|
|
95
|
+
|
|
96
|
+
let hiddenNewObject = {};
|
|
97
|
+
|
|
98
|
+
if (table.hiddenDataKeys && table.hiddenDataKeys.length > 0) {
|
|
99
|
+
table.hiddenDataKeys.forEach((dataK) => {
|
|
100
|
+
hiddenNewObject = {
|
|
101
|
+
...hiddenNewObject,
|
|
102
|
+
[dataK]: row[dataK],
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
87
107
|
if (!row.isChecked) {
|
|
88
108
|
selectedIds.push(selectedId);
|
|
109
|
+
hiddenSelectedRows.push(hiddenNewObject);
|
|
89
110
|
} else {
|
|
90
111
|
selectedIds = selectedIds.reduce((acc, id) => {
|
|
91
112
|
if (selectedId !== id) {
|
|
@@ -93,11 +114,42 @@ const PaginatedTable = ({
|
|
|
93
114
|
}
|
|
94
115
|
return acc;
|
|
95
116
|
}, []);
|
|
117
|
+
|
|
118
|
+
hiddenSelectedRows = hiddenSelectedRows.reduce((acc, hiddenObject) => {
|
|
119
|
+
if (JSON.stringify(hiddenNewObject) !== JSON.stringify(hiddenObject)) {
|
|
120
|
+
acc.push(hiddenObject);
|
|
121
|
+
}
|
|
122
|
+
return acc;
|
|
123
|
+
}, []);
|
|
96
124
|
}
|
|
97
125
|
dispatch(onRowSeclect(selectedIds));
|
|
126
|
+
dispatch(onRowSelectHidden(hiddenSelectedRows));
|
|
98
127
|
};
|
|
99
128
|
|
|
100
|
-
const handleToggleSelectAll = (event, Ids, includeIds) => {
|
|
129
|
+
const handleToggleSelectAll = (event, Ids, includeIds, rows) => {
|
|
130
|
+
if (event.target.checked) {
|
|
131
|
+
const filteredRows = [];
|
|
132
|
+
let hiddenNewObject = {};
|
|
133
|
+
rows.forEach((row) => {
|
|
134
|
+
hiddenNewObject = {};
|
|
135
|
+
table.hiddenDataKeys.forEach((dataK) => {
|
|
136
|
+
hiddenNewObject = {
|
|
137
|
+
...hiddenNewObject,
|
|
138
|
+
[dataK]: row[dataK],
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
filteredRows.push(hiddenNewObject);
|
|
142
|
+
});
|
|
143
|
+
const finalHiddenRowData = [...table.hiddenSelectedRows, ...filteredRows];
|
|
144
|
+
dispatch(onRowSelectHidden(finalHiddenRowData));
|
|
145
|
+
} else {
|
|
146
|
+
const filteredHiddenRows = table.hiddenSelectedRows.filter((hiddenRow) => (
|
|
147
|
+
!rows.some((row) => (
|
|
148
|
+
table.hiddenDataKeys.every((dataK) => hiddenRow[dataK] === row[dataK])))));
|
|
149
|
+
|
|
150
|
+
dispatch(onRowSelectHidden(filteredHiddenRows));
|
|
151
|
+
}
|
|
152
|
+
|
|
101
153
|
if (event.target.checked && !includeIds) {
|
|
102
154
|
const selecedIds = Ids.concat(table.selectedRows);
|
|
103
155
|
dispatch(onRowSeclect(selecedIds));
|
|
@@ -106,7 +158,6 @@ const PaginatedTable = ({
|
|
|
106
158
|
dispatch(onRowSeclect(filterIds));
|
|
107
159
|
}
|
|
108
160
|
};
|
|
109
|
-
|
|
110
161
|
const handleSortByColumn = (column, order) => {
|
|
111
162
|
const { sortBy } = table;
|
|
112
163
|
const sort = (order === 'asc' && sortBy === column) ? 'desc' : 'asc';
|
|
@@ -129,6 +180,31 @@ const PaginatedTable = ({
|
|
|
129
180
|
...table,
|
|
130
181
|
columns,
|
|
131
182
|
}));
|
|
183
|
+
// Save column state for persistence across search state changes
|
|
184
|
+
if (onColumnStateChange) {
|
|
185
|
+
onColumnStateChange(columns);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const handleAllColumnViewChange = (checked) => {
|
|
190
|
+
const columns = table.columns.map((col) => {
|
|
191
|
+
const updateColumnView = { ...col };
|
|
192
|
+
|
|
193
|
+
if (!col.hideable) {
|
|
194
|
+
return updateColumnView;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
updateColumnView.display = checked;
|
|
198
|
+
return updateColumnView;
|
|
199
|
+
});
|
|
200
|
+
dispatch(onColumnViewChange({
|
|
201
|
+
...table,
|
|
202
|
+
columns,
|
|
203
|
+
}));
|
|
204
|
+
// Save column state for persistence across search state changes
|
|
205
|
+
if (onColumnStateChange) {
|
|
206
|
+
onColumnStateChange(columns);
|
|
207
|
+
}
|
|
132
208
|
};
|
|
133
209
|
/**
|
|
134
210
|
* A. client table
|
|
@@ -147,7 +223,11 @@ const PaginatedTable = ({
|
|
|
147
223
|
onToggleSelectAll={handleToggleSelectAll}
|
|
148
224
|
onSortByColumn={handleSortByColumn}
|
|
149
225
|
onColumnViewChange={handleColumnViewChange}
|
|
226
|
+
onAllColumnViewChange={handleAllColumnViewChange}
|
|
150
227
|
themeConfig={themeConfig}
|
|
228
|
+
onSearch={onSearch}
|
|
229
|
+
searchValue={searchValue}
|
|
230
|
+
onSearchResultCount={onSearchResultCount}
|
|
151
231
|
/>
|
|
152
232
|
</>
|
|
153
233
|
);
|
|
@@ -176,7 +256,12 @@ const PaginatedTable = ({
|
|
|
176
256
|
onToggleSelectAll={handleToggleSelectAll}
|
|
177
257
|
onSortByColumn={handleSortByColumn}
|
|
178
258
|
onColumnViewChange={handleColumnViewChange}
|
|
259
|
+
onAllColumnViewChange={handleAllColumnViewChange}
|
|
179
260
|
themeConfig={themeConfig}
|
|
261
|
+
navigation={navigation}
|
|
262
|
+
onSearch={onSearch}
|
|
263
|
+
searchValue={searchValue}
|
|
264
|
+
onSearchResultCount={onSearchResultCount}
|
|
180
265
|
/>
|
|
181
266
|
</>
|
|
182
267
|
);
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
* Updates table row when table state is changed 1. (paginated action) and 2. filter action
|
|
14
14
|
*/
|
|
15
15
|
const TableController = ((props) => {
|
|
16
|
-
const { queryVariables, table } = props;
|
|
17
|
-
const { tableData } = getTableData({ queryVariables, table });
|
|
16
|
+
const { queryVariables, table, onSearchResultCount } = props;
|
|
17
|
+
const { tableData } = getTableData({ queryVariables, table, onSearchResultCount });
|
|
18
18
|
if (!tableData) {
|
|
19
19
|
return (
|
|
20
20
|
<Container maxWidth="xl">
|
|
@@ -41,9 +41,10 @@ const getPaginatedQueryVariables = (queryVariables, table) => {
|
|
|
41
41
|
* @param {*} queryVariables
|
|
42
42
|
* @param {*} table (table state)
|
|
43
43
|
* @param {*} tab (tab)
|
|
44
|
+
* @param {*} onSearchResultCount (callback to update search result count)
|
|
44
45
|
* @returns table data
|
|
45
46
|
*/
|
|
46
|
-
export const getTableData = ({ queryVariables, table }) => {
|
|
47
|
+
export const getTableData = ({ queryVariables, table, onSearchResultCount }) => {
|
|
47
48
|
const client = useApolloClient();
|
|
48
49
|
const {
|
|
49
50
|
page,
|
|
@@ -66,7 +67,26 @@ export const getTableData = ({ queryVariables, table }) => {
|
|
|
66
67
|
const controller = new AbortController();
|
|
67
68
|
getData().then((result) => {
|
|
68
69
|
if (table.paginationAPIField && result[table.paginationAPIField]) {
|
|
69
|
-
|
|
70
|
+
const apiResult = result[table.paginationAPIField];
|
|
71
|
+
|
|
72
|
+
// Check if this is the new getFilenames structure with files and totalCount
|
|
73
|
+
if (apiResult && typeof apiResult === 'object' && 'files' in apiResult && 'totalCount' in apiResult) {
|
|
74
|
+
// Handle getFilenames response structure
|
|
75
|
+
setTableData(apiResult.files);
|
|
76
|
+
|
|
77
|
+
// Update total count for search results
|
|
78
|
+
if (onSearchResultCount && apiResult.totalCount !== undefined) {
|
|
79
|
+
onSearchResultCount(apiResult.totalCount);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
// Handle regular array response (fileOverview, etc.)
|
|
83
|
+
setTableData(apiResult);
|
|
84
|
+
|
|
85
|
+
// For non-search queries, don't update the count
|
|
86
|
+
if (onSearchResultCount) {
|
|
87
|
+
onSearchResultCount(null);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
70
90
|
} else {
|
|
71
91
|
setTableData(result);
|
|
72
92
|
}
|
|
@@ -75,6 +95,6 @@ export const getTableData = ({ queryVariables, table }) => {
|
|
|
75
95
|
// cancel the request before component unmounts
|
|
76
96
|
controller.abort();
|
|
77
97
|
};
|
|
78
|
-
}, [queryVariables, page, rowsPerPage, sortOrder, sortBy]);
|
|
98
|
+
}, [queryVariables, page, rowsPerPage, sortOrder, sortBy, query, table.paginationAPIField]);
|
|
79
99
|
return { tableData };
|
|
80
100
|
};
|
|
@@ -5,6 +5,7 @@ export const actionTypes = {
|
|
|
5
5
|
ON_ROWS_PER_PAGE_CHANGE: 'ON_ROWS_PER_PAGE_CHANGE',
|
|
6
6
|
ON_PAGE_CHANGE: 'ON_PAGE_CHANGE',
|
|
7
7
|
ON_ROW_SELECT: 'ON_ROW_SELECT',
|
|
8
|
+
ON_ROW_SELECT_HIDDEN: 'ON_ROW_SELECT_HIDDEN',
|
|
8
9
|
SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
|
|
9
10
|
ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
|
|
10
11
|
};
|
|
@@ -44,6 +45,11 @@ export const onRowSeclect = (rows) => ({
|
|
|
44
45
|
payload: rows,
|
|
45
46
|
});
|
|
46
47
|
|
|
48
|
+
export const onRowSelectHidden = (rows) => ({
|
|
49
|
+
type: actionTypes.ON_ROW_SELECT_HIDDEN,
|
|
50
|
+
payload: rows,
|
|
51
|
+
});
|
|
52
|
+
|
|
47
53
|
export const setTotalRowCount = (count) => ({
|
|
48
54
|
type: actionTypes.SET_TOTAL_ROW_COUNT,
|
|
49
55
|
payload: count,
|
|
@@ -30,6 +30,11 @@ const reducer = (state, action) => {
|
|
|
30
30
|
...state,
|
|
31
31
|
selectedRows: payload,
|
|
32
32
|
};
|
|
33
|
+
case actionTypes.ON_ROW_SELECT_HIDDEN:
|
|
34
|
+
return {
|
|
35
|
+
...state,
|
|
36
|
+
hiddenSelectedRows: payload,
|
|
37
|
+
};
|
|
33
38
|
case actionTypes.ON_PAGE_AND_TOTAL_COUNT_CHANGE:
|
|
34
39
|
return {
|
|
35
40
|
...state,
|
package/src/wrapper/Wrapper.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@material-ui/core';
|
|
8
8
|
import ButtonView from './components/ButtonView';
|
|
9
9
|
import TextFieldView from './components/TextFieldView';
|
|
10
|
+
import ToolTipView from './components/TooltipView';
|
|
10
11
|
|
|
11
12
|
export const types = {
|
|
12
13
|
BUTTON: 'BUTTON',
|
|
@@ -55,7 +56,9 @@ const Text = ({
|
|
|
55
56
|
* @returns custom component based on configuration
|
|
56
57
|
*/
|
|
57
58
|
export const ViewComponent = (props) => {
|
|
58
|
-
const {
|
|
59
|
+
const {
|
|
60
|
+
type, customViewElem, CohortViewElem, tooltipCofig, section,
|
|
61
|
+
} = props;
|
|
59
62
|
switch (type) {
|
|
60
63
|
case types.BUTTON:
|
|
61
64
|
return (<ButtonView {...props} />);
|
|
@@ -69,6 +72,18 @@ export const ViewComponent = (props) => {
|
|
|
69
72
|
return <TextFieldView {...props} />;
|
|
70
73
|
case types.CUSTOM_ELEM:
|
|
71
74
|
return customViewElem();
|
|
75
|
+
case types.COHORT_ELEM:
|
|
76
|
+
if (section !== 'Participants') {
|
|
77
|
+
return (
|
|
78
|
+
<></>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
<CohortViewElem />
|
|
84
|
+
{tooltipCofig && (<ToolTipView {...props} />)}
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
72
87
|
default:
|
|
73
88
|
return <></>;
|
|
74
89
|
}
|
|
@@ -126,6 +141,15 @@ const CustomLayout = (props) => {
|
|
|
126
141
|
maxWidth={container.size}
|
|
127
142
|
className={container.clsName}
|
|
128
143
|
>
|
|
144
|
+
{
|
|
145
|
+
container.text
|
|
146
|
+
&& (
|
|
147
|
+
<p>
|
|
148
|
+
<span>{container.textTitle}</span>
|
|
149
|
+
{container.text}
|
|
150
|
+
</p>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
129
153
|
{container.items.map((item) => (
|
|
130
154
|
<ViewComponent
|
|
131
155
|
{...item}
|
|
@@ -150,6 +174,7 @@ const CustomWrapper = (props) => {
|
|
|
150
174
|
classes,
|
|
151
175
|
activeFilters,
|
|
152
176
|
tblDispatch,
|
|
177
|
+
fileCount,
|
|
153
178
|
} = props;
|
|
154
179
|
return (
|
|
155
180
|
<>
|
|
@@ -160,6 +185,7 @@ const CustomWrapper = (props) => {
|
|
|
160
185
|
classes={classes}
|
|
161
186
|
activeFilters={activeFilters}
|
|
162
187
|
tblDispatch={tblDispatch}
|
|
188
|
+
fileCount={fileCount}
|
|
163
189
|
>
|
|
164
190
|
{children}
|
|
165
191
|
</CustomLayout>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import ToolTip from '@bento-core/tool-tip';
|
|
3
|
-
import { Button } from '@material-ui/core';
|
|
3
|
+
import { Button, Backdrop, CircularProgress } from '@material-ui/core';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { getFilesID } from '../../WrapperService';
|
|
6
6
|
import AddToCartDialogView from '../AddToCartDialog/AddToCartDialogView';
|
|
@@ -34,6 +34,18 @@ export const ToolTipView = (props) => {
|
|
|
34
34
|
);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
// const checkDuplicate = (cartFiles, ids) => {
|
|
38
|
+
// const newIds = [];
|
|
39
|
+
// for (let i = 0; i < ids.length; i += 1) {
|
|
40
|
+
// if (!cartFiles.includes(ids[i])) {
|
|
41
|
+
// newIds.push(ids[i]);
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
// return newIds;
|
|
45
|
+
// };
|
|
46
|
+
|
|
47
|
+
const checkDuplicate = (cartFiles, ids) => (ids.filter((id) => !cartFiles[id]));
|
|
48
|
+
|
|
37
49
|
const AddAllFilesComponent = (props) => {
|
|
38
50
|
const {
|
|
39
51
|
title,
|
|
@@ -47,6 +59,8 @@ const AddAllFilesComponent = (props) => {
|
|
|
47
59
|
setOpenSnackbar,
|
|
48
60
|
client,
|
|
49
61
|
tooltipCofig,
|
|
62
|
+
fileCount,
|
|
63
|
+
cartFiles,
|
|
50
64
|
} = props;
|
|
51
65
|
/**
|
|
52
66
|
* conditionally display dialog view
|
|
@@ -54,6 +68,16 @@ const AddAllFilesComponent = (props) => {
|
|
|
54
68
|
const [openAddDialog, setOpen] = useState(false);
|
|
55
69
|
const toggleOpen = () => setOpen(!openAddDialog);
|
|
56
70
|
const [addFilesId, setAddFilesId] = useState([]);
|
|
71
|
+
const [isDataloading, setIsDataloading] = useState(false);
|
|
72
|
+
|
|
73
|
+
const cartFilesDict = {};
|
|
74
|
+
cartFiles.forEach((file) => { cartFilesDict[file] = true; });
|
|
75
|
+
|
|
76
|
+
const backdropCls = {
|
|
77
|
+
width: '100%',
|
|
78
|
+
zIndex: 99999,
|
|
79
|
+
background: 'rgba(0, 0, 0, 0.1)',
|
|
80
|
+
};
|
|
57
81
|
|
|
58
82
|
/**
|
|
59
83
|
* verify and set file ids
|
|
@@ -64,29 +88,52 @@ const AddAllFilesComponent = (props) => {
|
|
|
64
88
|
variables: activeFilters,
|
|
65
89
|
query: addFileQuery,
|
|
66
90
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
const upperLimit = 200000;
|
|
92
|
+
const cartCount = cartFiles.length;
|
|
93
|
+
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
94
|
+
setIsDataloading(true);
|
|
95
|
+
fileIds().then((response) => {
|
|
96
|
+
const data = response[responseKeys[0]];
|
|
97
|
+
if (data && data.length > 0) {
|
|
98
|
+
const isArray = Array.isArray(data[0][responseKeys[1]]);
|
|
99
|
+
// const idsInitial = data.reduce((acc, id) => {
|
|
100
|
+
// if (id && id[responseKeys[1]]) {
|
|
101
|
+
// // if object convert to array
|
|
102
|
+
// const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
103
|
+
// acc.push(...items);
|
|
104
|
+
// }
|
|
105
|
+
// return acc;
|
|
106
|
+
// }, []);
|
|
107
|
+
const idsInitial = [];
|
|
108
|
+
data.forEach((item) => {
|
|
109
|
+
if (item && item[responseKeys[1]]) {
|
|
110
|
+
const items = isArray ? item[responseKeys[1]] : [item[responseKeys[1]]];
|
|
111
|
+
items.forEach((it) => {
|
|
112
|
+
idsInitial.push(it);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const ids = [...new Set(idsInitial)];
|
|
117
|
+
if (cartCount + ids.length <= upperLimit) {
|
|
118
|
+
setIsDataloading(false);
|
|
119
|
+
setOpen(true);
|
|
120
|
+
setAddFilesId(ids);
|
|
121
|
+
} else {
|
|
122
|
+
const newIds = checkDuplicate(cartFilesDict, ids);
|
|
123
|
+
setIsDataloading(false);
|
|
124
|
+
if (cartCount + newIds.length <= upperLimit) {
|
|
125
|
+
setOpen(true);
|
|
126
|
+
setAddFilesId(newIds);
|
|
127
|
+
} else {
|
|
128
|
+
setAlterDisplay(true);
|
|
129
|
+
}
|
|
76
130
|
}
|
|
77
|
-
return acc;
|
|
78
|
-
}, []);
|
|
79
|
-
if (ids.length > 1000) {
|
|
80
|
-
setAlterDisplay(true);
|
|
81
|
-
} else {
|
|
82
|
-
setOpen(true);
|
|
83
|
-
setAddFilesId(ids);
|
|
84
131
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
132
|
+
return [];
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
setAlterDisplay(true);
|
|
136
|
+
}
|
|
90
137
|
};
|
|
91
138
|
|
|
92
139
|
/**
|
|
@@ -113,6 +160,9 @@ const AddAllFilesComponent = (props) => {
|
|
|
113
160
|
onYesClick={addFilesToCart}
|
|
114
161
|
onNoClick={toggleOpen}
|
|
115
162
|
/>
|
|
163
|
+
<Backdrop className={backdropCls} style={backdropCls} open={isDataloading}>
|
|
164
|
+
<CircularProgress color="inherit" />
|
|
165
|
+
</Backdrop>
|
|
116
166
|
</>
|
|
117
167
|
);
|
|
118
168
|
};
|
|
@@ -19,6 +19,7 @@ const AddFilesView = (props) => {
|
|
|
19
19
|
btnType,
|
|
20
20
|
count,
|
|
21
21
|
alertMessage,
|
|
22
|
+
cartFiles,
|
|
22
23
|
} = props;
|
|
23
24
|
/**
|
|
24
25
|
* snackbar state
|
|
@@ -43,6 +44,7 @@ const AddFilesView = (props) => {
|
|
|
43
44
|
client={client}
|
|
44
45
|
setAlterDisplay={setAlterDisplay}
|
|
45
46
|
setOpenSnackbar={setOpenSnackbar}
|
|
47
|
+
cartFiles={cartFiles}
|
|
46
48
|
/>
|
|
47
49
|
)
|
|
48
50
|
}
|
|
@@ -53,6 +55,7 @@ const AddFilesView = (props) => {
|
|
|
53
55
|
client={client}
|
|
54
56
|
setAlterDisplay={setAlterDisplay}
|
|
55
57
|
setOpenSnackbar={setOpenSnackbar}
|
|
58
|
+
cartFiles={cartFiles}
|
|
56
59
|
/>
|
|
57
60
|
)
|
|
58
61
|
}
|
|
@@ -7,6 +7,16 @@ import { onRowSeclect } from '../../../table/state/Actions';
|
|
|
7
7
|
import AddSelectedFileComponent from './AddSelectedFilesView';
|
|
8
8
|
import { getFilesID } from '../../WrapperService';
|
|
9
9
|
|
|
10
|
+
const checkDuplicate = (cartFiles, ids) => {
|
|
11
|
+
let duplicateCount = 0;
|
|
12
|
+
for (let i = 0; i < cartFiles.length; i += 1) {
|
|
13
|
+
if (ids.includes(cartFiles[i])) {
|
|
14
|
+
duplicateCount += 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return duplicateCount;
|
|
18
|
+
};
|
|
19
|
+
|
|
10
20
|
const AddSelectedFilesController = (props) => {
|
|
11
21
|
const {
|
|
12
22
|
clsName,
|
|
@@ -18,6 +28,7 @@ const AddSelectedFilesController = (props) => {
|
|
|
18
28
|
setOpenSnackbar,
|
|
19
29
|
setAlterDisplay,
|
|
20
30
|
client,
|
|
31
|
+
cartFiles,
|
|
21
32
|
} = props;
|
|
22
33
|
|
|
23
34
|
const tableContext = useContext(TableContext);
|
|
@@ -36,15 +47,29 @@ const AddSelectedFilesController = (props) => {
|
|
|
36
47
|
fileIds: selectedRows,
|
|
37
48
|
query: addFileQuery,
|
|
38
49
|
});
|
|
39
|
-
|
|
50
|
+
const cartCount = cartFiles.length;
|
|
40
51
|
fileIds().then((response) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
const idsInitial = response[responseKeys[0]] || [];
|
|
53
|
+
const ids = [...new Set(idsInitial)];
|
|
54
|
+
const fileCount = ids.length;
|
|
55
|
+
const upperLimit = 200000;
|
|
56
|
+
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
57
|
+
if (cartCount + fileCount <= upperLimit) {
|
|
58
|
+
addFiles(ids);
|
|
59
|
+
setOpenSnackbar(true);
|
|
60
|
+
dispatch(onRowSeclect([]));
|
|
61
|
+
} else {
|
|
62
|
+
const duplicate = checkDuplicate(cartFiles, ids);
|
|
63
|
+
if (cartCount + fileCount - duplicate <= upperLimit) {
|
|
64
|
+
addFiles(ids);
|
|
65
|
+
setOpenSnackbar(true);
|
|
66
|
+
dispatch(onRowSeclect([]));
|
|
67
|
+
} else {
|
|
68
|
+
setAlterDisplay(true);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
44
71
|
} else {
|
|
45
|
-
|
|
46
|
-
setOpenSnackbar(true);
|
|
47
|
-
dispatch(onRowSeclect([]));
|
|
72
|
+
setAlterDisplay(true);
|
|
48
73
|
}
|
|
49
74
|
});
|
|
50
75
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { btnTypes } from './AddFiles';
|
|
3
3
|
import AddFileButtonView from './ReduxAddFile';
|
|
4
|
-
import DownloadManifestView from './
|
|
4
|
+
import DownloadManifestView from './ReduxDownloadManifestBtn';
|
|
5
5
|
|
|
6
6
|
const ButtonView = (props) => {
|
|
7
7
|
const {
|
|
@@ -12,6 +12,7 @@ const DownloadManifestView = (props) => {
|
|
|
12
12
|
tooltipCofig,
|
|
13
13
|
clsName,
|
|
14
14
|
title,
|
|
15
|
+
cartFiles,
|
|
15
16
|
} = props;
|
|
16
17
|
/**
|
|
17
18
|
* get cart state
|
|
@@ -25,7 +26,7 @@ const DownloadManifestView = (props) => {
|
|
|
25
26
|
const getQueryVeriables = (queryVariables) => {
|
|
26
27
|
const variables = { ...queryVariables };
|
|
27
28
|
variables.offset = 0;
|
|
28
|
-
variables.first =
|
|
29
|
+
variables.first = 200000;
|
|
29
30
|
return variables;
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -53,6 +54,7 @@ const DownloadManifestView = (props) => {
|
|
|
53
54
|
<Button
|
|
54
55
|
className={clsName}
|
|
55
56
|
disableRipple
|
|
57
|
+
disabled={cartFiles.length === 0}
|
|
56
58
|
onClick={() => DocumentDownload()}
|
|
57
59
|
>
|
|
58
60
|
{title}
|
|
@@ -10,6 +10,7 @@ const AddFilesRedux = (props) => <AddFiles {...props} />;
|
|
|
10
10
|
*/
|
|
11
11
|
const mapStateToProps = (state) => ({
|
|
12
12
|
count: state.cartReducer && state.cartReducer.count,
|
|
13
|
+
cartFiles: state.cartReducer && state.cartReducer.filesId,
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
const mapDispatchToProps = (dispatch) => ({
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import DownloadManifestView from './DownloadManifestBtn';
|
|
4
|
+
|
|
5
|
+
const DownloadManifestRedux = (props) => <DownloadManifestView {...props} />;
|
|
6
|
+
|
|
7
|
+
const mapStateToProps = (state) => ({
|
|
8
|
+
cartFiles: state.cartReducer && state.cartReducer.filesId,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default connect(mapStateToProps)(DownloadManifestRedux);
|