@bento-core/table 1.0.1-ccdihub.47 → 1.0.1-ccdihub.49

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.
@@ -35,16 +35,12 @@ const DownloadButton = _ref => {
35
35
  style: downloadButtonStyle
36
36
  });
37
37
  }
38
- console.log('#######table:', table);
39
- console.log('&&&&&&&table:', table.tableInfo);
40
38
  const client = (0, _client.useApolloClient)();
41
- const downloadFile = 'CCDI Inventory ';
42
39
  async function downloadSCSVFile() {
43
40
  const {
44
41
  query,
45
42
  paginationAPIField
46
43
  } = table;
47
- const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
48
44
  const result = await client.query({
49
45
  query,
50
46
  variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
@@ -57,7 +53,7 @@ const DownloadButton = _ref => {
57
53
  }
58
54
  return response.data;
59
55
  });
60
- (0, _downloadTable.downloadJson)(result, table, downloadFileName);
56
+ (0, _downloadTable.downloadJson)(result, table, table.downloadFileName);
61
57
  }
62
58
  const downloadTableCSV = (0, _react.useCallback)(() => {
63
59
  downloadSCSVFile();
@@ -96,9 +96,10 @@ function downloadJson(tableData, table, downloadFileName) {
96
96
  return dataField;
97
97
  }).map(_ref5 => {
98
98
  let {
99
- header
99
+ header,
100
+ downloadHeader
100
101
  } = _ref5;
101
- return header;
102
+ return downloadHeader || header;
102
103
  });
103
104
  const csv = convertToCSV(jsonse, keysToInclude, headers);
104
105
  const exportData = new Blob([csv], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdihub.47",
3
+ "version": "1.0.1-ccdihub.49",
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",
@@ -23,21 +23,15 @@ const DownloadButton = ({
23
23
  if (count === 0) {
24
24
  return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
25
25
  }
26
- console.log('#######table:', table);
27
- console.log('&&&&&&&table:', table.tableInfo);
28
26
 
29
27
  const client = useApolloClient();
30
28
 
31
- const downloadFile = 'CCDI Inventory ';
32
-
33
29
  async function downloadSCSVFile() {
34
30
  const {
35
31
  query,
36
32
  paginationAPIField,
37
33
  } = table;
38
34
 
39
- const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
40
-
41
35
  const result = await client.query({
42
36
  query,
43
37
  variables: {
@@ -52,7 +46,7 @@ const DownloadButton = ({
52
46
  }
53
47
  return response.data;
54
48
  });
55
- downloadJson(result, table, downloadFileName);
49
+ downloadJson(result, table, table.downloadFileName);
56
50
  }
57
51
 
58
52
  const downloadTableCSV = useCallback(() => {
@@ -66,7 +66,8 @@ export function downloadJson(tableData, table, downloadFileName) {
66
66
  const jsonse = JSON.stringify(formatDataVal);
67
67
  const keysToInclude = columns.filter(({ dataField }) => dataField)
68
68
  .map(({ dataField }) => dataField);
69
- const headers = columns.filter(({ dataField }) => dataField).map(({ header }) => header);
69
+ const headers = columns.filter(({ dataField }) => dataField)
70
+ .map(({ header, downloadHeader }) => (downloadHeader || header));
70
71
  const csv = convertToCSV(jsonse, keysToInclude, headers);
71
72
  const exportData = new Blob([csv], { type: 'text/csv' });
72
73
  const JsonURL = window.URL.createObjectURL(exportData);