@bento-core/table 1.0.1-ccdihub.113 → 1.0.1-ccdihub.115

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.
@@ -216,7 +216,8 @@ const CPIModal = _ref => {
216
216
  let {
217
217
  open,
218
218
  onClose,
219
- row
219
+ row,
220
+ navigation
220
221
  } = _ref;
221
222
  const classes = useStyles();
222
223
  // const [sortBy, setSortBy] = useState('associated_id');
@@ -228,10 +229,13 @@ const CPIModal = _ref => {
228
229
  const dropdownRef = (0, _react.useRef)(null);
229
230
  const participantId = row.participant_id;
230
231
  const studyId = row.study_id;
231
- const cpiData = row.cpi_data;
232
232
  (0, _react.useEffect)(() => {
233
- setData(row.cpi_data);
234
- }, [row]);
233
+ // Reset all state when row or open status changes
234
+ setData(row.cpi_data || []);
235
+ setIds([]);
236
+ setSelectAll(false);
237
+ setDropdownOpen(false);
238
+ }, [row, open]);
235
239
  const handleDropdownToggle = () => {
236
240
  setDropdownOpen(!dropdownOpen);
237
241
  };
@@ -299,7 +303,7 @@ const CPIModal = _ref => {
299
303
  size: 'xl',
300
304
  clsName: 'container_header',
301
305
  items: [{
302
- participantIds: cpiData,
306
+ participantIds: data,
303
307
  title: 'ADD ALL FILES FOR PARTICIPANT',
304
308
  clsName: 'add_all_button',
305
309
  role: 'ADD_ALL_FILES',
@@ -637,9 +641,7 @@ const CPIModal = _ref => {
637
641
  className: classes.questionIcon
638
642
  }))), /*#__PURE__*/_react.default.createElement(_core.Button, {
639
643
  style: viewInExploreButton,
640
- onClick: () => {
641
- window.location.href = "/explore?p_id=".concat(participantId, "&dbgap_accession=").concat(studyId);
642
- },
644
+ onClick: () => navigation("/explore?p_id=".concat(participantId, "&dbgap_accession=").concat(studyId)),
643
645
  disableRipple: true
644
646
  }, "VIEW IN EXPLORE"), /*#__PURE__*/_react.default.createElement("div", {
645
647
  className: classes.dropdownContainer,
@@ -679,8 +681,8 @@ const CPIModal = _ref => {
679
681
  }, /*#__PURE__*/_react.default.createElement(_core.Button, {
680
682
  style: goToCartButton,
681
683
  onClick: () => {
682
- window.location.href = '/fileCentricCart';
683
684
  setDropdownOpen(false);
685
+ navigation('/fileCentricCart');
684
686
  },
685
687
  disableRipple: true
686
688
  }, "GO TO CART"))))))), /*#__PURE__*/_react.default.createElement("div", {
@@ -94,6 +94,7 @@ const CPIView = _ref => {
94
94
  return /*#__PURE__*/_react.default.createElement(_core.Typography, {
95
95
  className: _Types.cellTypes.CPI
96
96
  }, row[column === null || column === void 0 ? void 0 : column.dataField], cpiData.length ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CPIModal.default, {
97
+ key: "".concat(row.id, "-").concat(row.participant_id),
97
98
  row: row,
98
99
  open: modalOpen,
99
100
  onClose: handleModalClose,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdihub.113",
3
+ "version": "1.0.1-ccdihub.115",
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",
@@ -223,6 +223,7 @@ const CPIModal = ({
223
223
  open,
224
224
  onClose,
225
225
  row,
226
+ navigation,
226
227
  }) => {
227
228
  const classes = useStyles();
228
229
  // const [sortBy, setSortBy] = useState('associated_id');
@@ -235,11 +236,14 @@ const CPIModal = ({
235
236
 
236
237
  const participantId = row.participant_id;
237
238
  const studyId = row.study_id;
238
- const cpiData = row.cpi_data;
239
239
 
240
240
  useEffect(() => {
241
- setData(row.cpi_data);
242
- }, [row]);
241
+ // Reset all state when row or open status changes
242
+ setData(row.cpi_data || []);
243
+ setIds([]);
244
+ setSelectAll(false);
245
+ setDropdownOpen(false);
246
+ }, [row, open]);
243
247
 
244
248
  const handleDropdownToggle = () => {
245
249
  setDropdownOpen(!dropdownOpen);
@@ -319,7 +323,7 @@ const CPIModal = ({
319
323
  clsName: 'container_header',
320
324
  items: [
321
325
  {
322
- participantIds: cpiData,
326
+ participantIds: data,
323
327
  title: 'ADD ALL FILES FOR PARTICIPANT',
324
328
  clsName: 'add_all_button',
325
329
  role: 'ADD_ALL_FILES',
@@ -681,9 +685,7 @@ const CPIModal = ({
681
685
 
682
686
  <Button
683
687
  style={viewInExploreButton}
684
- onClick={() => {
685
- window.location.href = `/explore?p_id=${participantId}&dbgap_accession=${studyId}`;
686
- }}
688
+ onClick={() => navigation(`/explore?p_id=${participantId}&dbgap_accession=${studyId}`)}
687
689
  disableRipple
688
690
  >
689
691
  VIEW IN EXPLORE
@@ -734,8 +736,8 @@ const CPIModal = ({
734
736
  <Button
735
737
  style={goToCartButton}
736
738
  onClick={() => {
737
- window.location.href = '/fileCentricCart';
738
739
  setDropdownOpen(false);
740
+ navigation('/fileCentricCart');
739
741
  }}
740
742
  disableRipple
741
743
  >
@@ -102,6 +102,7 @@ const CPIView = ({
102
102
  ? (
103
103
  <>
104
104
  <CPIModal
105
+ key={`${row.id}-${row.participant_id}`}
105
106
  row={row}
106
107
  open={modalOpen}
107
108
  onClose={handleModalClose}