@bento-core/table 1.0.1-ccdihub.48 → 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,17 +35,12 @@ const DownloadButton = _ref => {
|
|
|
35
35
|
style: downloadButtonStyle
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
console.log('#######table:', table);
|
|
39
|
-
console.log('&&&&&&&table:', table.column);
|
|
40
|
-
console.log('*******downloadFileName:', table.downloadFileName);
|
|
41
38
|
const client = (0, _client.useApolloClient)();
|
|
42
|
-
const downloadFile = 'CCDI Inventory ';
|
|
43
39
|
async function downloadSCSVFile() {
|
|
44
40
|
const {
|
|
45
41
|
query,
|
|
46
42
|
paginationAPIField
|
|
47
43
|
} = table;
|
|
48
|
-
const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
|
|
49
44
|
const result = await client.query({
|
|
50
45
|
query,
|
|
51
46
|
variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
|
|
@@ -58,7 +53,7 @@ const DownloadButton = _ref => {
|
|
|
58
53
|
}
|
|
59
54
|
return response.data;
|
|
60
55
|
});
|
|
61
|
-
(0, _downloadTable.downloadJson)(result, table, downloadFileName);
|
|
56
|
+
(0, _downloadTable.downloadJson)(result, table, table.downloadFileName);
|
|
62
57
|
}
|
|
63
58
|
const downloadTableCSV = (0, _react.useCallback)(() => {
|
|
64
59
|
downloadSCSVFile();
|
|
@@ -89,23 +89,17 @@ function downloadJson(tableData, table, downloadFileName) {
|
|
|
89
89
|
} = _ref3;
|
|
90
90
|
return dataField;
|
|
91
91
|
});
|
|
92
|
-
const
|
|
92
|
+
const headers = columns.filter(_ref4 => {
|
|
93
93
|
let {
|
|
94
94
|
dataField
|
|
95
95
|
} = _ref4;
|
|
96
96
|
return dataField;
|
|
97
|
-
})
|
|
98
|
-
console.log('????? columnsFilter:', columnsFilter);
|
|
99
|
-
const headers = columns.filter(_ref5 => {
|
|
97
|
+
}).map(_ref5 => {
|
|
100
98
|
let {
|
|
101
|
-
|
|
99
|
+
header,
|
|
100
|
+
downloadHeader
|
|
102
101
|
} = _ref5;
|
|
103
|
-
return
|
|
104
|
-
}).map(_ref6 => {
|
|
105
|
-
let {
|
|
106
|
-
header
|
|
107
|
-
} = _ref6;
|
|
108
|
-
return header;
|
|
102
|
+
return downloadHeader || header;
|
|
109
103
|
});
|
|
110
104
|
const csv = convertToCSV(jsonse, keysToInclude, headers);
|
|
111
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.
|
|
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,22 +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.column);
|
|
28
|
-
console.log('*******downloadFileName:', table.downloadFileName);
|
|
29
26
|
|
|
30
27
|
const client = useApolloClient();
|
|
31
28
|
|
|
32
|
-
const downloadFile = 'CCDI Inventory ';
|
|
33
|
-
|
|
34
29
|
async function downloadSCSVFile() {
|
|
35
30
|
const {
|
|
36
31
|
query,
|
|
37
32
|
paginationAPIField,
|
|
38
33
|
} = table;
|
|
39
34
|
|
|
40
|
-
const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
|
|
41
|
-
|
|
42
35
|
const result = await client.query({
|
|
43
36
|
query,
|
|
44
37
|
variables: {
|
|
@@ -53,7 +46,7 @@ const DownloadButton = ({
|
|
|
53
46
|
}
|
|
54
47
|
return response.data;
|
|
55
48
|
});
|
|
56
|
-
downloadJson(result, table, downloadFileName);
|
|
49
|
+
downloadJson(result, table, table.downloadFileName);
|
|
57
50
|
}
|
|
58
51
|
|
|
59
52
|
const downloadTableCSV = useCallback(() => {
|
|
@@ -66,9 +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
|
|
70
|
-
|
|
71
|
-
const headers = columns.filter(({ dataField }) => dataField).map(({ header }) => header);
|
|
69
|
+
const headers = columns.filter(({ dataField }) => dataField)
|
|
70
|
+
.map(({ header, downloadHeader }) => (downloadHeader || header));
|
|
72
71
|
const csv = convertToCSV(jsonse, keysToInclude, headers);
|
|
73
72
|
const exportData = new Blob([csv], { type: 'text/csv' });
|
|
74
73
|
const JsonURL = window.URL.createObjectURL(exportData);
|