@bento-core/table 1.0.1-ccdihub.70 → 1.0.1-ccdihub.72

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.
@@ -60,13 +60,13 @@ function convertToCSV(jsonse, keysToInclude, header) {
60
60
  } else {
61
61
  line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
62
62
  }
63
- } else if (keyName === 'last_known_survival_status') {
64
- if (entry[keyName] === '[]') {
63
+ } else if (keyName === 'last_known_survival_status' || keyName === 'sample_id' || keyName === 'data_category') {
64
+ if (!entry[keyName] || entry[keyName] === '[]') {
65
65
  line += '';
66
66
  } else if (entry[keyName].toString().charAt(0) === '[' && entry[keyName].toString().charAt(entry[keyName].toString().length - 1) === ']') {
67
- line += entry[keyName].toString().substring(1, entry[keyName].length - 1);
67
+ line += "\"".concat(entry[keyName].toString().substring(1, entry[keyName].length - 1), "\"");
68
68
  } else {
69
- line += entry[keyName];
69
+ line += "\"".concat(entry[keyName], "\"");
70
70
  }
71
71
  } else {
72
72
  line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
@@ -148,18 +148,29 @@ function downloadJson(tableData, table, downloadFileName) {
148
148
  });
149
149
  let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
150
150
  formatDataVal = formatDataVal.map(entry => {
151
- const survivalStatus = entry.last_known_survival_status;
152
- if (survivalStatus === '[]') {
153
- return _objectSpread(_objectSpread({}, entry), {}, {
154
- last_known_survival_status: ''
155
- });
151
+ let survivalStatus = entry.last_known_survival_status;
152
+ let sampleId = entry.sample_id;
153
+ let dataCategory = entry.data_category;
154
+ if (!survivalStatus || survivalStatus === '[]') {
155
+ survivalStatus = '';
156
+ } else if (survivalStatus.toString().charAt(0) === '[' && survivalStatus.toString().charAt(survivalStatus.toString().length - 1) === ']') {
157
+ survivalStatus = survivalStatus.toString().substring(1, survivalStatus.length - 1);
156
158
  }
157
- if (survivalStatus.toString().charAt(0) === '[' && survivalStatus.toString().charAt(survivalStatus.toString().length - 1) === ']') {
158
- return _objectSpread(_objectSpread({}, entry), {}, {
159
- last_known_survival_status: survivalStatus.toString().substring(1, survivalStatus.length - 1)
160
- });
159
+ if (!sampleId || sampleId === '[]') {
160
+ sampleId = '';
161
+ } else if (sampleId.toString().charAt(0) === '[' && sampleId.toString().charAt(sampleId.toString().length - 1) === ']') {
162
+ sampleId = sampleId.toString().substring(1, sampleId.length - 1);
161
163
  }
162
- return entry;
164
+ if (!dataCategory || dataCategory === '[]') {
165
+ dataCategory = '';
166
+ } else if (dataCategory.toString().charAt(0) === '[' && dataCategory.toString().charAt(dataCategory.toString().length - 1) === ']') {
167
+ dataCategory = dataCategory.toString().substring(1, dataCategory.length - 1);
168
+ }
169
+ return _objectSpread(_objectSpread({}, entry), {}, {
170
+ last_known_survival_status: survivalStatus,
171
+ sample_id: sampleId,
172
+ data_category: dataCategory
173
+ });
163
174
  });
164
175
  filterColumns.forEach(column => {
165
176
  formatDataVal = JSON.parse(JSON.stringify(formatDataVal).split("\"".concat(column.dataField, "\":")).join("\"".concat(column.header, "\":")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdihub.70",
3
+ "version": "1.0.1-ccdihub.72",
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",
@@ -46,13 +46,13 @@ export function convertToCSV(jsonse, keysToInclude, header) {
46
46
  } else {
47
47
  line += entry[keyName] !== null ? `"${entry[keyName]}"` : ' ';
48
48
  }
49
- } else if (keyName === 'last_known_survival_status') {
50
- if (entry[keyName] === '[]') {
49
+ } else if (keyName === 'last_known_survival_status' || keyName === 'sample_id' || keyName === 'data_category') {
50
+ if (!entry[keyName] || entry[keyName] === '[]') {
51
51
  line += '';
52
52
  } else if (entry[keyName].toString().charAt(0) === '[' && entry[keyName].toString().charAt(entry[keyName].toString().length - 1) === ']') {
53
- line += entry[keyName].toString().substring(1, entry[keyName].length - 1);
53
+ line += `"${entry[keyName].toString().substring(1, entry[keyName].length - 1)}"`;
54
54
  } else {
55
- line += entry[keyName];
55
+ line += `"${entry[keyName]}"`;
56
56
  }
57
57
  } else {
58
58
  line += entry[keyName] !== null ? `"${entry[keyName]}"` : ' ';
@@ -97,18 +97,33 @@ export function downloadJson(tableData, table, downloadFileName) {
97
97
  const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType));
98
98
  let formatDataVal = formatColumnValues(filterColumns, tableData);
99
99
  formatDataVal = formatDataVal.map((entry) => {
100
- const survivalStatus = entry.last_known_survival_status;
101
- if (survivalStatus === '[]') {
102
- return { ...entry, last_known_survival_status: '' };
100
+ let survivalStatus = entry.last_known_survival_status;
101
+ let sampleId = entry.sample_id;
102
+ let dataCategory = entry.data_category;
103
+
104
+ if (!survivalStatus || survivalStatus === '[]') {
105
+ survivalStatus = '';
106
+ } else if (survivalStatus.toString().charAt(0) === '[' && survivalStatus.toString().charAt(survivalStatus.toString().length - 1) === ']') {
107
+ survivalStatus = survivalStatus.toString().substring(1, survivalStatus.length - 1);
108
+ }
109
+
110
+ if (!sampleId || sampleId === '[]') {
111
+ sampleId = '';
112
+ } else if (sampleId.toString().charAt(0) === '[' && sampleId.toString().charAt(sampleId.toString().length - 1) === ']') {
113
+ sampleId = sampleId.toString().substring(1, sampleId.length - 1);
103
114
  }
104
- if (survivalStatus.toString().charAt(0) === '[' && survivalStatus.toString().charAt(survivalStatus.toString().length - 1) === ']') {
105
- return {
106
- ...entry,
107
- last_known_survival_status:
108
- survivalStatus.toString().substring(1, survivalStatus.length - 1),
109
- };
115
+
116
+ if (!dataCategory || dataCategory === '[]') {
117
+ dataCategory = '';
118
+ } else if (dataCategory.toString().charAt(0) === '[' && dataCategory.toString().charAt(dataCategory.toString().length - 1) === ']') {
119
+ dataCategory = dataCategory.toString().substring(1, dataCategory.length - 1);
110
120
  }
111
- return entry;
121
+ return {
122
+ ...entry,
123
+ last_known_survival_status: survivalStatus,
124
+ sample_id: sampleId,
125
+ data_category: dataCategory,
126
+ };
112
127
  });
113
128
  filterColumns.forEach((column) => {
114
129
  formatDataVal = JSON.parse(