@bento-core/table 1.0.1-ccdihub.98 → 1.0.1-ccdiintegrated.1

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.
Files changed (55) hide show
  1. package/dist/ExtendedView.js +134 -7
  2. package/dist/TableView.js +23 -7
  3. package/dist/body/CustomTblBody.js +2 -1
  4. package/dist/body/DisplayBodyCell.js +18 -0
  5. package/dist/body/components/CPIMappingView.js +221 -0
  6. package/dist/body/components/CPIModal.js +436 -95
  7. package/dist/body/components/CPIView.js +64 -10
  8. package/dist/body/components/StudiesDataAvailabilityView.js +125 -0
  9. package/dist/body/components/assets/CPI_Icon_Dataset.svg +6 -0
  10. package/dist/body/components/assets/CPI_Icon_Multi.svg +6 -0
  11. package/dist/body/components/assets/CPI_Icon_Single.svg +4 -0
  12. package/dist/body/components/assets/CPI_Icon_Study.svg +11 -0
  13. package/dist/body/components/assets/Participant_Files.svg +17 -0
  14. package/dist/body/components/assets/Publications.svg +15 -0
  15. package/dist/body/components/assets/Sample_Files.svg +16 -0
  16. package/dist/body/components/assets/Study_Files.svg +21 -0
  17. package/dist/body/components/assets/download.svg +3 -0
  18. package/dist/header/CustomCell.js +4 -3
  19. package/dist/header/CustomTblHeader.js +16 -3
  20. package/dist/index.js +7 -0
  21. package/dist/toolbar/DownloadButtonView.js +30 -4
  22. package/dist/toolbar/SearchBar.js +92 -0
  23. package/dist/toolbar/assets/Search_Icon.svg +3 -0
  24. package/dist/util/Types.js +16 -4
  25. package/dist/wrapper/components/AddToCart/AddToCartView.js +126 -0
  26. package/dist/wrapper/components/AddToCart/ReduxAddToCart.js +27 -0
  27. package/dist/wrapper/components/Snackbar/Snackbar.js +5 -0
  28. package/package.json +25 -24
  29. package/src/ExtendedView.js +146 -7
  30. package/src/TableView.js +27 -8
  31. package/src/body/CustomTblBody.js +2 -1
  32. package/src/body/DisplayBodyCell.js +22 -0
  33. package/src/body/components/CPIMappingView.js +260 -0
  34. package/src/body/components/CPIModal.js +467 -103
  35. package/src/body/components/CPIView.js +75 -22
  36. package/src/body/components/StudiesDataAvailabilityView.js +121 -0
  37. package/src/body/components/assets/CPI_Icon_Dataset.svg +6 -0
  38. package/src/body/components/assets/CPI_Icon_Multi.svg +6 -0
  39. package/src/body/components/assets/CPI_Icon_Single.svg +4 -0
  40. package/src/body/components/assets/CPI_Icon_Study.svg +11 -0
  41. package/src/body/components/assets/Participant_Files.svg +17 -0
  42. package/src/body/components/assets/Publications.svg +15 -0
  43. package/src/body/components/assets/Sample_Files.svg +16 -0
  44. package/src/body/components/assets/Study_Files.svg +21 -0
  45. package/src/body/components/assets/download.svg +3 -0
  46. package/src/header/CustomCell.js +4 -3
  47. package/src/header/CustomTblHeader.js +13 -1
  48. package/src/index.js +1 -0
  49. package/src/toolbar/DownloadButtonView.js +20 -4
  50. package/src/toolbar/SearchBar.js +90 -0
  51. package/src/toolbar/assets/Search_Icon.svg +3 -0
  52. package/src/util/Types.js +10 -1
  53. package/src/wrapper/components/AddToCart/AddToCartView.js +132 -0
  54. package/src/wrapper/components/AddToCart/ReduxAddToCart.js +20 -0
  55. package/src/wrapper/components/Snackbar/Snackbar.js +1 -0
@@ -32,7 +32,7 @@ const CustomTableBody = ({
32
32
  <ThemeProvider theme={themeConfig}>
33
33
  <TableBody>
34
34
  {rows
35
- .map((row) => (
35
+ .map((row, rowIndex) => (
36
36
  <TableRow>
37
37
  {
38
38
  displayColunms.map((column) => {
@@ -51,6 +51,7 @@ const CustomTableBody = ({
51
51
  <DisplayCell
52
52
  column={column}
53
53
  row={row}
54
+ rowIndex={rowIndex}
54
55
  themeConfig={themeConfig}
55
56
  navigation={navigation}
56
57
  />
@@ -7,6 +7,8 @@ import { cellTypes } from '../util/Types';
7
7
  import CustomLinkView from './components/CustomLinkView';
8
8
  import DataFormatView from './components/DataFormatView';
9
9
  import CPIView from './components/CPIView';
10
+ import CPIMappingView from './components/CPIMappingView';
11
+ import StudiesDataAvailabilityView from './components/StudiesDataAvailabilityView';
10
12
 
11
13
  /**
12
14
  * Custom Column reneder
@@ -30,6 +32,7 @@ const CustomComponent = ({
30
32
  const ViewCell = ({
31
33
  column,
32
34
  row,
35
+ rowIndex,
33
36
  themeConfig,
34
37
  navigation,
35
38
  }) => {
@@ -65,6 +68,23 @@ const ViewCell = ({
65
68
  navigation={navigation}
66
69
  />
67
70
  );
71
+ case cellTypes.CPI_MAPPING:
72
+ return (
73
+ <CPIMappingView
74
+ row={row}
75
+ column={column}
76
+ rowIndex={rowIndex}
77
+ themeConfig={themeConfig}
78
+ navigation={navigation}
79
+ />
80
+ );
81
+ case cellTypes.STUDIES:
82
+ return (
83
+ <StudiesDataAvailabilityView
84
+ row={row}
85
+ column={column}
86
+ />
87
+ );
68
88
  default:
69
89
  return (
70
90
  <Typography>
@@ -77,6 +97,7 @@ const ViewCell = ({
77
97
  const DisplayCell = ({
78
98
  row,
79
99
  column,
100
+ rowIndex,
80
101
  themeConfig,
81
102
  navigation,
82
103
  }) => (
@@ -84,6 +105,7 @@ const DisplayCell = ({
84
105
  <ViewCell
85
106
  row={row}
86
107
  column={column}
108
+ rowIndex={rowIndex}
87
109
  themeConfig={themeConfig}
88
110
  navigation={navigation}
89
111
  />
@@ -0,0 +1,260 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ Typography,
4
+ Tooltip,
5
+ makeStyles,
6
+ } from '@material-ui/core';
7
+ import { cellTypes } from '../../util/Types';
8
+ import cpiIconSingle from './assets/CPI_Icon_Single.svg';
9
+ import cpiIconMulti from './assets/CPI_Icon_Multi.svg';
10
+ import cpiIconStudy from './assets/CPI_Icon_Study.svg';
11
+ import cpiIconDataset from './assets/CPI_Icon_Dataset.svg';
12
+ import CPIModal from './CPIModal';
13
+
14
+ /**
15
+ * CPI Mapping component - displays different icons based on domain_category
16
+ */
17
+
18
+ const CPIMappingView = ({
19
+ row,
20
+ themeConfig,
21
+ navigation,
22
+ rowIndex,
23
+ }) => {
24
+ const useStyles = makeStyles(() => ({
25
+ arrow: {
26
+ '&:before': {
27
+ border: '1px solid black',
28
+ },
29
+ color: 'white',
30
+ },
31
+ tooltip: {
32
+ backgroundColor: 'white',
33
+ border: '1px solid black',
34
+ color: 'black',
35
+ fontFamily: 'Poppins',
36
+ fontWeight: 400,
37
+ fontStyle: 'Regular',
38
+ fontSize: '13px',
39
+ lineHeight: '17.5px',
40
+ letterSpacing: '-0.01em',
41
+ padding: '10px',
42
+ },
43
+ }));
44
+
45
+ const classes = useStyles();
46
+
47
+ const [modalOpen, setModalOpen] = useState(false);
48
+ const cpiData = row.cpi_data ? row.cpi_data : [];
49
+
50
+ // Filter ALL CPI data by data_type for tooltip logic
51
+ const internalData = cpiData.filter((e) => e.data_type === 'internal');
52
+ const externalData = cpiData.filter((e) => e.data_type === 'external');
53
+
54
+ // Group CPI data by domain_category
55
+ const organizationalData = cpiData.filter((e) => e.domain_category === 'organizational_identifier');
56
+ const datasetData = cpiData.filter((e) => e.domain_category === 'dataset');
57
+ const studyData = cpiData.filter((e) => e.domain_category === 'study');
58
+
59
+ const handleModalOpen = () => {
60
+ setModalOpen(true);
61
+ };
62
+
63
+ const handleModalClose = () => {
64
+ setModalOpen(false);
65
+ };
66
+
67
+ const button = {
68
+ color: '#07679C',
69
+ textDecoration: 'underline',
70
+ fontWeight: 700,
71
+ cursor: 'pointer',
72
+ padding: 0,
73
+ marginLeft: '3px',
74
+ };
75
+
76
+ const italicText = {
77
+ fontFamily: 'Poppins',
78
+ fontWeight: 400,
79
+ fontStyle: 'italic',
80
+ fontSize: '13px',
81
+ lineHeight: '19px',
82
+ letterSpacing: '-0.01em',
83
+ };
84
+
85
+ const iconContainer = {
86
+ display: 'flex',
87
+ alignItems: 'center',
88
+ justifyContent: 'flex-start',
89
+ gap: '24px',
90
+ width: '150px',
91
+ };
92
+
93
+ const icon = {
94
+ position: 'relative',
95
+ cursor: 'pointer',
96
+ display: 'inline-block',
97
+ };
98
+
99
+ const badgeContainer = {
100
+ position: 'relative',
101
+ display: 'inline-block',
102
+ };
103
+
104
+ // Determine row background color based on index (even rows are gray)
105
+ const isEvenRow = rowIndex !== undefined && rowIndex % 2 === 1;
106
+ const rowBackgroundColor = isEvenRow ? '#f4f5f5' : 'white';
107
+
108
+ const getBadgeStyle = (count, iconType) => {
109
+ let rightOffset = '-8px';
110
+ let bottomOffset = '0.5px';
111
+ let boxShadow = 'none';
112
+
113
+ if (iconType === 'organizational' && count === 1) {
114
+ rightOffset = '-6px';
115
+ bottomOffset = '0.5px';
116
+ } else if (iconType === 'organizational') {
117
+ // Multi organizational icon - no box shadow needed
118
+ rightOffset = '-8px';
119
+ boxShadow = 'none';
120
+ } else {
121
+ // Dataset and Study icons need gap
122
+ boxShadow = `0 0 0 2px ${rowBackgroundColor}`;
123
+ }
124
+
125
+ return {
126
+ position: 'absolute',
127
+ right: rightOffset,
128
+ bottom: bottomOffset,
129
+ backgroundColor: 'white',
130
+ border: '1.5px solid #07679C',
131
+ borderRadius: '4px',
132
+ minWidth: '12px',
133
+ height: '12px',
134
+ display: 'flex',
135
+ alignItems: 'center',
136
+ justifyContent: 'center',
137
+ padding: '2px 3px',
138
+ fontSize: '8px',
139
+ fontWeight: 700,
140
+ fontStyle: 'normal',
141
+ lineHeight: '16px',
142
+ letterSpacing: '-0.02em',
143
+ color: '#07679C',
144
+ fontFamily: 'Open Sans',
145
+ boxShadow,
146
+ };
147
+ };
148
+
149
+ const renderIcon = (iconSrc, count, iconType) => {
150
+ if (count === 0) return null;
151
+
152
+ let tooltipContent;
153
+
154
+ // Same tooltip logic for all icon types
155
+ if (externalData.length === 1 && internalData.length === 0) {
156
+ tooltipContent = (
157
+ <div>
158
+ dbGaP identifier mapped in the CCDI Participant Index (CPI) is available
159
+ <span role="button" onClick={handleModalOpen} tabIndex={0} style={button}>
160
+ here.
161
+ </span>
162
+ </div>
163
+ );
164
+ } else if (externalData.length > 1 && internalData.length === 0) {
165
+ tooltipContent = (
166
+ <div>
167
+ Multiple alternative identifiers mapped in the CCDI Participant Index (CPI) are available
168
+ <span role="button" onClick={handleModalOpen} tabIndex={0} style={button}>
169
+ here.
170
+ </span>
171
+ </div>
172
+ );
173
+ } else {
174
+ // Has internal identifiers
175
+ tooltipContent = (
176
+ <div>
177
+ <div style={{ marginBottom: '6px' }}>
178
+ This participant has more than one identifier in CCDI Hub studies:
179
+ </div>
180
+ {internalData.map((e) => (
181
+ <div key={e.associated_id} style={italicText}>
182
+ {`${e.associated_id}, ${e.repository_of_synonym_id}`}
183
+ </div>
184
+ ))}
185
+ <div style={{ marginTop: '6px' }}>
186
+ Additional alternative identifiers mapped in the
187
+ CCDI Participant Index (CPI) for this participant are available
188
+ <span role="button" onClick={handleModalOpen} tabIndex={0} style={button}>
189
+ here.
190
+ </span>
191
+ </div>
192
+ </div>
193
+ );
194
+ }
195
+
196
+ return (
197
+ <Tooltip
198
+ key={`${iconType}-tooltip`}
199
+ interactive
200
+ placement="top"
201
+ classes={{
202
+ arrow: classes.arrow,
203
+ tooltip: classes.tooltip,
204
+ }}
205
+ arrow
206
+ title={tooltipContent}
207
+ >
208
+ <span style={icon}>
209
+ <span style={badgeContainer}>
210
+ <img
211
+ src={iconSrc}
212
+ height={21}
213
+ width={23}
214
+ alt={`cpi-${iconType}-icon`}
215
+ />
216
+ <span style={getBadgeStyle(count, iconType)}>{count}</span>
217
+ </span>
218
+ </span>
219
+ </Tooltip>
220
+ );
221
+ };
222
+
223
+ const getOrganizationalIcon = (count) => (count === 1 ? cpiIconSingle : cpiIconMulti);
224
+
225
+ if (!cpiData.length) {
226
+ return <Typography />;
227
+ }
228
+
229
+ return (
230
+ <Typography className={cellTypes.CPI_MAPPING}>
231
+ <CPIModal
232
+ key={`${row.id}-${row.participant_id}`}
233
+ row={row}
234
+ open={modalOpen}
235
+ onClose={handleModalClose}
236
+ themeConfig={themeConfig}
237
+ navigation={navigation}
238
+ />
239
+ <div style={iconContainer}>
240
+ {organizationalData.length > 0 && renderIcon(
241
+ getOrganizationalIcon(organizationalData.length),
242
+ organizationalData.length,
243
+ 'organizational',
244
+ )}
245
+ {datasetData.length > 0 && renderIcon(
246
+ cpiIconDataset,
247
+ datasetData.length,
248
+ 'dataset',
249
+ )}
250
+ {studyData.length > 0 && renderIcon(
251
+ cpiIconStudy,
252
+ studyData.length,
253
+ 'study',
254
+ )}
255
+ </div>
256
+ </Typography>
257
+ );
258
+ };
259
+
260
+ export default CPIMappingView;