@bento-core/paginated-table 1.0.1-ccdiintegrated.5 → 1.0.1-ccdiintegrated.6

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.
@@ -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
@@ -35,11 +40,6 @@ const PaginatedTable = _ref => {
35
40
  * 3. Add all btn / Add file button also dispatch action to update table state
36
41
  */
37
42
  const [table, dispatch] = (0, _react.useReducer)(_Reducer.default, {}, initState);
38
- (0, _react.useEffect)(() => {
39
- if (Object.keys(queryVariables).length > 0) {
40
- dispatch((0, _Actions.unselectAllRows)());
41
- }
42
- }, [queryVariables]);
43
43
 
44
44
  /**
45
45
  * use context to provide table state to wrapper component
@@ -186,6 +186,10 @@ const PaginatedTable = _ref => {
186
186
  dispatch((0, _Actions.onColumnViewChange)(_objectSpread(_objectSpread({}, table), {}, {
187
187
  columns
188
188
  })));
189
+ // Save column state for persistence across search state changes
190
+ if (onColumnStateChange) {
191
+ onColumnStateChange(columns);
192
+ }
189
193
  };
190
194
  const handleAllColumnViewChange = checked => {
191
195
  const columns = table.columns.map(col => {
@@ -199,6 +203,10 @@ const PaginatedTable = _ref => {
199
203
  dispatch((0, _Actions.onColumnViewChange)(_objectSpread(_objectSpread({}, table), {}, {
200
204
  columns
201
205
  })));
206
+ // Save column state for persistence across search state changes
207
+ if (onColumnStateChange) {
208
+ onColumnStateChange(columns);
209
+ }
202
210
  };
203
211
  /**
204
212
  * A. client table
@@ -216,7 +224,10 @@ const PaginatedTable = _ref => {
216
224
  onSortByColumn: handleSortByColumn,
217
225
  onColumnViewChange: handleColumnViewChange,
218
226
  onAllColumnViewChange: handleAllColumnViewChange,
219
- themeConfig: themeConfig
227
+ themeConfig: themeConfig,
228
+ onSearch: onSearch,
229
+ searchValue: searchValue,
230
+ onSearchResultCount: onSearchResultCount
220
231
  }));
221
232
  }
222
233
 
@@ -241,7 +252,11 @@ const PaginatedTable = _ref => {
241
252
  onSortByColumn: handleSortByColumn,
242
253
  onColumnViewChange: handleColumnViewChange,
243
254
  onAllColumnViewChange: handleAllColumnViewChange,
244
- themeConfig: themeConfig
255
+ themeConfig: themeConfig,
256
+ navigation: navigation,
257
+ onSearch: onSearch,
258
+ searchValue: searchValue,
259
+ onSearchResultCount: onSearchResultCount
245
260
  }));
246
261
  };
247
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
- setTableData(result[table.paginationAPIField]);
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.unselectAllRows = exports.setTotalRowCount = exports.onRowsPerPageChange = exports.onRowSelectHidden = 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',
@@ -13,8 +13,7 @@ const actionTypes = {
13
13
  ON_ROW_SELECT: 'ON_ROW_SELECT',
14
14
  ON_ROW_SELECT_HIDDEN: 'ON_ROW_SELECT_HIDDEN',
15
15
  SET_TOTAL_ROW_COUNT: 'SET_TOTAL_ROW_COUNT',
16
- ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE',
17
- UNSELECT_ALL_ROWS: 'UNSELECT_ALL_ROWS'
16
+ ON_PAGE_AND_TOTAL_COUNT_CHANGE: 'ON_PAGE_AND_TOTAL_COUNT_CHANGE'
18
17
  };
19
18
  exports.actionTypes = actionTypes;
20
19
  const onColumnViewChange = columns => ({
@@ -61,8 +60,4 @@ const setTotalRowCount = count => ({
61
60
  type: actionTypes.SET_TOTAL_ROW_COUNT,
62
61
  payload: count
63
62
  });
64
- exports.setTotalRowCount = setTotalRowCount;
65
- const unselectAllRows = () => ({
66
- type: actionTypes.UNSELECT_ALL_ROWS
67
- });
68
- exports.unselectAllRows = unselectAllRows;
63
+ exports.setTotalRowCount = setTotalRowCount;
@@ -49,11 +49,6 @@ const reducer = (state, action) => {
49
49
  return _objectSpread(_objectSpread({}, state), {}, {
50
50
  totalRowCount: payload
51
51
  });
52
- case _Actions.actionTypes.UNSELECT_ALL_ROWS:
53
- return _objectSpread(_objectSpread({}, state), {}, {
54
- selectedRows: [],
55
- hiddenSelectedRows: []
56
- });
57
52
  default:
58
53
  return state;
59
54
  }
@@ -78,8 +78,10 @@ const Text = _ref2 => {
78
78
  const ViewComponent = props => {
79
79
  const {
80
80
  type,
81
- CustomViewElem,
82
- tooltipCofig
81
+ customViewElem,
82
+ CohortViewElem,
83
+ tooltipCofig,
84
+ section
83
85
  } = props;
84
86
  switch (type) {
85
87
  case types.BUTTON:
@@ -93,7 +95,12 @@ const ViewComponent = props => {
93
95
  case types.TEXT_INPUT:
94
96
  return /*#__PURE__*/_react.default.createElement(_TextFieldView.default, props);
95
97
  case types.CUSTOM_ELEM:
96
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(CustomViewElem, null), tooltipCofig && /*#__PURE__*/_react.default.createElement(_TooltipView.default, props));
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));
97
104
  default:
98
105
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
99
106
  }
@@ -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 = 100000;
17
+ queryVariables.first = 200000;
18
18
  return queryVariables;
19
19
  };
20
20
  exports.getQueryVariables = getQueryVariables;
@@ -40,16 +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;
44
- const checkDuplicate = (cartFiles, ids) => {
45
- let duplicateCount = 0;
46
- for (let i = 0; i < cartFiles.length; i += 1) {
47
- if (ids.includes(cartFiles[i])) {
48
- duplicateCount += 1;
49
- }
50
- }
51
- return duplicateCount;
52
- };
54
+ const checkDuplicate = (cartFiles, ids) => ids.filter(id => !cartFiles[id]);
53
55
  const AddAllFilesComponent = props => {
54
56
  const {
55
57
  title,
@@ -72,6 +74,16 @@ const AddAllFilesComponent = props => {
72
74
  const [openAddDialog, setOpen] = (0, _react.useState)(false);
73
75
  const toggleOpen = () => setOpen(!openAddDialog);
74
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
+ };
75
87
 
76
88
  /**
77
89
  * verify and set file ids
@@ -82,29 +94,42 @@ const AddAllFilesComponent = props => {
82
94
  variables: activeFilters,
83
95
  query: addFileQuery
84
96
  });
97
+ const upperLimit = 200000;
85
98
  const cartCount = cartFiles.length;
86
- if (fileCount <= 6000 && cartCount < 6000) {
99
+ if (fileCount <= upperLimit && cartCount < upperLimit) {
100
+ setIsDataloading(true);
87
101
  fileIds().then(response => {
88
102
  const data = response[responseKeys[0]];
89
103
  if (data && data.length > 0) {
90
104
  const isArray = Array.isArray(data[0][responseKeys[1]]);
91
- const idsInitial = data.reduce((acc, id) => {
92
- if (id && id[responseKeys[1]]) {
93
- // if object convert to array
94
- const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
95
- acc.push(...items);
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
+ });
96
120
  }
97
- return acc;
98
- }, []);
121
+ });
99
122
  const ids = [...new Set(idsInitial)];
100
- if (cartCount + ids.length <= 6000) {
101
- setOpen(true);
102
- setAddFilesId(ids);
123
+ if (cartCount + ids.length <= upperLimit) {
124
+ setIsDataloading(false);
125
+ addFiles(ids);
126
+ setOpenSnackbar(true);
103
127
  } else {
104
- const duplicate = checkDuplicate(cartFiles, ids);
105
- if (cartCount + ids.length - duplicate <= 6000) {
128
+ const newIds = checkDuplicate(cartFilesDict, ids);
129
+ setIsDataloading(false);
130
+ if (cartCount + newIds.length <= upperLimit) {
106
131
  setOpen(true);
107
- setAddFilesId(ids);
132
+ setAddFilesId(newIds);
108
133
  } else {
109
134
  setAlterDisplay(true);
110
135
  }
@@ -133,7 +158,13 @@ const AddAllFilesComponent = props => {
133
158
  open: openAddDialog,
134
159
  onYesClick: addFilesToCart,
135
160
  onNoClick: toggleOpen
136
- }));
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
+ })));
137
168
  };
138
169
  var _default = AddAllFilesComponent;
139
170
  exports.default = _default;
@@ -61,14 +61,15 @@ const AddSelectedFilesController = props => {
61
61
  const idsInitial = response[responseKeys[0]] || [];
62
62
  const ids = [...new Set(idsInitial)];
63
63
  const fileCount = ids.length;
64
- if (fileCount <= 6000 && cartCount < 6000) {
65
- if (cartCount + fileCount <= 6000) {
64
+ const upperLimit = 200000;
65
+ if (fileCount <= upperLimit && cartCount < upperLimit) {
66
+ if (cartCount + fileCount <= upperLimit) {
66
67
  addFiles(ids);
67
68
  setOpenSnackbar(true);
68
69
  dispatch((0, _Actions.onRowSeclect)([]));
69
70
  } else {
70
71
  const duplicate = checkDuplicate(cartFiles, ids);
71
- if (cartCount + fileCount - duplicate <= 6000) {
72
+ if (cartCount + fileCount - duplicate <= upperLimit) {
72
73
  addFiles(ids);
73
74
  setOpenSnackbar(true);
74
75
  dispatch((0, _Actions.onRowSeclect)([]));
@@ -37,7 +37,7 @@ const DownloadManifestView = props => {
37
37
  const getQueryVeriables = queryVariables => {
38
38
  const variables = _objectSpread({}, queryVariables);
39
39
  variables.offset = 0;
40
- variables.first = 10000;
40
+ variables.first = 200000;
41
41
  return variables;
42
42
  };
43
43
  const client = (0, _client.useApolloClient)();
@@ -24,8 +24,8 @@ const SnackbarView = props => {
24
24
  open: open,
25
25
  autoHideDuration: 3000,
26
26
  anchorOrigin: {
27
- vertical: 'bottom',
28
- horizontal: 'right'
27
+ vertical: 'top',
28
+ horizontal: 'center'
29
29
  },
30
30
  message: /*#__PURE__*/_react.default.createElement("div", {
31
31
  className: "snackBarMessage"
@@ -21,13 +21,11 @@ const ToolTipView = props => {
21
21
  icon,
22
22
  alt,
23
23
  arrow = false,
24
- maxWidth,
25
24
  clsName
26
25
  } = tooltipCofig;
27
26
  return /*#__PURE__*/_react.default.createElement(_toolTip.default, {
28
27
  title: tooltipCofig[section],
29
28
  arrow: arrow,
30
- maxWidth: maxWidth || '230px',
31
29
  classes: {
32
30
  tooltip: classes.customTooltip,
33
31
  arrow: classes.customArrow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/paginated-table",
3
- "version": "1.0.1-ccdiintegrated.5",
3
+ "version": "1.0.1-ccdiintegrated.6",
4
4
  "homepage": "https://github.com/CBIIT/bento-frontend#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/CBIIT/bento-frontend/issues"