@bento-core/paginated-table 1.0.1-ccdihub.99 → 1.0.1-ccdiintegrated.10

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
@@ -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
- themeConfig: themeConfig
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
- themeConfig: themeConfig
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
- 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.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,
@@ -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
  }
@@ -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
@@ -85,25 +97,37 @@ const AddAllFilesComponent = props => {
85
97
  const upperLimit = 200000;
86
98
  const cartCount = cartFiles.length;
87
99
  if (fileCount <= upperLimit && cartCount < upperLimit) {
100
+ setIsDataloading(true);
88
101
  fileIds().then(response => {
89
102
  const data = response[responseKeys[0]];
90
103
  if (data && data.length > 0) {
91
104
  const isArray = Array.isArray(data[0][responseKeys[1]]);
92
- const idsInitial = data.reduce((acc, id) => {
93
- if (id && id[responseKeys[1]]) {
94
- // if object convert to array
95
- const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
96
- 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
+ });
97
120
  }
98
- return acc;
99
- }, []);
121
+ });
100
122
  const ids = [...new Set(idsInitial)];
101
123
  if (cartCount + ids.length <= upperLimit) {
102
- setOpen(true);
103
- setAddFilesId(ids);
124
+ setIsDataloading(false);
125
+ addFiles(ids);
126
+ setOpenSnackbar(true);
104
127
  } else {
105
- const duplicate = checkDuplicate(cartFiles, ids);
106
- if (cartCount + ids.length - duplicate <= upperLimit) {
128
+ const newIds = checkDuplicate(cartFilesDict, ids);
129
+ setIsDataloading(false);
130
+ if (cartCount + newIds.length <= upperLimit) {
107
131
  setOpen(true);
108
132
  setAddFilesId(ids);
109
133
  } else {
@@ -134,7 +158,13 @@ const AddAllFilesComponent = props => {
134
158
  open: openAddDialog,
135
159
  onYesClick: addFilesToCart,
136
160
  onNoClick: toggleOpen
137
- }));
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
+ })));
138
168
  };
139
169
  var _default = AddAllFilesComponent;
140
170
  exports.default = _default;
@@ -28,6 +28,7 @@ const AddFilesView = props => {
28
28
  const {
29
29
  btnType,
30
30
  count,
31
+ alreadyInCartCount,
31
32
  alertMessage,
32
33
  cartFiles
33
34
  } = props;
@@ -57,6 +58,7 @@ const AddFilesView = props => {
57
58
  })), /*#__PURE__*/_react.default.createElement(_Snackbar.default, {
58
59
  open: openSnackbar,
59
60
  count: count,
61
+ alreadyInCartCount: alreadyInCartCount,
60
62
  onClose: () => setOpenSnackbar(false)
61
63
  }), displayAlter && /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
62
64
  alertMessage: alertMessage,
@@ -16,6 +16,7 @@ const AddFilesRedux = props => /*#__PURE__*/_react.default.createElement(_AddFil
16
16
  */
17
17
  const mapStateToProps = state => ({
18
18
  count: state.cartReducer && state.cartReducer.count,
19
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
19
20
  cartFiles: state.cartReducer && state.cartReducer.filesId
20
21
  });
21
22
  const mapDispatchToProps = dispatch => ({
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _core = require("@material-ui/core");
9
+ var _cart = require("@bento-core/cart");
9
10
  var _SuccessOutlined = _interopRequireDefault(require("./SuccessOutlined"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12
  const SnackbarView = props => {
12
13
  const {
13
14
  count,
15
+ alreadyInCartCount = 0,
14
16
  open,
15
17
  onClose
16
18
  } = props;
@@ -24,8 +26,8 @@ const SnackbarView = props => {
24
26
  open: open,
25
27
  autoHideDuration: 3000,
26
28
  anchorOrigin: {
27
- vertical: 'bottom',
28
- horizontal: 'right'
29
+ vertical: 'top',
30
+ horizontal: 'center'
29
31
  },
30
32
  message: /*#__PURE__*/_react.default.createElement("div", {
31
33
  className: "snackBarMessage"
@@ -33,7 +35,7 @@ const SnackbarView = props => {
33
35
  className: "snackBarMessageIcon"
34
36
  }, /*#__PURE__*/_react.default.createElement(_SuccessOutlined.default, null), ' '), /*#__PURE__*/_react.default.createElement("span", {
35
37
  className: "snackBarText"
36
- }, count, ' ', "File(s) successfully added to your cart"))
38
+ }, (0, _cart.formatCartAddMessage)(count, alreadyInCartCount)))
37
39
  }));
38
40
  };
39
41
  var _default = SnackbarView;
@@ -10,7 +10,8 @@ var _Snackbar = _interopRequireDefault(require("./Snackbar"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  const ReduxSnackbar = props => /*#__PURE__*/_react.default.createElement(_Snackbar.default, props);
12
12
  const mapStateToProps = state => ({
13
- count: state.cartReducer.count
13
+ count: state.cartReducer.count,
14
+ alreadyInCartCount: state.cartReducer.alreadyInCartCount
14
15
  });
15
16
  var _default = (0, _reactRedux.connect)(mapStateToProps, null)(ReduxSnackbar);
16
17
  exports.default = _default;
package/package.json CHANGED
@@ -1,25 +1,30 @@
1
1
  {
2
2
  "name": "@bento-core/paginated-table",
3
- "version": "1.0.1-ccdihub.99",
4
- "main": "dist/index.js",
5
- "scripts": {
6
- "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "lint": "eslint src"
3
+ "version": "1.0.1-ccdiintegrated.10",
4
+ "homepage": "https://github.com/CBIIT/bento-frontend#readme",
5
+ "bugs": {
6
+ "url": "https://github.com/CBIIT/bento-frontend/issues"
9
7
  },
10
8
  "repository": {
11
9
  "type": "git",
12
10
  "url": "git+https://github.com/CBIIT/bento-frontend.git"
13
11
  },
14
- "publishConfig": {
15
- "access": "public"
12
+ "license": "ISC",
13
+ "author": "CTOS Bento Team",
14
+ "type": "commonjs",
15
+ "main": "dist/index.js",
16
+ "scripts": {
17
+ "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
18
+ "test": "echo \"Error: no test specified\" && exit 1",
19
+ "lint": "eslint src"
16
20
  },
17
21
  "dependencies": {
18
- "@bento-core/cart": "1.0.1-ccdihub.7",
19
- "@bento-core/table": "1.0.1-ccdihub.74",
20
- "@bento-core/tool-tip": "^1.0.0",
21
- "@bento-core/util": "^1.0.0"
22
+ "@bento-core/cart": "1.0.1-ccdiintegrated.2",
23
+ "@bento-core/table": "1.0.1-ccdiintegrated.8",
24
+ "@bento-core/tool-tip": "1.0.1-ccdiintegrated.1",
25
+ "@bento-core/util": "1.0.1-ccdiintegrated.1"
22
26
  },
27
+ "devDependencies": {},
23
28
  "peerDependencies": {
24
29
  "@apollo/client": "^3.6.9",
25
30
  "@material-ui/core": "^4.12.4",
@@ -28,12 +33,8 @@
28
33
  "react-dom": "^17.0.0",
29
34
  "react-redux": "^7.2.1"
30
35
  },
31
- "author": "CTOS Bento Team",
32
- "license": "ISC",
33
- "bugs": {
34
- "url": "https://github.com/CBIIT/bento-frontend/issues"
36
+ "publishConfig": {
37
+ "access": "public"
35
38
  },
36
- "homepage": "https://github.com/CBIIT/bento-frontend#readme",
37
- "devDependencies": {},
38
39
  "description": ""
39
40
  }
@@ -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
- setTableData(result[table.paginationAPIField]);
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,
@@ -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 { type, customViewElem } = props;
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
  }
@@ -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,15 +34,17 @@ export const ToolTipView = (props) => {
34
34
  );
35
35
  };
36
36
 
37
- const checkDuplicate = (cartFiles, ids) => {
38
- let duplicateCount = 0;
39
- for (let i = 0; i < cartFiles.length; i += 1) {
40
- if (ids.includes(cartFiles[i])) {
41
- duplicateCount += 1;
42
- }
43
- }
44
- return duplicateCount;
45
- };
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]));
46
48
 
47
49
  const AddAllFilesComponent = (props) => {
48
50
  const {
@@ -66,6 +68,16 @@ const AddAllFilesComponent = (props) => {
66
68
  const [openAddDialog, setOpen] = useState(false);
67
69
  const toggleOpen = () => setOpen(!openAddDialog);
68
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
+ };
69
81
 
70
82
  /**
71
83
  * verify and set file ids
@@ -79,25 +91,37 @@ const AddAllFilesComponent = (props) => {
79
91
  const upperLimit = 200000;
80
92
  const cartCount = cartFiles.length;
81
93
  if (fileCount <= upperLimit && cartCount < upperLimit) {
94
+ setIsDataloading(true);
82
95
  fileIds().then((response) => {
83
96
  const data = response[responseKeys[0]];
84
97
  if (data && data.length > 0) {
85
98
  const isArray = Array.isArray(data[0][responseKeys[1]]);
86
- const idsInitial = data.reduce((acc, id) => {
87
- if (id && id[responseKeys[1]]) {
88
- // if object convert to array
89
- const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
90
- acc.push(...items);
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
+ });
91
114
  }
92
- return acc;
93
- }, []);
115
+ });
94
116
  const ids = [...new Set(idsInitial)];
95
117
  if (cartCount + ids.length <= upperLimit) {
96
- setOpen(true);
97
- setAddFilesId(ids);
118
+ setIsDataloading(false);
119
+ addFiles(ids);
120
+ setOpenSnackbar(true);
98
121
  } else {
99
- const duplicate = checkDuplicate(cartFiles, ids);
100
- if (cartCount + ids.length - duplicate <= upperLimit) {
122
+ const newIds = checkDuplicate(cartFilesDict, ids);
123
+ setIsDataloading(false);
124
+ if (cartCount + newIds.length <= upperLimit) {
101
125
  setOpen(true);
102
126
  setAddFilesId(ids);
103
127
  } else {
@@ -136,6 +160,9 @@ const AddAllFilesComponent = (props) => {
136
160
  onYesClick={addFilesToCart}
137
161
  onNoClick={toggleOpen}
138
162
  />
163
+ <Backdrop className={backdropCls} style={backdropCls} open={isDataloading}>
164
+ <CircularProgress color="inherit" />
165
+ </Backdrop>
139
166
  </>
140
167
  );
141
168
  };
@@ -18,6 +18,7 @@ const AddFilesView = (props) => {
18
18
  const {
19
19
  btnType,
20
20
  count,
21
+ alreadyInCartCount,
21
22
  alertMessage,
22
23
  cartFiles,
23
24
  } = props;
@@ -62,6 +63,7 @@ const AddFilesView = (props) => {
62
63
  <SnackbarView
63
64
  open={openSnackbar}
64
65
  count={count}
66
+ alreadyInCartCount={alreadyInCartCount}
65
67
  onClose={() => setOpenSnackbar(false)}
66
68
  />
67
69
  {(displayAlter) && (
@@ -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
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
13
14
  cartFiles: state.cartReducer && state.cartReducer.filesId,
14
15
  });
15
16
 
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import { Snackbar } from '@material-ui/core';
3
+ import { formatCartAddMessage } from '@bento-core/cart';
3
4
  import SuccessOutlinedIcon from './SuccessOutlined';
4
5
 
5
6
  const SnackbarView = (props) => {
6
7
  const {
7
8
  count,
9
+ alreadyInCartCount = 0,
8
10
  open,
9
11
  onClose,
10
12
  } = props;
@@ -21,7 +23,7 @@ const SnackbarView = (props) => {
21
23
  className="snackBar"
22
24
  open={open}
23
25
  autoHideDuration={3000}
24
- anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
26
+ anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
25
27
  message={(
26
28
  <div className="snackBarMessage">
27
29
  <span className="snackBarMessageIcon">
@@ -29,9 +31,7 @@ const SnackbarView = (props) => {
29
31
  {' '}
30
32
  </span>
31
33
  <span className="snackBarText">
32
- {count}
33
- {' '}
34
- File(s) successfully added to your cart
34
+ {formatCartAddMessage(count, alreadyInCartCount)}
35
35
  </span>
36
36
  </div>
37
37
  )}
@@ -6,6 +6,7 @@ const ReduxSnackbar = ((props) => <SnackbarView {...props} />);
6
6
 
7
7
  const mapStateToProps = (state) => ({
8
8
  count: state.cartReducer.count,
9
+ alreadyInCartCount: state.cartReducer.alreadyInCartCount,
9
10
  });
10
11
 
11
12
  export default connect(mapStateToProps, null)(ReduxSnackbar);