@bento-core/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.
Files changed (75) hide show
  1. package/dist/ExtendedView.js +135 -8
  2. package/dist/TableView.js +25 -7
  3. package/dist/body/CustomTblBody.js +2 -1
  4. package/dist/body/DefaultThemConfig.js +1 -1
  5. package/dist/body/DisplayBodyCell.js +24 -2
  6. package/dist/body/components/CPIMappingView.js +221 -0
  7. package/dist/body/components/CPIModal.js +440 -94
  8. package/dist/body/components/CPIView.js +64 -10
  9. package/dist/body/components/CustomLinkView.js +2 -1
  10. package/dist/body/components/DataFormatView.js +1 -1
  11. package/dist/body/components/StudiesDataAvailabilityView.js +125 -0
  12. package/dist/body/components/assets/CPI_Icon_Dataset.svg +6 -0
  13. package/dist/body/components/assets/CPI_Icon_Multi.svg +6 -0
  14. package/dist/body/components/assets/CPI_Icon_Single.svg +4 -0
  15. package/dist/body/components/assets/CPI_Icon_Study.svg +11 -0
  16. package/dist/body/components/assets/Participant_Files.svg +17 -0
  17. package/dist/body/components/assets/Publications.svg +15 -0
  18. package/dist/body/components/assets/Sample_Files.svg +16 -0
  19. package/dist/body/components/assets/Study_Files.svg +21 -0
  20. package/dist/body/components/assets/download.svg +3 -0
  21. package/dist/header/CustomCell.js +4 -3
  22. package/dist/header/CustomTblHeader.js +16 -3
  23. package/dist/index.js +25 -0
  24. package/dist/toolbar/DownloadButtonView.js +30 -4
  25. package/dist/toolbar/SearchBar.js +92 -0
  26. package/dist/toolbar/assets/Search_Icon.svg +3 -0
  27. package/dist/util/Dataformat.js +50 -2
  28. package/dist/util/Types.js +16 -4
  29. package/dist/util/downloadTable.js +77 -53
  30. package/dist/wrapper/components/AddFiles.js +6 -14
  31. package/dist/wrapper/components/AddToCart/AddToCartView.js +128 -0
  32. package/dist/wrapper/components/AddToCart/ReduxAddToCart.js +28 -0
  33. package/dist/wrapper/components/CPIFilesView/CPIFilesView.js +12 -6
  34. package/dist/wrapper/components/ReduxAddFile.js +1 -0
  35. package/dist/wrapper/components/Snackbar/CartToast.js +96 -0
  36. package/dist/wrapper/components/Snackbar/Snackbar.js +12 -1
  37. package/dist/wrapper/components/Snackbar/SnackbarRedux.js +2 -1
  38. package/package.json +23 -22
  39. package/src/ExtendedView.js +147 -8
  40. package/src/TableView.js +29 -8
  41. package/src/body/CustomTblBody.js +2 -1
  42. package/src/body/DefaultThemConfig.js +1 -1
  43. package/src/body/DisplayBodyCell.js +40 -2
  44. package/src/body/components/CPIMappingView.js +260 -0
  45. package/src/body/components/CPIModal.js +468 -101
  46. package/src/body/components/CPIView.js +75 -22
  47. package/src/body/components/CustomLinkView.js +4 -1
  48. package/src/body/components/DataFormatView.js +4 -2
  49. package/src/body/components/StudiesDataAvailabilityView.js +121 -0
  50. package/src/body/components/assets/CPI_Icon_Dataset.svg +6 -0
  51. package/src/body/components/assets/CPI_Icon_Multi.svg +6 -0
  52. package/src/body/components/assets/CPI_Icon_Single.svg +4 -0
  53. package/src/body/components/assets/CPI_Icon_Study.svg +11 -0
  54. package/src/body/components/assets/Participant_Files.svg +17 -0
  55. package/src/body/components/assets/Publications.svg +15 -0
  56. package/src/body/components/assets/Sample_Files.svg +16 -0
  57. package/src/body/components/assets/Study_Files.svg +21 -0
  58. package/src/body/components/assets/download.svg +3 -0
  59. package/src/header/CustomCell.js +4 -3
  60. package/src/header/CustomTblHeader.js +13 -1
  61. package/src/index.js +7 -1
  62. package/src/toolbar/DownloadButtonView.js +20 -4
  63. package/src/toolbar/SearchBar.js +90 -0
  64. package/src/toolbar/assets/Search_Icon.svg +3 -0
  65. package/src/util/Dataformat.js +47 -0
  66. package/src/util/Types.js +10 -1
  67. package/src/util/downloadTable.js +75 -34
  68. package/src/wrapper/components/AddFiles.js +7 -14
  69. package/src/wrapper/components/AddToCart/AddToCartView.js +134 -0
  70. package/src/wrapper/components/AddToCart/ReduxAddToCart.js +21 -0
  71. package/src/wrapper/components/CPIFilesView/CPIFilesView.js +15 -9
  72. package/src/wrapper/components/ReduxAddFile.js +1 -0
  73. package/src/wrapper/components/Snackbar/CartToast.js +99 -0
  74. package/src/wrapper/components/Snackbar/Snackbar.js +8 -3
  75. package/src/wrapper/components/Snackbar/SnackbarRedux.js +2 -1
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _core = require("@material-ui/core");
9
+ var _Search_Icon = _interopRequireDefault(require("./assets/Search_Icon.svg"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ 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); }
12
+ 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; }
13
+ const SearchBar = _ref => {
14
+ let {
15
+ onSearch
16
+ } = _ref;
17
+ const [searchValue, setSearchValue] = (0, _react.useState)('');
18
+ const handleSearchClick = () => {
19
+ if (onSearch) {
20
+ onSearch(searchValue);
21
+ }
22
+ };
23
+ const handleKeyPress = event => {
24
+ if (event.key === 'Enter') {
25
+ handleSearchClick();
26
+ }
27
+ };
28
+ const handleChange = event => {
29
+ setSearchValue(event.target.value);
30
+ };
31
+ const useStyles = (0, _core.makeStyles)({
32
+ searchContainer: {
33
+ display: 'flex',
34
+ alignItems: 'center',
35
+ border: '0.75px solid #606060',
36
+ borderRadius: '5px',
37
+ backgroundColor: '#ffffff',
38
+ height: '36px',
39
+ width: '300px',
40
+ paddingLeft: '12px',
41
+ paddingRight: '4px',
42
+ marginTop: '8px',
43
+ marginBottom: '8px',
44
+ marginLeft: '-28px',
45
+ float: 'left'
46
+ },
47
+ inputBase: {
48
+ flex: 1,
49
+ fontFamily: 'Poppins',
50
+ fontSize: '14px',
51
+ color: '#000000',
52
+ '& input::placeholder': {
53
+ color: '#9B9B9B',
54
+ opacity: 1
55
+ }
56
+ },
57
+ searchButton: {
58
+ padding: '6px',
59
+ backgroundColor: 'transparent',
60
+ '&:hover': {
61
+ backgroundColor: 'rgba(0, 0, 0, 0.04)'
62
+ }
63
+ },
64
+ searchIcon: {
65
+ width: '15px',
66
+ height: '15px'
67
+ }
68
+ });
69
+ const classes = useStyles();
70
+ return /*#__PURE__*/_react.default.createElement("div", {
71
+ className: classes.searchContainer
72
+ }, /*#__PURE__*/_react.default.createElement(_core.InputBase, {
73
+ className: classes.inputBase,
74
+ placeholder: "Search...",
75
+ value: searchValue,
76
+ onChange: handleChange,
77
+ onKeyPress: handleKeyPress,
78
+ inputProps: {
79
+ 'aria-label': 'search'
80
+ }
81
+ }), /*#__PURE__*/_react.default.createElement(_core.IconButton, {
82
+ className: classes.searchButton,
83
+ onClick: handleSearchClick,
84
+ "aria-label": "search"
85
+ }, /*#__PURE__*/_react.default.createElement("img", {
86
+ src: _Search_Icon.default,
87
+ alt: "search",
88
+ className: classes.searchIcon
89
+ })));
90
+ };
91
+ var _default = SearchBar;
92
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M6.4134 1C3.43007 1 1 3.43007 1 6.4134C1 9.39672 3.43007 11.8268 6.4134 11.8268C7.71072 11.8268 8.90214 11.3661 9.83589 10.6014L13.0681 13.8336C13.118 13.8855 13.1777 13.927 13.2438 13.9556C13.3099 13.9841 13.3811 13.9992 13.4531 14C13.5251 14.0007 13.5966 13.9871 13.6632 13.9598C13.7299 13.9326 13.7905 13.8924 13.8414 13.8414C13.8924 13.7905 13.9326 13.7299 13.9598 13.6632C13.9871 13.5966 14.0007 13.5251 14 13.4531C13.9992 13.3811 13.9841 13.3099 13.9556 13.2438C13.927 13.1777 13.8855 13.118 13.8336 13.0681L10.6014 9.83589C11.3661 8.90214 11.8268 7.71072 11.8268 6.4134C11.8268 3.43007 9.39672 1 6.4134 1ZM6.4134 2.08268C8.8116 2.08268 10.7441 4.0152 10.7441 6.4134C10.7441 8.8116 8.8116 10.7441 6.4134 10.7441C4.0152 10.7441 2.08268 8.8116 2.08268 6.4134C2.08268 4.0152 4.0152 2.08268 6.4134 2.08268Z" fill="#4D889E" stroke="#4D889E"/>
3
+ </svg>
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.formatBytes = formatBytes;
7
- exports.formatColumnValues = void 0;
7
+ exports.stripSurroundingBrackets = exports.isBracketStripEnabled = exports.formatValueForDisplay = exports.formatColumnValues = void 0;
8
8
  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; }
9
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -52,4 +52,52 @@ const formatColumnValues = (columns, data) => {
52
52
  }
53
53
  return data;
54
54
  };
55
- exports.formatColumnValues = formatColumnValues;
55
+
56
+ /**
57
+ * Column flag `stripSurroundingBrackets: false` disables OpenSearch
58
+ * bracket-stripping for that column. Default (undefined/true) is enabled.
59
+ */
60
+ exports.formatColumnValues = formatColumnValues;
61
+ const isBracketStripEnabled = function isBracketStripEnabled() {
62
+ let column = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
63
+ return column.stripSurroundingBrackets !== false;
64
+ };
65
+
66
+ /**
67
+ * Remove wrapping square brackets from OpenSearch array-as-string values.
68
+ * "[Complete Response]" => "Complete Response"; "[]" => "".
69
+ */
70
+ exports.isBracketStripEnabled = isBracketStripEnabled;
71
+ const stripSurroundingBrackets = value => {
72
+ if (value == null) {
73
+ return value;
74
+ }
75
+ if (Array.isArray(value)) {
76
+ return value.map(item => stripSurroundingBrackets(item));
77
+ }
78
+ if (typeof value !== 'string') {
79
+ return value;
80
+ }
81
+ const text = value.trim();
82
+ if (text === '[]') {
83
+ return '';
84
+ }
85
+ if (text.startsWith('[') && text.endsWith(']')) {
86
+ return text.slice(1, -1).trim();
87
+ }
88
+ return value;
89
+ };
90
+
91
+ /** Display helper: strip wrapping brackets and join arrays. */
92
+ exports.stripSurroundingBrackets = stripSurroundingBrackets;
93
+ const formatValueForDisplay = value => {
94
+ const stripped = stripSurroundingBrackets(value);
95
+ if (Array.isArray(stripped)) {
96
+ return stripped.map(item => item == null ? '' : String(item)).filter(Boolean).join(', ');
97
+ }
98
+ if (stripped == null) {
99
+ return '';
100
+ }
101
+ return String(stripped);
102
+ };
103
+ exports.formatValueForDisplay = formatValueForDisplay;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.notIncludedCellStyle = exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.STUDY_DOWNLOAD = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.DBGAP = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CPI = exports.CHECKBOX = void 0;
6
+ exports.notIncludedCellStyle = exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.STUDY_DOWNLOAD = exports.STUDIES = exports.MODAL = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.EXCLUDE_FROM_DOWNLOAD = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.DBGAP = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CPI_MAPPING = exports.CPI = exports.CHECKBOX = void 0;
7
7
  const CHECKBOX = 'CHECKBOX';
8
8
  exports.CHECKBOX = CHECKBOX;
9
9
  const DELETE = 'DELETE';
@@ -20,6 +20,8 @@ const FORMAT_DATA = 'FORMAT_DATA';
20
20
  exports.FORMAT_DATA = FORMAT_DATA;
21
21
  const CPI = 'CPI';
22
22
  exports.CPI = CPI;
23
+ const CPI_MAPPING = 'CPI_MAPPING';
24
+ exports.CPI_MAPPING = CPI_MAPPING;
23
25
  const FORMAT_BYTES = 'FORMAT_BYTES';
24
26
  exports.FORMAT_BYTES = FORMAT_BYTES;
25
27
  const TRANSFORM = 'TRANSFORM';
@@ -30,6 +32,12 @@ const EXPAND = 'EXPAND';
30
32
  exports.EXPAND = EXPAND;
31
33
  const DBGAP = 'DBGAP';
32
34
  exports.DBGAP = DBGAP;
35
+ const MODAL = 'MODAL';
36
+ exports.MODAL = MODAL;
37
+ const EXCLUDE_FROM_DOWNLOAD = 'EXCLUDE_FROM_DOWNLOAD';
38
+ exports.EXCLUDE_FROM_DOWNLOAD = EXCLUDE_FROM_DOWNLOAD;
39
+ const STUDIES = 'STUDIES';
40
+ exports.STUDIES = STUDIES;
33
41
  const cellTypes = {
34
42
  CUSTOM_ELEM,
35
43
  LINK,
@@ -38,19 +46,23 @@ const cellTypes = {
38
46
  DELETE,
39
47
  DEFAULT,
40
48
  FORMAT_DATA,
41
- CPI
49
+ CPI,
50
+ CPI_MAPPING,
51
+ STUDIES
42
52
  };
43
53
  exports.cellTypes = cellTypes;
44
54
  const cellStyles = {
45
55
  TRANSFORM,
46
56
  EXPAND,
47
57
  DBGAP,
48
- STUDY_DOWNLOAD
58
+ STUDY_DOWNLOAD,
59
+ MODAL,
60
+ EXCLUDE_FROM_DOWNLOAD
49
61
  };
50
62
  exports.cellStyles = cellStyles;
51
63
  const actionCellTypes = [CHECKBOX, DELETE];
52
64
  exports.actionCellTypes = actionCellTypes;
53
- const notIncludedCellStyle = [STUDY_DOWNLOAD];
65
+ const notIncludedCellStyle = [STUDY_DOWNLOAD, EXCLUDE_FROM_DOWNLOAD];
54
66
  exports.notIncludedCellStyle = notIncludedCellStyle;
55
67
  const FORMAT_DATA_CELLS = [FORMAT_BYTES];
56
68
  exports.FORMAT_DATA_CELLS = FORMAT_DATA_CELLS;
@@ -7,6 +7,8 @@ exports.convertToCSV = convertToCSV;
7
7
  exports.createFileName = createFileName;
8
8
  exports.downloadCSV = downloadCSV;
9
9
  exports.downloadJson = downloadJson;
10
+ exports.formatAgeForDownload = formatAgeForDownload;
11
+ exports.getDownloadColumns = getDownloadColumns;
10
12
  var _Dataformat = require("./Dataformat");
11
13
  var _Types = require("./Types");
12
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; }
@@ -14,6 +16,31 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
14
16
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
18
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
+ const AGE_FIELDS = new Set(['age_at_diagnosis', 'participant_age_at_collection', 'age_at_treatment_start', 'age_at_treatment_end', 'age_at_response', 'age_at_last_known_survival_status', 'age_at_event_free_survival_status']);
20
+
21
+ /**
22
+ * Sentinel OpenSearch age values (-999) become "Not Reported" for CSV/JSON download.
23
+ * Supports scalars, arrays (files table), and bracketed strings.
24
+ */
25
+ function formatAgeForDownload(value) {
26
+ if (Array.isArray(value)) {
27
+ if (value.length === 0) {
28
+ return 'Not Reported';
29
+ }
30
+ return value.map(item => formatAgeForDownload(item)).join('; ');
31
+ }
32
+ if (value === -999 || value === '-999' || value == null || value === '') {
33
+ return 'Not Reported';
34
+ }
35
+ if (typeof value === 'string' && value.startsWith('[') && value.endsWith(']')) {
36
+ const inner = value.slice(1, -1).trim();
37
+ if (!inner) {
38
+ return 'Not Reported';
39
+ }
40
+ return inner.split(',').map(item => formatAgeForDownload(item.trim())).join('; ');
41
+ }
42
+ return String(value);
43
+ }
17
44
  function createFileName(fileName, type) {
18
45
  const date = new Date();
19
46
  const yyyy = date.getFullYear();
@@ -54,22 +81,25 @@ function convertToCSV(jsonse, keysToInclude, header) {
54
81
  if (line !== '') line += ',';
55
82
  if (keyName === 'file_size') {
56
83
  line += entry[keyName] !== null ? "\"".concat((0, _Dataformat.formatBytes)(entry[keyName]), "\"") : ' ';
57
- } else if (keyName === 'age_at_diagnosis' || keyName === 'participant_age_at_collection') {
58
- if (entry[keyName] === -999) {
59
- line += 'Not Reported';
84
+ } else if (AGE_FIELDS.has(keyName)) {
85
+ if (entry[keyName] == null) {
86
+ line += ' ';
60
87
  } else {
61
- line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
88
+ line += "\"".concat(formatAgeForDownload(entry[keyName]), "\"");
62
89
  }
63
- } else if (keyName === 'last_known_survival_status' || keyName === 'sample_id' || keyName === 'data_category') {
64
- if (!entry[keyName] || entry[keyName] === '[]') {
65
- line += '';
66
- } else if (entry[keyName].toString().charAt(0) === '[' && entry[keyName].toString().charAt(entry[keyName].toString().length - 1) === ']') {
67
- line += "\"".concat(entry[keyName].toString().substring(1, entry[keyName].length - 1), "\"");
90
+ } else {
91
+ const raw = entry[keyName];
92
+ if (raw == null) {
93
+ line += ' ';
68
94
  } else {
69
- line += "\"".concat(entry[keyName], "\"");
95
+ const stripped = (0, _Dataformat.stripSurroundingBrackets)(raw);
96
+ if (stripped === '' || stripped === '[]') {
97
+ line += '';
98
+ } else {
99
+ const display = Array.isArray(stripped) ? stripped.join(', ') : stripped;
100
+ line += "\"".concat(display, "\"");
101
+ }
70
102
  }
71
- } else {
72
- line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
73
103
  }
74
104
  return line;
75
105
  });
@@ -83,26 +113,34 @@ function convertToCSV(jsonse, keysToInclude, header) {
83
113
  });
84
114
  return str;
85
115
  }
86
- function downloadCSV(tableData, table, downloadFileName) {
87
- const {
88
- columns = []
89
- } = table;
90
- const filterColumns = columns.filter(_ref => {
116
+
117
+ /** Columns shown in the table, or marked downloadOnly (hidden in the UI, included in export). */
118
+ const isIncludedInDownload = _ref => {
119
+ let {
120
+ display,
121
+ downloadOnly
122
+ } = _ref;
123
+ return Boolean(display || downloadOnly);
124
+ };
125
+ function getDownloadColumns() {
126
+ let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
127
+ return columns.filter(_ref2 => {
91
128
  let {
92
129
  cellType
93
- } = _ref;
94
- return !_Types.actionCellTypes.includes(cellType);
95
- }).filter(_ref2 => {
96
- let {
97
- cellStyle
98
130
  } = _ref2;
99
- return !_Types.notIncludedCellStyle.includes(cellStyle);
131
+ return !_Types.actionCellTypes.includes(cellType);
100
132
  }).filter(_ref3 => {
101
133
  let {
102
- display
134
+ cellStyle
103
135
  } = _ref3;
104
- return display;
105
- });
136
+ return !_Types.notIncludedCellStyle.includes(cellStyle);
137
+ }).filter(isIncludedInDownload);
138
+ }
139
+ function downloadCSV(tableData, table, downloadFileName) {
140
+ const {
141
+ columns = []
142
+ } = table;
143
+ const filterColumns = getDownloadColumns(columns);
106
144
  const formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
107
145
  const jsonse = JSON.stringify(formatDataVal);
108
146
  const keysToInclude = filterColumns.filter(_ref4 => {
@@ -145,36 +183,22 @@ function downloadJson(tableData, table, downloadFileName) {
145
183
  const {
146
184
  columns = []
147
185
  } = table;
148
- const toDelete = columns.filter(e => !e.display);
149
- const filterColumns = columns.filter(_ref8 => {
150
- let {
151
- cellType
152
- } = _ref8;
153
- return !_Types.actionCellTypes.includes(cellType);
154
- }).filter(_ref9 => {
155
- let {
156
- display
157
- } = _ref9;
158
- return display;
159
- });
186
+ const toDelete = columns.filter(e => !e.display && !e.downloadOnly);
187
+ const filterColumns = getDownloadColumns(columns);
160
188
  let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
161
189
  formatDataVal = formatDataVal.map(entry => {
162
- let survivalStatus = entry.last_known_survival_status;
163
- let sampleId = entry.sample_id;
164
- let dataCategory = entry.data_category;
165
190
  const toReturn = _objectSpread({}, entry);
166
- if (survivalStatus && survivalStatus.toString().charAt(0) === '[' && survivalStatus.toString().charAt(survivalStatus.toString().length - 1) === ']') {
167
- survivalStatus = survivalStatus.toString().substring(1, survivalStatus.length - 1);
168
- toReturn['Last Known Survival Status'] = survivalStatus;
169
- }
170
- if (sampleId && sampleId.toString().charAt(0) === '[' && sampleId.toString().charAt(sampleId.toString().length - 1) === ']') {
171
- sampleId = sampleId.toString().substring(1, sampleId.length - 1);
172
- toReturn['Sample Id'] = sampleId;
173
- }
174
- if (dataCategory && dataCategory.toString().charAt(0) === '[' && dataCategory.toString().charAt(dataCategory.toString().length - 1) === ']') {
175
- dataCategory = dataCategory.toString().substring(1, dataCategory.length - 1);
176
- toReturn['Data Category'] = dataCategory;
177
- }
191
+ AGE_FIELDS.forEach(field => {
192
+ if (Object.prototype.hasOwnProperty.call(entry, field) && entry[field] != null) {
193
+ toReturn[field] = formatAgeForDownload(entry[field]);
194
+ }
195
+ });
196
+ Object.keys(toReturn).forEach(key => {
197
+ if (AGE_FIELDS.has(key)) {
198
+ return;
199
+ }
200
+ toReturn[key] = (0, _Dataformat.stripSurroundingBrackets)(toReturn[key]);
201
+ });
178
202
  toDelete.forEach(column => delete toReturn[column.dataField]);
179
203
  return toReturn;
180
204
  });
@@ -7,7 +7,7 @@ exports.default = exports.btnTypes = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _client = require("@apollo/client");
9
9
  var _CPIFilesView = _interopRequireDefault(require("./CPIFilesView/CPIFilesView"));
10
- var _Snackbar = _interopRequireDefault(require("./Snackbar/Snackbar"));
10
+ var _CartToast = _interopRequireDefault(require("./Snackbar/CartToast"));
11
11
  var _AddToCartDialogAlertView = _interopRequireDefault(require("./AddToCartDialog/AddToCartDialogAlertView"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  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); }
@@ -19,29 +19,20 @@ const btnTypes = {
19
19
  DOWNLOAD_MANIFEST: 'DOWNLOAD_MANIFEST'
20
20
  };
21
21
  /**
22
- * customize button based on configuration
23
- * refer config table (wrapper component config)
22
+ * Explore CPI add-files button. Uses CartToast (body portal) instead of the
23
+ * Global Search MUI Snackbar so the toast stays visible above the Explore Modal.
24
24
  */
25
25
  exports.btnTypes = btnTypes;
26
26
  const AddFilesView = props => {
27
27
  const {
28
28
  count,
29
+ alreadyInCartCount,
29
30
  alertMessage,
30
31
  cartFiles,
31
32
  buttonStyle
32
33
  } = props;
33
- /**
34
- * snackbar state
35
- */
36
34
  const [openSnackbar, setOpenSnackbar] = (0, _react.useState)(false);
37
-
38
- /**
39
- * conditionally display max file Alter/Error dialog view
40
- */
41
35
  const [displayAlter, setAlterDisplay] = (0, _react.useState)(false);
42
- /**
43
- * acess bento app client via ApolloProvider
44
- */
45
36
  const client = (0, _client.useApolloClient)();
46
37
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CPIFilesView.default, _extends({}, props, {
47
38
  client: client,
@@ -49,9 +40,10 @@ const AddFilesView = props => {
49
40
  setOpenSnackbar: setOpenSnackbar,
50
41
  cartFiles: cartFiles,
51
42
  buttonStyle: buttonStyle
52
- })), /*#__PURE__*/_react.default.createElement(_Snackbar.default, {
43
+ })), /*#__PURE__*/_react.default.createElement(_CartToast.default, {
53
44
  open: openSnackbar,
54
45
  count: count,
46
+ alreadyInCartCount: alreadyInCartCount,
55
47
  onClose: () => setOpenSnackbar(false)
56
48
  }), displayAlter && /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
57
49
  alertMessage: alertMessage,
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.ToolTipView = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _toolTip = _interopRequireDefault(require("@bento-core/tool-tip"));
9
+ var _core = require("@material-ui/core");
10
+ var _Snackbar = _interopRequireDefault(require("../Snackbar/Snackbar"));
11
+ var _AddToCartDialogAlertView = _interopRequireDefault(require("../AddToCartDialog/AddToCartDialogAlertView"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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); }
14
+ 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; }
15
+ const customTooltip = {
16
+ border: '#03A383 1px solid'
17
+ };
18
+ const customArrow = {
19
+ '&::before': {
20
+ border: '#03A383 1px solid'
21
+ }
22
+ };
23
+ const iconStyle = {
24
+ paddingRight: '20px',
25
+ paddingBottom: '20px',
26
+ paddingLeft: '5px'
27
+ };
28
+ const ToolTipView = props => {
29
+ const {
30
+ section,
31
+ tooltipCofig
32
+ } = props;
33
+ const {
34
+ icon,
35
+ src,
36
+ alt,
37
+ arrow = false,
38
+ tooltipText
39
+ } = tooltipCofig;
40
+ return /*#__PURE__*/_react.default.createElement(_toolTip.default, {
41
+ placement: "top",
42
+ title: tooltipText || "".concat(tooltipCofig[section]),
43
+ arrow: arrow,
44
+ classes: {
45
+ tooltip: customTooltip,
46
+ arrow: customArrow
47
+ }
48
+ }, /*#__PURE__*/_react.default.createElement("img", {
49
+ src: icon || src,
50
+ alt: alt,
51
+ style: iconStyle
52
+ }));
53
+ };
54
+
55
+ // const checkDuplicate = (cartFiles, ids) => {
56
+ // const newIds = [];
57
+ // for (let i = 0; i < ids.length; i += 1) {
58
+ // if (!cartFiles.includes(ids[i])) {
59
+ // newIds.push(ids[i]);
60
+ // }
61
+ // }
62
+ // return newIds;
63
+ // };
64
+ exports.ToolTipView = ToolTipView;
65
+ const checkDuplicate = (cartFiles, ids) => ids.filter(id => !cartFiles[id]);
66
+ const AddToCartView = props => {
67
+ const {
68
+ cartFiles,
69
+ fileId,
70
+ buttonStyle,
71
+ addFiles,
72
+ count,
73
+ alreadyInCartCount
74
+ } = props;
75
+
76
+ // const [isDataloading, setIsDataloading] = useState(false);
77
+ const [openSnackbar, setOpenSnackbar] = (0, _react.useState)(false);
78
+ const [displayAlter, setAlterDisplay] = (0, _react.useState)(false);
79
+ const cartFilesDict = {};
80
+ cartFiles.forEach(file => {
81
+ cartFilesDict[file] = true;
82
+ });
83
+
84
+ // const backdropCls = {
85
+ // width: '100%',
86
+ // zIndex: 99999,
87
+ // background: 'rgba(0, 0, 0, 0.1)',
88
+ // };
89
+ /**
90
+ * verify and set file ids
91
+ */
92
+ const addAllFiles = () => {
93
+ const idsInitial = fileId || [];
94
+ const ids = Array.isArray(idsInitial) ? idsInitial : [idsInitial];
95
+ const fileCount = ids.length;
96
+ const upperLimit = 200000;
97
+ const cartCount = cartFiles.length;
98
+ if (fileCount <= upperLimit && cartCount < upperLimit) {
99
+ const newIds = checkDuplicate(cartFiles, ids);
100
+ if (cartCount + newIds.length <= upperLimit) {
101
+ addFiles(ids);
102
+ setOpenSnackbar(true);
103
+ } else {
104
+ setAlterDisplay(true);
105
+ }
106
+ } else {
107
+ setAlterDisplay(true);
108
+ }
109
+ };
110
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Button, {
111
+ variant: "outlined",
112
+ onClick: addAllFiles,
113
+ disableRipple: true,
114
+ style: buttonStyle,
115
+ disabled: false
116
+ }, "ADD TO CART"), /*#__PURE__*/_react.default.createElement(_Snackbar.default, {
117
+ open: openSnackbar,
118
+ count: count,
119
+ alreadyInCartCount: alreadyInCartCount,
120
+ onClose: () => setOpenSnackbar(false)
121
+ }), displayAlter && /*#__PURE__*/_react.default.createElement(_AddToCartDialogAlertView.default, {
122
+ alertMessage: "The cart is limited to 200,000 files. Please narrow the search criteria or remove some files from the cart to add more.",
123
+ open: displayAlter,
124
+ onClose: () => setAlterDisplay(false)
125
+ }));
126
+ };
127
+ var _default = AddToCartView;
128
+ exports.default = _default;
@@ -0,0 +1,28 @@
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 _cart = require("@bento-core/cart");
10
+ var _AddToCartView = _interopRequireDefault(require("./AddToCartView"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const AddToCartRedux = props => /*#__PURE__*/_react.default.createElement(_AddToCartView.default, props);
13
+
14
+ /**
15
+ * create query variable with actie filters
16
+ */
17
+ const mapStateToProps = state => ({
18
+ count: state.cartReducer && state.cartReducer.count,
19
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
20
+ cartFiles: state.cartReducer && state.cartReducer.filesId
21
+ });
22
+ const mapDispatchToProps = dispatch => ({
23
+ addFiles: files => {
24
+ dispatch((0, _cart.onAddCartFiles)(files));
25
+ }
26
+ });
27
+ var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(AddToCartRedux);
28
+ exports.default = _default;
@@ -67,7 +67,7 @@ const ToolTipView = props => {
67
67
  // };
68
68
  exports.ToolTipView = ToolTipView;
69
69
  const checkDuplicate = (cartFiles, ids) => ids.filter(id => !cartFiles[id]);
70
- const addFileQuery = (0, _graphqlTag.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nquery search ( \n $participant_ids: [String],\n){\n fileIDsFromList ( \n participant_ids: $participant_ids,\n ) \n}\n "])));
70
+ const addFileQuery = (0, _graphqlTag.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nquery search (\n $pid: [String],\n){\n fileIDsFromList (\n pid: $pid,\n )\n}\n "])));
71
71
  const CPIFilesComponent = props => {
72
72
  const {
73
73
  title,
@@ -82,7 +82,8 @@ const CPIFilesComponent = props => {
82
82
  cartFiles,
83
83
  participantIds,
84
84
  buttonStyle,
85
- rowID
85
+ rowID,
86
+ onOptionClick
86
87
  } = props;
87
88
  /**
88
89
  * conditionally display dialog view
@@ -106,21 +107,26 @@ const CPIFilesComponent = props => {
106
107
  * verify and set file ids
107
108
  */
108
109
  const addAllFiles = () => {
110
+ if (typeof onOptionClick === 'function') {
111
+ onOptionClick();
112
+ }
109
113
  let toAdd = [];
110
114
  if (btnType === 'ADD_ALL_FILES') {
115
+ // Always include the modal participant pid plus any internal CPI-mapped ids.
116
+ toAdd = rowID ? [rowID] : [];
111
117
  participantIds.forEach(e => {
112
118
  if (e.data_type === 'internal' && e.p_id) {
113
119
  toAdd = toAdd.concat(e.p_id);
114
120
  }
115
- toAdd = toAdd.concat(rowID);
116
121
  });
117
122
  } else {
118
- toAdd = participantIds.concat(rowID);
123
+ toAdd = (rowID ? [rowID] : []).concat(participantIds);
119
124
  }
125
+ toAdd = [...new Set(toAdd.filter(id => typeof id === 'string' && id))];
120
126
  const fileIds = (0, _WrapperService.getFilesID)({
121
127
  client,
122
128
  variables: {
123
- participant_ids: toAdd
129
+ pid: toAdd
124
130
  },
125
131
  query: addFileQuery
126
132
  });
@@ -136,7 +142,7 @@ const CPIFilesComponent = props => {
136
142
  setOpen(true);
137
143
  setAddFilesId(ids);
138
144
  } else {
139
- const newIds = checkDuplicate(cartFiles, ids);
145
+ const newIds = checkDuplicate(cartFilesDict, ids);
140
146
  if (cartCount + newIds.length <= upperLimit) {
141
147
  setOpen(true);
142
148
  setAddFilesId(newIds);