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

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.
@@ -9,6 +9,11 @@ exports.downloadCSV = downloadCSV;
9
9
  exports.downloadJson = downloadJson;
10
10
  var _Dataformat = require("./Dataformat");
11
11
  var _Types = require("./Types");
12
+ 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; }
13
+ 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; }
14
+ 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
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
+ 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); }
12
17
  function createFileName(fileName, type) {
13
18
  const date = new Date();
14
19
  const yyyy = date.getFullYear();
@@ -55,6 +60,14 @@ function convertToCSV(jsonse, keysToInclude, header) {
55
60
  } else {
56
61
  line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
57
62
  }
63
+ } else if (keyName === 'last_known_survival_status') {
64
+ if (entry[keyName] === '[]') {
65
+ line += '';
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);
68
+ } else {
69
+ line += entry[keyName];
70
+ }
58
71
  } else {
59
72
  line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
60
73
  }
@@ -134,6 +147,20 @@ function downloadJson(tableData, table, downloadFileName) {
134
147
  return !_Types.actionCellTypes.includes(cellType);
135
148
  });
136
149
  let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
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
+ });
156
+ }
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
+ });
161
+ }
162
+ return entry;
163
+ });
137
164
  filterColumns.forEach(column => {
138
165
  formatDataVal = JSON.parse(JSON.stringify(formatDataVal).split("\"".concat(column.dataField, "\":")).join("\"".concat(column.header, "\":")));
139
166
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdihub.69",
3
+ "version": "1.0.1-ccdihub.70",
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,6 +46,14 @@ 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] === '[]') {
51
+ line += '';
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);
54
+ } else {
55
+ line += entry[keyName];
56
+ }
49
57
  } else {
50
58
  line += entry[keyName] !== null ? `"${entry[keyName]}"` : ' ';
51
59
  }
@@ -88,6 +96,20 @@ export function downloadJson(tableData, table, downloadFileName) {
88
96
  const { columns = [] } = table;
89
97
  const filterColumns = columns.filter(({ cellType }) => !actionCellTypes.includes(cellType));
90
98
  let formatDataVal = formatColumnValues(filterColumns, tableData);
99
+ formatDataVal = formatDataVal.map((entry) => {
100
+ const survivalStatus = entry.last_known_survival_status;
101
+ if (survivalStatus === '[]') {
102
+ return { ...entry, last_known_survival_status: '' };
103
+ }
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
+ };
110
+ }
111
+ return entry;
112
+ });
91
113
  filterColumns.forEach((column) => {
92
114
  formatDataVal = JSON.parse(
93
115
  JSON.stringify(formatDataVal).split(`"${column.dataField}":`).join(`"${column.header}":`),