@bento-core/table 1.0.1-ccdiintegrated.3 → 1.0.1-ccdiintegrated.5
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.
- package/dist/body/DisplayBodyCell.js +6 -2
- package/dist/body/components/CustomLinkView.js +2 -1
- package/dist/body/components/DataFormatView.js +1 -1
- package/dist/index.js +18 -0
- package/dist/util/Dataformat.js +50 -2
- package/dist/util/downloadTable.js +17 -53
- package/package.json +1 -1
- package/src/body/DisplayBodyCell.js +18 -2
- package/src/body/components/CustomLinkView.js +4 -1
- package/src/body/components/DataFormatView.js +4 -2
- package/src/index.js +6 -1
- package/src/util/Dataformat.js +47 -0
- package/src/util/downloadTable.js +18 -54
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _core = require("@material-ui/core");
|
|
9
9
|
var _Types = require("../util/Types");
|
|
10
|
+
var _Dataformat = require("../util/Dataformat");
|
|
10
11
|
var _CustomLinkView = _interopRequireDefault(require("./components/CustomLinkView"));
|
|
11
12
|
var _DataFormatView = _interopRequireDefault(require("./components/DataFormatView"));
|
|
12
13
|
var _CPIView = _interopRequireDefault(require("./components/CPIView"));
|
|
@@ -30,8 +31,11 @@ const CustomComponent = _ref => {
|
|
|
30
31
|
dataField,
|
|
31
32
|
customCellRender
|
|
32
33
|
} = column;
|
|
34
|
+
const raw = row[dataField];
|
|
35
|
+
const value = (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.stripSurroundingBrackets)(raw) : raw;
|
|
33
36
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, customCellRender(_objectSpread(_objectSpread(_objectSpread({}, row), column), {}, {
|
|
34
|
-
|
|
37
|
+
[dataField]: value,
|
|
38
|
+
label: value
|
|
35
39
|
})));
|
|
36
40
|
};
|
|
37
41
|
|
|
@@ -87,7 +91,7 @@ const ViewCell = _ref2 => {
|
|
|
87
91
|
column: column
|
|
88
92
|
});
|
|
89
93
|
default:
|
|
90
|
-
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, row[column.dataField]);
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.formatValueForDisplay)(row[column.dataField]) : row[column.dataField]);
|
|
91
95
|
}
|
|
92
96
|
};
|
|
93
97
|
const DisplayCell = _ref3 => {
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _core = require("@material-ui/core");
|
|
9
9
|
var _Types = require("../../util/Types");
|
|
10
|
+
var _Dataformat = require("../../util/Dataformat");
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
/**
|
|
12
13
|
* Custom Link component
|
|
@@ -24,7 +25,7 @@ const CustomLinkView = _ref => {
|
|
|
24
25
|
return /*#__PURE__*/_react.default.createElement(_core.Link, {
|
|
25
26
|
href: url,
|
|
26
27
|
className: _Types.cellTypes.LINK
|
|
27
|
-
}, /*#__PURE__*/_react.default.createElement(_core.Typography, null, row[column === null || column === void 0 ? void 0 : column.dataField]));
|
|
28
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.formatValueForDisplay)(row[column === null || column === void 0 ? void 0 : column.dataField]) : row[column === null || column === void 0 ? void 0 : column.dataField]));
|
|
28
29
|
};
|
|
29
30
|
var _default = CustomLinkView;
|
|
30
31
|
exports.default = _default;
|
|
@@ -26,7 +26,7 @@ const CellView = _ref => {
|
|
|
26
26
|
case _Types.dataFormatTypes.FORMAT_BYTES:
|
|
27
27
|
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.formatBytes)(value));
|
|
28
28
|
default:
|
|
29
|
-
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, value);
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.formatValueForDisplay)(value) : value);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
const DataFormatView = _ref2 => {
|
package/dist/index.js
CHANGED
|
@@ -45,12 +45,30 @@ Object.defineProperty(exports, "formatBytes", {
|
|
|
45
45
|
return _Dataformat.formatBytes;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "formatValueForDisplay", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _Dataformat.formatValueForDisplay;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
48
54
|
Object.defineProperty(exports, "headerTypes", {
|
|
49
55
|
enumerable: true,
|
|
50
56
|
get: function get() {
|
|
51
57
|
return _Types.headerTypes;
|
|
52
58
|
}
|
|
53
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "isBracketStripEnabled", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _Dataformat.isBracketStripEnabled;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "stripSurroundingBrackets", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _Dataformat.stripSurroundingBrackets;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
54
72
|
var _TableView = _interopRequireDefault(require("./TableView"));
|
|
55
73
|
var _Types = require("./util/Types");
|
|
56
74
|
var _Dataformat = require("./util/Dataformat");
|
package/dist/util/Dataformat.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
|
@@ -86,16 +86,19 @@ function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
86
86
|
} else {
|
|
87
87
|
line += "\"".concat(formatAgeForDownload(entry[keyName]), "\"");
|
|
88
88
|
}
|
|
89
|
-
} else
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
line += "\"".concat(entry[keyName].toString().substring(1, entry[keyName].length - 1), "\"");
|
|
89
|
+
} else {
|
|
90
|
+
const raw = entry[keyName];
|
|
91
|
+
if (raw == null) {
|
|
92
|
+
line += ' ';
|
|
94
93
|
} else {
|
|
95
|
-
|
|
94
|
+
const stripped = (0, _Dataformat.stripSurroundingBrackets)(raw);
|
|
95
|
+
if (stripped === '' || stripped === '[]') {
|
|
96
|
+
line += '';
|
|
97
|
+
} else {
|
|
98
|
+
const display = Array.isArray(stripped) ? stripped.join(', ') : stripped;
|
|
99
|
+
line += "\"".concat(display, "\"");
|
|
100
|
+
}
|
|
96
101
|
}
|
|
97
|
-
} else {
|
|
98
|
-
line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
|
|
99
102
|
}
|
|
100
103
|
return line;
|
|
101
104
|
});
|
|
@@ -185,57 +188,18 @@ function downloadJson(tableData, table, downloadFileName) {
|
|
|
185
188
|
});
|
|
186
189
|
let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
|
187
190
|
formatDataVal = formatDataVal.map(entry => {
|
|
188
|
-
let survivalStatus = entry.last_known_survival_status;
|
|
189
|
-
let sampleId = entry.sample_id;
|
|
190
|
-
let dataCategory = entry.data_category;
|
|
191
|
-
let participantId = entry.participant_id;
|
|
192
|
-
let anatomicSite = entry.anatomic_site;
|
|
193
|
-
let sampleDescription = entry.sample_description;
|
|
194
|
-
let percentTumor = entry.percent_tumor;
|
|
195
|
-
let percentNecrosis = entry.percent_necrosis;
|
|
196
|
-
let consentCodes = entry.consent_codes;
|
|
197
191
|
const toReturn = _objectSpread({}, entry);
|
|
198
192
|
AGE_FIELDS.forEach(field => {
|
|
199
193
|
if (Object.prototype.hasOwnProperty.call(entry, field) && entry[field] != null) {
|
|
200
194
|
toReturn[field] = formatAgeForDownload(entry[field]);
|
|
201
195
|
}
|
|
202
196
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
toReturn['Sample Id'] = sampleId;
|
|
210
|
-
}
|
|
211
|
-
if (dataCategory && dataCategory.toString().charAt(0) === '[' && dataCategory.toString().charAt(dataCategory.toString().length - 1) === ']') {
|
|
212
|
-
dataCategory = dataCategory.toString().substring(1, dataCategory.length - 1);
|
|
213
|
-
toReturn['Data Category'] = dataCategory;
|
|
214
|
-
}
|
|
215
|
-
if (participantId && participantId.toString().charAt(0) === '[' && participantId.toString().charAt(participantId.toString().length - 1) === ']') {
|
|
216
|
-
participantId = participantId.toString().substring(1, participantId.length - 1);
|
|
217
|
-
toReturn['Participant ID'] = participantId;
|
|
218
|
-
}
|
|
219
|
-
if (anatomicSite && anatomicSite.toString().charAt(0) === '[' && anatomicSite.toString().charAt(anatomicSite.toString().length - 1) === ']') {
|
|
220
|
-
anatomicSite = anatomicSite.toString().substring(1, anatomicSite.length - 1);
|
|
221
|
-
toReturn['Anatomic Site'] = anatomicSite;
|
|
222
|
-
}
|
|
223
|
-
if (sampleDescription && sampleDescription.toString().charAt(0) === '[' && sampleDescription.toString().charAt(sampleDescription.toString().length - 1) === ']') {
|
|
224
|
-
sampleDescription = sampleDescription.toString().substring(1, sampleDescription.length - 1);
|
|
225
|
-
toReturn['Sample Description'] = sampleDescription;
|
|
226
|
-
}
|
|
227
|
-
if (percentTumor && percentTumor.toString().charAt(0) === '[' && percentTumor.toString().charAt(percentTumor.toString().length - 1) === ']') {
|
|
228
|
-
percentTumor = percentTumor.toString().substring(1, percentTumor.length - 1);
|
|
229
|
-
toReturn['Percent Tumor'] = percentTumor;
|
|
230
|
-
}
|
|
231
|
-
if (percentNecrosis && percentNecrosis.toString().charAt(0) === '[' && percentNecrosis.toString().charAt(percentNecrosis.toString().length - 1) === ']') {
|
|
232
|
-
percentNecrosis = percentNecrosis.toString().substring(1, percentNecrosis.length - 1);
|
|
233
|
-
toReturn['Percent Necrosis'] = percentNecrosis;
|
|
234
|
-
}
|
|
235
|
-
if (consentCodes && consentCodes.toString().charAt(0) === '[' && consentCodes.toString().charAt(consentCodes.toString().length - 1) === ']') {
|
|
236
|
-
consentCodes = consentCodes.toString().substring(1, consentCodes.length - 1);
|
|
237
|
-
toReturn['Consent Codes'] = consentCodes;
|
|
238
|
-
}
|
|
197
|
+
Object.keys(toReturn).forEach(key => {
|
|
198
|
+
if (AGE_FIELDS.has(key)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
toReturn[key] = (0, _Dataformat.stripSurroundingBrackets)(toReturn[key]);
|
|
202
|
+
});
|
|
239
203
|
toDelete.forEach(column => delete toReturn[column.dataField]);
|
|
240
204
|
return toReturn;
|
|
241
205
|
});
|
package/package.json
CHANGED
|
@@ -4,6 +4,11 @@ import {
|
|
|
4
4
|
Typography,
|
|
5
5
|
} from '@material-ui/core';
|
|
6
6
|
import { cellTypes } from '../util/Types';
|
|
7
|
+
import {
|
|
8
|
+
formatValueForDisplay,
|
|
9
|
+
isBracketStripEnabled,
|
|
10
|
+
stripSurroundingBrackets,
|
|
11
|
+
} from '../util/Dataformat';
|
|
7
12
|
import CustomLinkView from './components/CustomLinkView';
|
|
8
13
|
import DataFormatView from './components/DataFormatView';
|
|
9
14
|
import CPIView from './components/CPIView';
|
|
@@ -18,9 +23,18 @@ const CustomComponent = ({
|
|
|
18
23
|
column,
|
|
19
24
|
}) => {
|
|
20
25
|
const { dataField, customCellRender } = column;
|
|
26
|
+
const raw = row[dataField];
|
|
27
|
+
const value = isBracketStripEnabled(column)
|
|
28
|
+
? stripSurroundingBrackets(raw)
|
|
29
|
+
: raw;
|
|
21
30
|
return (
|
|
22
31
|
<>
|
|
23
|
-
{customCellRender({
|
|
32
|
+
{customCellRender({
|
|
33
|
+
...row,
|
|
34
|
+
...column,
|
|
35
|
+
[dataField]: value,
|
|
36
|
+
label: value,
|
|
37
|
+
})}
|
|
24
38
|
</>
|
|
25
39
|
);
|
|
26
40
|
};
|
|
@@ -88,7 +102,9 @@ const ViewCell = ({
|
|
|
88
102
|
default:
|
|
89
103
|
return (
|
|
90
104
|
<Typography>
|
|
91
|
-
{
|
|
105
|
+
{isBracketStripEnabled(column)
|
|
106
|
+
? formatValueForDisplay(row[column.dataField])
|
|
107
|
+
: row[column.dataField]}
|
|
92
108
|
</Typography>
|
|
93
109
|
);
|
|
94
110
|
}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Link, Typography,
|
|
4
4
|
} from '@material-ui/core';
|
|
5
5
|
import { cellTypes } from '../../util/Types';
|
|
6
|
+
import { formatValueForDisplay, isBracketStripEnabled } from '../../util/Dataformat';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Custom Link component
|
|
@@ -16,7 +17,9 @@ const CustomLinkView = ({
|
|
|
16
17
|
return (
|
|
17
18
|
<Link href={url} className={cellTypes.LINK}>
|
|
18
19
|
<Typography>
|
|
19
|
-
{
|
|
20
|
+
{isBracketStripEnabled(column)
|
|
21
|
+
? formatValueForDisplay(row[column?.dataField])
|
|
22
|
+
: row[column?.dataField]}
|
|
20
23
|
</Typography>
|
|
21
24
|
</Link>
|
|
22
25
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Typography } from '@material-ui/core';
|
|
3
3
|
import { dataFormatTypes } from '../../util/Types';
|
|
4
|
-
import { formatBytes } from '../../util/Dataformat';
|
|
4
|
+
import { formatBytes, formatValueForDisplay, isBracketStripEnabled } from '../../util/Dataformat';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* dataformat view for file size (byte, MB, GB)
|
|
@@ -23,7 +23,9 @@ const CellView = ({
|
|
|
23
23
|
default:
|
|
24
24
|
return (
|
|
25
25
|
<Typography>
|
|
26
|
-
{
|
|
26
|
+
{isBracketStripEnabled(column)
|
|
27
|
+
? formatValueForDisplay(value)
|
|
28
|
+
: value}
|
|
27
29
|
</Typography>
|
|
28
30
|
);
|
|
29
31
|
}
|
package/src/index.js
CHANGED
|
@@ -6,5 +6,10 @@ export {
|
|
|
6
6
|
ComponentTypes,
|
|
7
7
|
dataFormatTypes,
|
|
8
8
|
} from './util/Types';
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
formatBytes,
|
|
11
|
+
stripSurroundingBrackets,
|
|
12
|
+
formatValueForDisplay,
|
|
13
|
+
isBracketStripEnabled,
|
|
14
|
+
} from './util/Dataformat';
|
|
10
15
|
export { default as AddToCart } from './wrapper/components/AddToCart/ReduxAddToCart';
|
package/src/util/Dataformat.js
CHANGED
|
@@ -31,3 +31,50 @@ export const formatColumnValues = (columns, data) => {
|
|
|
31
31
|
}
|
|
32
32
|
return data;
|
|
33
33
|
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Column flag `stripSurroundingBrackets: false` disables OpenSearch
|
|
37
|
+
* bracket-stripping for that column. Default (undefined/true) is enabled.
|
|
38
|
+
*/
|
|
39
|
+
export const isBracketStripEnabled = (column = {}) => (
|
|
40
|
+
column.stripSurroundingBrackets !== false
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Remove wrapping square brackets from OpenSearch array-as-string values.
|
|
45
|
+
* "[Complete Response]" => "Complete Response"; "[]" => "".
|
|
46
|
+
*/
|
|
47
|
+
export const stripSurroundingBrackets = (value) => {
|
|
48
|
+
if (value == null) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
return value.map((item) => stripSurroundingBrackets(item));
|
|
53
|
+
}
|
|
54
|
+
if (typeof value !== 'string') {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
const text = value.trim();
|
|
58
|
+
if (text === '[]') {
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
if (text.startsWith('[') && text.endsWith(']')) {
|
|
62
|
+
return text.slice(1, -1).trim();
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** Display helper: strip wrapping brackets and join arrays. */
|
|
68
|
+
export const formatValueForDisplay = (value) => {
|
|
69
|
+
const stripped = stripSurroundingBrackets(value);
|
|
70
|
+
if (Array.isArray(stripped)) {
|
|
71
|
+
return stripped
|
|
72
|
+
.map((item) => (item == null ? '' : String(item)))
|
|
73
|
+
.filter(Boolean)
|
|
74
|
+
.join(', ');
|
|
75
|
+
}
|
|
76
|
+
if (stripped == null) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
return String(stripped);
|
|
80
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatBytes, formatColumnValues } from './Dataformat';
|
|
1
|
+
import { formatBytes, formatColumnValues, stripSurroundingBrackets } from './Dataformat';
|
|
2
2
|
import { actionCellTypes, notIncludedCellStyle } from './Types';
|
|
3
3
|
|
|
4
4
|
const AGE_FIELDS = new Set([
|
|
@@ -80,16 +80,19 @@ export function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
80
80
|
} else {
|
|
81
81
|
line += `"${formatAgeForDownload(entry[keyName])}"`;
|
|
82
82
|
}
|
|
83
|
-
} else
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
line += `"${entry[keyName].toString().substring(1, entry[keyName].length - 1)}"`;
|
|
83
|
+
} else {
|
|
84
|
+
const raw = entry[keyName];
|
|
85
|
+
if (raw == null) {
|
|
86
|
+
line += ' ';
|
|
88
87
|
} else {
|
|
89
|
-
|
|
88
|
+
const stripped = stripSurroundingBrackets(raw);
|
|
89
|
+
if (stripped === '' || stripped === '[]') {
|
|
90
|
+
line += '';
|
|
91
|
+
} else {
|
|
92
|
+
const display = Array.isArray(stripped) ? stripped.join(', ') : stripped;
|
|
93
|
+
line += `"${display}"`;
|
|
94
|
+
}
|
|
90
95
|
}
|
|
91
|
-
} else {
|
|
92
|
-
line += entry[keyName] !== null ? `"${entry[keyName]}"` : ' ';
|
|
93
96
|
}
|
|
94
97
|
return line;
|
|
95
98
|
});
|
|
@@ -134,15 +137,6 @@ export function downloadJson(tableData, table, downloadFileName) {
|
|
|
134
137
|
.filter(({ display }) => display);
|
|
135
138
|
let formatDataVal = formatColumnValues(filterColumns, tableData);
|
|
136
139
|
formatDataVal = formatDataVal.map((entry) => {
|
|
137
|
-
let survivalStatus = entry.last_known_survival_status;
|
|
138
|
-
let sampleId = entry.sample_id;
|
|
139
|
-
let dataCategory = entry.data_category;
|
|
140
|
-
let participantId = entry.participant_id;
|
|
141
|
-
let anatomicSite = entry.anatomic_site;
|
|
142
|
-
let sampleDescription = entry.sample_description;
|
|
143
|
-
let percentTumor = entry.percent_tumor;
|
|
144
|
-
let percentNecrosis = entry.percent_necrosis;
|
|
145
|
-
let consentCodes = entry.consent_codes;
|
|
146
140
|
const toReturn = { ...entry };
|
|
147
141
|
|
|
148
142
|
AGE_FIELDS.forEach((field) => {
|
|
@@ -151,42 +145,12 @@ export function downloadJson(tableData, table, downloadFileName) {
|
|
|
151
145
|
}
|
|
152
146
|
});
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
toReturn['Sample Id'] = sampleId;
|
|
161
|
-
}
|
|
162
|
-
if (dataCategory && dataCategory.toString().charAt(0) === '[' && dataCategory.toString().charAt(dataCategory.toString().length - 1) === ']') {
|
|
163
|
-
dataCategory = dataCategory.toString().substring(1, dataCategory.length - 1);
|
|
164
|
-
toReturn['Data Category'] = dataCategory;
|
|
165
|
-
}
|
|
166
|
-
if (participantId && participantId.toString().charAt(0) === '[' && participantId.toString().charAt(participantId.toString().length - 1) === ']') {
|
|
167
|
-
participantId = participantId.toString().substring(1, participantId.length - 1);
|
|
168
|
-
toReturn['Participant ID'] = participantId;
|
|
169
|
-
}
|
|
170
|
-
if (anatomicSite && anatomicSite.toString().charAt(0) === '[' && anatomicSite.toString().charAt(anatomicSite.toString().length - 1) === ']') {
|
|
171
|
-
anatomicSite = anatomicSite.toString().substring(1, anatomicSite.length - 1);
|
|
172
|
-
toReturn['Anatomic Site'] = anatomicSite;
|
|
173
|
-
}
|
|
174
|
-
if (sampleDescription && sampleDescription.toString().charAt(0) === '[' && sampleDescription.toString().charAt(sampleDescription.toString().length - 1) === ']') {
|
|
175
|
-
sampleDescription = sampleDescription.toString().substring(1, sampleDescription.length - 1);
|
|
176
|
-
toReturn['Sample Description'] = sampleDescription;
|
|
177
|
-
}
|
|
178
|
-
if (percentTumor && percentTumor.toString().charAt(0) === '[' && percentTumor.toString().charAt(percentTumor.toString().length - 1) === ']') {
|
|
179
|
-
percentTumor = percentTumor.toString().substring(1, percentTumor.length - 1);
|
|
180
|
-
toReturn['Percent Tumor'] = percentTumor;
|
|
181
|
-
}
|
|
182
|
-
if (percentNecrosis && percentNecrosis.toString().charAt(0) === '[' && percentNecrosis.toString().charAt(percentNecrosis.toString().length - 1) === ']') {
|
|
183
|
-
percentNecrosis = percentNecrosis.toString().substring(1, percentNecrosis.length - 1);
|
|
184
|
-
toReturn['Percent Necrosis'] = percentNecrosis;
|
|
185
|
-
}
|
|
186
|
-
if (consentCodes && consentCodes.toString().charAt(0) === '[' && consentCodes.toString().charAt(consentCodes.toString().length - 1) === ']') {
|
|
187
|
-
consentCodes = consentCodes.toString().substring(1, consentCodes.length - 1);
|
|
188
|
-
toReturn['Consent Codes'] = consentCodes;
|
|
189
|
-
}
|
|
148
|
+
Object.keys(toReturn).forEach((key) => {
|
|
149
|
+
if (AGE_FIELDS.has(key)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
toReturn[key] = stripSurroundingBrackets(toReturn[key]);
|
|
153
|
+
});
|
|
190
154
|
|
|
191
155
|
toDelete.forEach((column) => delete toReturn[column.dataField]);
|
|
192
156
|
return toReturn;
|