@bento-core/table 1.0.1-ccdihub.33 → 1.0.1-ccdihub.35
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.
- package/dist/ExtendedView.js +15 -5
- package/dist/pagination/CustomPagination.js +2 -18
- package/dist/toolbar/DownloadButtonView.js +52 -8
- package/package.json +1 -1
- package/src/ExtendedView.js +27 -14
- package/src/pagination/CustomPagination.js +13 -30
- package/src/toolbar/DownloadButtonView.js +53 -11
- package/dist/pagination/components/DownloadButton.js +0 -66
- package/src/pagination/components/DownloadButton.js +0 -68
package/dist/ExtendedView.js
CHANGED
|
@@ -16,6 +16,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
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; }
|
|
17
17
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
18
|
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); }
|
|
19
|
+
const downloadAreaStyle = {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
borderTop: '1px solid #8A7F7C',
|
|
22
|
+
marginRight: '41px'
|
|
23
|
+
};
|
|
19
24
|
const ExtendedView = _ref => {
|
|
20
25
|
let {
|
|
21
26
|
table,
|
|
@@ -44,13 +49,14 @@ const ExtendedView = _ref => {
|
|
|
44
49
|
theme: themeConfig
|
|
45
50
|
}, numSelected === 0 && (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(_core.Toolbar, {
|
|
46
51
|
className: "downloadColumnView"
|
|
47
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
48
|
-
download: download
|
|
49
|
-
}), /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
|
|
52
|
+
}, /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
|
|
50
53
|
table: table,
|
|
51
54
|
manageViewColumns: manageViewColumns,
|
|
52
55
|
onColumnViewChange: onColumnViewChange
|
|
53
|
-
})), pagination && /*#__PURE__*/_react.default.createElement(
|
|
56
|
+
})), pagination && /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
+
className: "downloadArea",
|
|
58
|
+
style: downloadAreaStyle
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
|
|
54
60
|
customTheme: customTheme.tblTopPgn,
|
|
55
61
|
rowsPerPageOptions: [10, 25, 50, 100],
|
|
56
62
|
component: "div",
|
|
@@ -61,7 +67,11 @@ const ExtendedView = _ref => {
|
|
|
61
67
|
onRowsPerPageChange: onRowsPerPageChange,
|
|
62
68
|
queryVariables: queryVariables,
|
|
63
69
|
table: table
|
|
64
|
-
})
|
|
70
|
+
}), /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
|
|
71
|
+
count: table.totalRowCount || 0,
|
|
72
|
+
queryVariables: queryVariables,
|
|
73
|
+
table: table
|
|
74
|
+
})));
|
|
65
75
|
};
|
|
66
76
|
var _default = ExtendedView;
|
|
67
77
|
exports.default = _default;
|
|
@@ -7,7 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _core = require("@material-ui/core");
|
|
10
|
-
var _DownloadButton = _interopRequireDefault(require("./components/DownloadButton"));
|
|
11
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
11
|
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
12
|
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; }
|
|
@@ -39,12 +38,6 @@ const defaultTheme = {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
|
-
const downloadAreaStyle = {
|
|
43
|
-
display: 'flex',
|
|
44
|
-
borderTop: '1px solid #8A7F7C',
|
|
45
|
-
borderBottom: '1px solid #8A7F7C',
|
|
46
|
-
paddingRight: '41px'
|
|
47
|
-
};
|
|
48
41
|
const CustomPagination = _ref => {
|
|
49
42
|
let {
|
|
50
43
|
rowsPerPageOptions,
|
|
@@ -53,17 +46,12 @@ const CustomPagination = _ref => {
|
|
|
53
46
|
page,
|
|
54
47
|
onPageChange,
|
|
55
48
|
onRowsPerPageChange,
|
|
56
|
-
customTheme = {}
|
|
57
|
-
queryVariables,
|
|
58
|
-
table
|
|
49
|
+
customTheme = {}
|
|
59
50
|
} = _ref;
|
|
60
51
|
return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
|
|
61
52
|
theme: (0, _core.createTheme)({
|
|
62
53
|
overrides: _objectSpread(_objectSpread({}, defaultTheme), customTheme)
|
|
63
54
|
})
|
|
64
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
-
className: "downloadArea",
|
|
66
|
-
style: downloadAreaStyle
|
|
67
55
|
}, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
|
|
68
56
|
rowsPerPageOptions: rowsPerPageOptions,
|
|
69
57
|
component: "div",
|
|
@@ -78,11 +66,7 @@ const CustomPagination = _ref => {
|
|
|
78
66
|
},
|
|
79
67
|
native: true
|
|
80
68
|
}
|
|
81
|
-
})
|
|
82
|
-
count: count,
|
|
83
|
-
queryVariables: queryVariables,
|
|
84
|
-
table: table
|
|
85
|
-
})));
|
|
69
|
+
}));
|
|
86
70
|
};
|
|
87
71
|
CustomPagination.propTypes = {
|
|
88
72
|
rowsPerPageOptions: _propTypes.default.arrayOf(_propTypes.default.number).isRequired,
|
|
@@ -4,20 +4,64 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _client = require("@apollo/client");
|
|
8
9
|
var _core = require("@material-ui/core");
|
|
9
10
|
var _icons = require("@material-ui/icons");
|
|
10
|
-
|
|
11
|
+
var _downloadTable = require("../util/downloadTable");
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
+
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); }
|
|
19
|
+
const downloadButtonStyle = {
|
|
20
|
+
color: '#d1d2d3',
|
|
21
|
+
marginTop: '7px'
|
|
22
|
+
};
|
|
11
23
|
const DownloadButton = _ref => {
|
|
12
24
|
let {
|
|
13
|
-
|
|
25
|
+
count,
|
|
26
|
+
queryVariables,
|
|
27
|
+
table
|
|
14
28
|
} = _ref;
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
29
|
+
if (count === 0) {
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, {
|
|
31
|
+
className: "disableButton",
|
|
32
|
+
style: downloadButtonStyle
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const client = (0, _client.useApolloClient)();
|
|
36
|
+
const downloadFile = 'CCDI Inventory ';
|
|
37
|
+
async function downloadSCSVFile() {
|
|
38
|
+
const {
|
|
39
|
+
query,
|
|
40
|
+
paginationAPIField
|
|
41
|
+
} = table;
|
|
42
|
+
const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
|
|
43
|
+
const result = await client.query({
|
|
44
|
+
query,
|
|
45
|
+
variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
|
|
46
|
+
page: 0,
|
|
47
|
+
first: 25000
|
|
48
|
+
})
|
|
49
|
+
}).then(response => {
|
|
50
|
+
if (paginationAPIField && response && response.data) {
|
|
51
|
+
return response.data[paginationAPIField];
|
|
52
|
+
}
|
|
53
|
+
return response.data;
|
|
54
|
+
});
|
|
55
|
+
(0, _downloadTable.downloadJson)(result, table, downloadFileName);
|
|
17
56
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
57
|
+
const downloadTableCSV = (0, _react.useCallback)(() => {
|
|
58
|
+
downloadSCSVFile();
|
|
59
|
+
}, [queryVariables]);
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
61
|
+
title: "Download filtered results as a CSV"
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
63
|
+
onClick: downloadTableCSV
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null)));
|
|
21
65
|
};
|
|
22
66
|
var _default = DownloadButton;
|
|
23
67
|
exports.default = _default;
|
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.35",
|
|
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",
|
package/src/ExtendedView.js
CHANGED
|
@@ -9,6 +9,12 @@ import ManageColumnView from './toolbar/ManageColumnView';
|
|
|
9
9
|
import defaultTheme from './DefaultThemConfig';
|
|
10
10
|
import DownloadButton from './toolbar/DownloadButtonView';
|
|
11
11
|
|
|
12
|
+
const downloadAreaStyle = {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
borderTop: '1px solid #8A7F7C',
|
|
15
|
+
marginRight: '41px',
|
|
16
|
+
};
|
|
17
|
+
|
|
12
18
|
const ExtendedView = ({
|
|
13
19
|
table,
|
|
14
20
|
onColumnViewChange,
|
|
@@ -33,9 +39,9 @@ const ExtendedView = ({
|
|
|
33
39
|
<ThemeProvider theme={themeConfig}>
|
|
34
40
|
{(numSelected === 0 && (download || manageViewColumns)) && (
|
|
35
41
|
<Toolbar className="downloadColumnView">
|
|
36
|
-
<DownloadButton
|
|
42
|
+
{/* <DownloadButton
|
|
37
43
|
download={download}
|
|
38
|
-
/>
|
|
44
|
+
/> */}
|
|
39
45
|
<ManageColumnView
|
|
40
46
|
table={table}
|
|
41
47
|
manageViewColumns={manageViewColumns}
|
|
@@ -45,18 +51,25 @@ const ExtendedView = ({
|
|
|
45
51
|
)}
|
|
46
52
|
{
|
|
47
53
|
(pagination) && (
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
<div className="downloadArea" style={downloadAreaStyle}>
|
|
55
|
+
<CustomPagination
|
|
56
|
+
customTheme={customTheme.tblTopPgn}
|
|
57
|
+
rowsPerPageOptions={[10, 25, 50, 100]}
|
|
58
|
+
component="div"
|
|
59
|
+
count={table.totalRowCount || 0}
|
|
60
|
+
rowsPerPage={table.rowsPerPage || 10}
|
|
61
|
+
page={table.page || 0}
|
|
62
|
+
onPageChange={onPageChange}
|
|
63
|
+
onRowsPerPageChange={onRowsPerPageChange}
|
|
64
|
+
queryVariables={queryVariables}
|
|
65
|
+
table={table}
|
|
66
|
+
/>
|
|
67
|
+
<DownloadButton
|
|
68
|
+
count={table.totalRowCount || 0}
|
|
69
|
+
queryVariables={queryVariables}
|
|
70
|
+
table={table}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
60
73
|
)
|
|
61
74
|
}
|
|
62
75
|
</ThemeProvider>
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
TablePagination,
|
|
6
6
|
ThemeProvider,
|
|
7
7
|
} from '@material-ui/core';
|
|
8
|
-
import DownloadButton from './components/DownloadButton';
|
|
9
8
|
|
|
10
9
|
const defaultTheme = {
|
|
11
10
|
MuiTablePagination: {
|
|
@@ -33,13 +32,6 @@ const defaultTheme = {
|
|
|
33
32
|
},
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
const downloadAreaStyle = {
|
|
37
|
-
display: 'flex',
|
|
38
|
-
borderTop: '1px solid #8A7F7C',
|
|
39
|
-
borderBottom: '1px solid #8A7F7C',
|
|
40
|
-
paddingRight: '41px',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
35
|
const CustomPagination = ({
|
|
44
36
|
rowsPerPageOptions,
|
|
45
37
|
count,
|
|
@@ -48,30 +40,21 @@ const CustomPagination = ({
|
|
|
48
40
|
onPageChange,
|
|
49
41
|
onRowsPerPageChange,
|
|
50
42
|
customTheme = {},
|
|
51
|
-
queryVariables,
|
|
52
|
-
table,
|
|
53
43
|
}) => (
|
|
54
44
|
<ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/>
|
|
69
|
-
<DownloadButton
|
|
70
|
-
count={count}
|
|
71
|
-
queryVariables={queryVariables}
|
|
72
|
-
table={table}
|
|
73
|
-
/>
|
|
74
|
-
</div>
|
|
45
|
+
<TablePagination
|
|
46
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
47
|
+
component="div"
|
|
48
|
+
count={count}
|
|
49
|
+
rowsPerPage={rowsPerPage}
|
|
50
|
+
page={page}
|
|
51
|
+
onPageChange={onPageChange}
|
|
52
|
+
onRowsPerPageChange={onRowsPerPageChange}
|
|
53
|
+
SelectProps={{
|
|
54
|
+
inputProps: { 'aria-label': 'Selection dropdown for displaying the number of results per page' },
|
|
55
|
+
native: true,
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
75
58
|
</ThemeProvider>
|
|
76
59
|
);
|
|
77
60
|
|
|
@@ -1,25 +1,67 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useApolloClient } from '@apollo/client';
|
|
2
3
|
import {
|
|
3
4
|
IconButton,
|
|
4
5
|
Tooltip,
|
|
5
6
|
} from '@material-ui/core';
|
|
6
7
|
import { CloudDownload } from '@material-ui/icons';
|
|
8
|
+
import { downloadJson } from '../util/downloadTable';
|
|
9
|
+
|
|
10
|
+
const downloadButtonStyle = {
|
|
11
|
+
color: '#d1d2d3',
|
|
12
|
+
marginTop: '7px',
|
|
13
|
+
};
|
|
7
14
|
|
|
8
15
|
const DownloadButton = ({
|
|
9
|
-
|
|
16
|
+
count,
|
|
17
|
+
queryVariables,
|
|
18
|
+
table,
|
|
10
19
|
}) => {
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
20
|
+
if (count === 0) {
|
|
21
|
+
return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
|
|
13
22
|
}
|
|
14
23
|
|
|
24
|
+
const client = useApolloClient();
|
|
25
|
+
|
|
26
|
+
const downloadFile = 'CCDI Inventory ';
|
|
27
|
+
|
|
28
|
+
async function downloadSCSVFile() {
|
|
29
|
+
const {
|
|
30
|
+
query,
|
|
31
|
+
paginationAPIField,
|
|
32
|
+
} = table;
|
|
33
|
+
|
|
34
|
+
const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
|
|
35
|
+
|
|
36
|
+
const result = await client.query({
|
|
37
|
+
query,
|
|
38
|
+
variables: {
|
|
39
|
+
...queryVariables,
|
|
40
|
+
page: 0,
|
|
41
|
+
first: 25000,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
.then((response) => {
|
|
45
|
+
if (paginationAPIField && response && response.data) {
|
|
46
|
+
return response.data[paginationAPIField];
|
|
47
|
+
}
|
|
48
|
+
return response.data;
|
|
49
|
+
});
|
|
50
|
+
downloadJson(result, table, downloadFileName);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const downloadTableCSV = useCallback(() => {
|
|
54
|
+
downloadSCSVFile();
|
|
55
|
+
}, [queryVariables]);
|
|
56
|
+
|
|
15
57
|
return (
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</
|
|
22
|
-
|
|
58
|
+
<Tooltip title="Download filtered results as a CSV">
|
|
59
|
+
<IconButton
|
|
60
|
+
onClick={downloadTableCSV}
|
|
61
|
+
>
|
|
62
|
+
<CloudDownload />
|
|
63
|
+
</IconButton>
|
|
64
|
+
</Tooltip>
|
|
23
65
|
);
|
|
24
66
|
};
|
|
25
67
|
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _client = require("@apollo/client");
|
|
9
|
-
var _core = require("@material-ui/core");
|
|
10
|
-
var _icons = require("@material-ui/icons");
|
|
11
|
-
var _downloadTable = require("../../util/downloadTable");
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
-
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; }
|
|
15
|
-
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; }
|
|
16
|
-
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; }
|
|
17
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
-
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); }
|
|
19
|
-
const downloadButtonStyle = {
|
|
20
|
-
color: '#d1d2d3',
|
|
21
|
-
marginTop: '7px'
|
|
22
|
-
};
|
|
23
|
-
const DownloadButton = _ref => {
|
|
24
|
-
let {
|
|
25
|
-
count,
|
|
26
|
-
queryVariables,
|
|
27
|
-
table
|
|
28
|
-
} = _ref;
|
|
29
|
-
if (count === 0) {
|
|
30
|
-
return /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, {
|
|
31
|
-
style: downloadButtonStyle
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const client = (0, _client.useApolloClient)();
|
|
35
|
-
const downloadFile = 'CCDI Inventory ';
|
|
36
|
-
async function downloadSCSVFile() {
|
|
37
|
-
const {
|
|
38
|
-
query,
|
|
39
|
-
paginationAPIField
|
|
40
|
-
} = table;
|
|
41
|
-
const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
|
|
42
|
-
const result = await client.query({
|
|
43
|
-
query,
|
|
44
|
-
variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
|
|
45
|
-
page: 0,
|
|
46
|
-
first: 25000
|
|
47
|
-
})
|
|
48
|
-
}).then(response => {
|
|
49
|
-
if (paginationAPIField && response && response.data) {
|
|
50
|
-
return response.data[paginationAPIField];
|
|
51
|
-
}
|
|
52
|
-
return response.data;
|
|
53
|
-
});
|
|
54
|
-
(0, _downloadTable.downloadJson)(result, table, downloadFileName);
|
|
55
|
-
}
|
|
56
|
-
const downloadTableCSV = (0, _react.useCallback)(() => {
|
|
57
|
-
downloadSCSVFile();
|
|
58
|
-
}, [queryVariables]);
|
|
59
|
-
return /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
60
|
-
title: "Download filtered results as a CSV"
|
|
61
|
-
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
62
|
-
onClick: downloadTableCSV
|
|
63
|
-
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null)));
|
|
64
|
-
};
|
|
65
|
-
var _default = DownloadButton;
|
|
66
|
-
exports.default = _default;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { useApolloClient } from '@apollo/client';
|
|
3
|
-
import {
|
|
4
|
-
IconButton,
|
|
5
|
-
Tooltip,
|
|
6
|
-
} from '@material-ui/core';
|
|
7
|
-
import { CloudDownload } from '@material-ui/icons';
|
|
8
|
-
import { downloadJson } from '../../util/downloadTable';
|
|
9
|
-
|
|
10
|
-
const downloadButtonStyle = {
|
|
11
|
-
color: '#d1d2d3',
|
|
12
|
-
marginTop: '7px',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const DownloadButton = ({
|
|
16
|
-
count,
|
|
17
|
-
queryVariables,
|
|
18
|
-
table,
|
|
19
|
-
}) => {
|
|
20
|
-
if (count === 0) {
|
|
21
|
-
return <CloudDownload style={downloadButtonStyle} />;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const client = useApolloClient();
|
|
25
|
-
|
|
26
|
-
const downloadFile = 'CCDI Inventory ';
|
|
27
|
-
|
|
28
|
-
async function downloadSCSVFile() {
|
|
29
|
-
const {
|
|
30
|
-
query,
|
|
31
|
-
paginationAPIField,
|
|
32
|
-
} = table;
|
|
33
|
-
|
|
34
|
-
const downloadFileName = downloadFile.concat(paginationAPIField.replace('Overview', ''), ' download');
|
|
35
|
-
|
|
36
|
-
const result = await client.query({
|
|
37
|
-
query,
|
|
38
|
-
variables: {
|
|
39
|
-
...queryVariables,
|
|
40
|
-
page: 0,
|
|
41
|
-
first: 25000,
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
.then((response) => {
|
|
45
|
-
if (paginationAPIField && response && response.data) {
|
|
46
|
-
return response.data[paginationAPIField];
|
|
47
|
-
}
|
|
48
|
-
return response.data;
|
|
49
|
-
});
|
|
50
|
-
downloadJson(result, table, downloadFileName);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const downloadTableCSV = useCallback(() => {
|
|
54
|
-
downloadSCSVFile();
|
|
55
|
-
}, [queryVariables]);
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<Tooltip title="Download filtered results as a CSV">
|
|
59
|
-
<IconButton
|
|
60
|
-
onClick={downloadTableCSV}
|
|
61
|
-
>
|
|
62
|
-
<CloudDownload />
|
|
63
|
-
</IconButton>
|
|
64
|
-
</Tooltip>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default DownloadButton;
|