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

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') {
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,22 @@ 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
+ if (!survivalStatus || survivalStatus === '[]') {
154
+ survivalStatus = '';
155
+ } else if (survivalStatus.toString().charAt(0) === '[' && survivalStatus.toString().charAt(survivalStatus.toString().length - 1) === ']') {
156
+ survivalStatus = survivalStatus.toString().substring(1, survivalStatus.length - 1);
156
157
  }
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
- });
158
+ if (!sampleId || sampleId === '[]') {
159
+ sampleId = '';
160
+ } else if (sampleId.toString().charAt(0) === '[' && sampleId.toString().charAt(sampleId.toString().length - 1) === ']') {
161
+ sampleId = sampleId.toString().substring(1, sampleId.length - 1);
161
162
  }
162
- return entry;
163
+ return _objectSpread(_objectSpread({}, entry), {}, {
164
+ last_known_survival_status: survivalStatus,
165
+ sample_id: sampleId
166
+ });
163
167
  });
164
168
  filterColumns.forEach(column => {
165
169
  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.71",
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') {
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,20 @@ 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
+ if (!survivalStatus || survivalStatus === '[]') {
103
+ survivalStatus = '';
104
+ } else if (survivalStatus.toString().charAt(0) === '[' && survivalStatus.toString().charAt(survivalStatus.toString().length - 1) === ']') {
105
+ survivalStatus = survivalStatus.toString().substring(1, survivalStatus.length - 1);
103
106
  }
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
- };
107
+
108
+ if (!sampleId || sampleId === '[]') {
109
+ sampleId = '';
110
+ } else if (sampleId.toString().charAt(0) === '[' && sampleId.toString().charAt(sampleId.toString().length - 1) === ']') {
111
+ sampleId = sampleId.toString().substring(1, sampleId.length - 1);
110
112
  }
111
- return entry;
113
+ return { ...entry, last_known_survival_status: survivalStatus, sample_id: sampleId };
112
114
  });
113
115
  filterColumns.forEach((column) => {
114
116
  formatDataVal = JSON.parse(