@bento-core/table 1.0.1-ins.2 → 1.0.1-ins.4

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.
@@ -16,16 +16,20 @@ 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
+ paddingRight: '41px'
23
+ };
19
24
  const ExtendedView = _ref => {
20
25
  let {
21
26
  table,
22
- rows,
23
27
  onColumnViewChange,
24
28
  onRowsPerPageChange,
25
29
  onPageChange,
30
+ numSelected = 0,
26
31
  customTheme,
27
- queryVariables,
28
- server
32
+ queryVariables
29
33
  } = _ref;
30
34
  const {
31
35
  extendedViewConfig
@@ -43,19 +47,16 @@ const ExtendedView = _ref => {
43
47
  });
44
48
  return /*#__PURE__*/_react.default.createElement(_core.ThemeProvider, {
45
49
  theme: themeConfig
46
- }, (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(_core.Toolbar, {
47
- className: "downloadAndColumnView"
48
- }, /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
49
- download: download,
50
- rows: rows,
51
- server: server,
52
- table: table,
53
- queryVariables: queryVariables
54
- }), /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
50
+ }, numSelected === 0 && (download || manageViewColumns) && /*#__PURE__*/_react.default.createElement(_core.Toolbar, {
51
+ className: "downloadColumnView"
52
+ }, /*#__PURE__*/_react.default.createElement(_ManageColumnView.default, {
55
53
  table: table,
56
54
  manageViewColumns: manageViewColumns,
57
55
  onColumnViewChange: onColumnViewChange
58
- })), pagination && /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
56
+ })), pagination && /*#__PURE__*/_react.default.createElement("div", {
57
+ className: "downloadArea",
58
+ style: downloadAreaStyle
59
+ }, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
59
60
  customTheme: customTheme.tblTopPgn,
60
61
  rowsPerPageOptions: [10, 25, 50, 100],
61
62
  component: "div",
@@ -63,8 +64,14 @@ const ExtendedView = _ref => {
63
64
  rowsPerPage: table.rowsPerPage || 10,
64
65
  page: table.page || 0,
65
66
  onPageChange: onPageChange,
66
- onRowsPerPageChange: onRowsPerPageChange
67
- }));
67
+ onRowsPerPageChange: onRowsPerPageChange,
68
+ queryVariables: queryVariables,
69
+ table: table
70
+ }), /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
71
+ count: table.totalRowCount || 0,
72
+ queryVariables: queryVariables,
73
+ table: table
74
+ })));
68
75
  };
69
76
  var _default = ExtendedView;
70
77
  exports.default = _default;
package/dist/TableView.js CHANGED
@@ -12,6 +12,7 @@ var _CustomTblBody = _interopRequireDefault(require("./body/CustomTblBody"));
12
12
  var _CustomToolbar = _interopRequireDefault(require("./toolbar/CustomToolbar"));
13
13
  var _DisplayErrMsg = _interopRequireDefault(require("./errMsg/DisplayErrMsg"));
14
14
  var _ExtendedView = _interopRequireDefault(require("./ExtendedView"));
15
+ var _DownloadButtonView = _interopRequireDefault(require("./toolbar/DownloadButtonView"));
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17
  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; }
17
18
  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; }
@@ -32,11 +33,15 @@ const CustomTableContainer = props => {
32
33
  component: _core.Paper
33
34
  }, children));
34
35
  };
36
+ const downloadAreaStyle = {
37
+ display: 'flex',
38
+ borderBottom: '1px solid #8A7F7C',
39
+ paddingRight: '41px'
40
+ };
35
41
  const TableView = _ref => {
36
42
  var _table$selectedRows, _table$selectedRows2;
37
43
  let {
38
44
  tableRows = [],
39
- totalRows = [],
40
45
  table,
41
46
  onRowsPerPageChange,
42
47
  onPageChange,
@@ -46,13 +51,10 @@ const TableView = _ref => {
46
51
  onSortByColumn,
47
52
  onColumnViewChange,
48
53
  themeConfig = {},
49
- queryVariables,
50
- server
54
+ queryVariables
51
55
  } = _ref;
52
56
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ExtendedView.default, {
53
57
  table: table,
54
- rows: totalRows,
55
- server: server,
56
58
  onColumnViewChange: onColumnViewChange,
57
59
  onRowsPerPageChange: onRowsPerPageChange,
58
60
  onPageChange: onPageChange,
@@ -81,7 +83,10 @@ const TableView = _ref => {
81
83
  }))), tableRows.length === 0 && /*#__PURE__*/_react.default.createElement(_DisplayErrMsg.default, {
82
84
  customTheme: themeConfig.displayErr,
83
85
  table: table
84
- }), /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
86
+ }), /*#__PURE__*/_react.default.createElement("div", {
87
+ className: "downloadArea",
88
+ style: downloadAreaStyle
89
+ }, /*#__PURE__*/_react.default.createElement(_CustomPagination.default, {
85
90
  customTheme: themeConfig.tblPgn,
86
91
  rowsPerPageOptions: [10, 25, 50, 100],
87
92
  component: "div",
@@ -90,7 +95,11 @@ const TableView = _ref => {
90
95
  page: table.page || 0,
91
96
  onPageChange: onPageChange,
92
97
  onRowsPerPageChange: onRowsPerPageChange
93
- }));
98
+ }), /*#__PURE__*/_react.default.createElement(_DownloadButtonView.default, {
99
+ count: table.totalRowCount || 0,
100
+ queryVariables: queryVariables,
101
+ table: table
102
+ })));
94
103
  };
95
104
  var _default = TableView;
96
105
  exports.default = _default;
@@ -7,12 +7,71 @@ 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 _styles = require("@material-ui/core/styles");
11
+ var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
12
+ var _FirstPage = _interopRequireDefault(require("@material-ui/icons/FirstPage"));
13
+ var _KeyboardArrowLeft = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowLeft"));
14
+ var _KeyboardArrowRight = _interopRequireDefault(require("@material-ui/icons/KeyboardArrowRight"));
15
+ var _LastPage = _interopRequireDefault(require("@material-ui/icons/LastPage"));
10
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
17
  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; }
12
18
  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; }
13
19
  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; }
14
20
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
21
  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); }
22
+ const useStyles1 = (0, _styles.makeStyles)(theme => ({
23
+ root: {
24
+ flexShrink: 0,
25
+ marginLeft: theme.spacing(2.5)
26
+ }
27
+ }));
28
+ function TablePaginationActions(props) {
29
+ const classes = useStyles1();
30
+ const theme = (0, _styles.useTheme)();
31
+ const {
32
+ count,
33
+ page,
34
+ rowsPerPage,
35
+ onPageChange
36
+ } = props;
37
+ const handleFirstPageButtonClick = event => {
38
+ onPageChange(event, 0);
39
+ };
40
+ const handleBackButtonClick = event => {
41
+ onPageChange(event, page - 1);
42
+ };
43
+ const handleNextButtonClick = event => {
44
+ onPageChange(event, page + 1);
45
+ };
46
+ const handleLastPageButtonClick = event => {
47
+ onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
48
+ };
49
+ return /*#__PURE__*/_react.default.createElement("div", {
50
+ className: classes.root
51
+ }, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
52
+ onClick: handleFirstPageButtonClick,
53
+ disabled: page === 0,
54
+ "aria-label": "first page"
55
+ }, theme.direction === 'rtl' ? /*#__PURE__*/_react.default.createElement(_LastPage.default, null) : /*#__PURE__*/_react.default.createElement(_FirstPage.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
56
+ onClick: handleBackButtonClick,
57
+ disabled: page === 0,
58
+ "aria-label": "previous page"
59
+ }, theme.direction === 'rtl' ? /*#__PURE__*/_react.default.createElement(_KeyboardArrowRight.default, null) : /*#__PURE__*/_react.default.createElement(_KeyboardArrowLeft.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
60
+ onClick: handleNextButtonClick,
61
+ disabled: page >= Math.ceil(count / rowsPerPage) - 1,
62
+ "aria-label": "next page"
63
+ }, theme.direction === 'rtl' ? /*#__PURE__*/_react.default.createElement(_KeyboardArrowLeft.default, null) : /*#__PURE__*/_react.default.createElement(_KeyboardArrowRight.default, null)), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
64
+ onClick: handleLastPageButtonClick,
65
+ disabled: page >= Math.ceil(count / rowsPerPage) - 1,
66
+ "aria-label": "last page"
67
+ }, theme.direction === 'rtl' ? /*#__PURE__*/_react.default.createElement(_FirstPage.default, null) : /*#__PURE__*/_react.default.createElement(_LastPage.default, null)));
68
+ }
69
+ TablePaginationActions.propTypes = {
70
+ count: _propTypes.default.number.isRequired,
71
+ onPageChange: _propTypes.default.func.isRequired,
72
+ page: _propTypes.default.number.isRequired,
73
+ rowsPerPage: _propTypes.default.number.isRequired
74
+ };
16
75
  const defaultTheme = {
17
76
  MuiTablePagination: {
18
77
  root: {
@@ -38,6 +97,12 @@ const defaultTheme = {
38
97
  }
39
98
  }
40
99
  };
100
+ const downloadAreaStyle = {
101
+ display: 'flex',
102
+ borderTop: '1px solid #8A7F7C',
103
+ borderBottom: '1px solid #8A7F7C',
104
+ paddingRight: '41px'
105
+ };
41
106
  const CustomPagination = _ref => {
42
107
  let {
43
108
  rowsPerPageOptions,
@@ -52,6 +117,9 @@ const CustomPagination = _ref => {
52
117
  theme: (0, _core.createTheme)({
53
118
  overrides: _objectSpread(_objectSpread({}, defaultTheme), customTheme)
54
119
  })
120
+ }, /*#__PURE__*/_react.default.createElement("div", {
121
+ className: "downloadArea",
122
+ style: downloadAreaStyle
55
123
  }, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
56
124
  rowsPerPageOptions: rowsPerPageOptions,
57
125
  component: "div",
@@ -59,8 +127,9 @@ const CustomPagination = _ref => {
59
127
  rowsPerPage: rowsPerPage,
60
128
  page: page,
61
129
  onPageChange: onPageChange,
62
- onRowsPerPageChange: onRowsPerPageChange
63
- }));
130
+ onRowsPerPageChange: onRowsPerPageChange,
131
+ ActionsComponent: TablePaginationActions
132
+ })));
64
133
  };
65
134
  CustomPagination.propTypes = {
66
135
  rowsPerPageOptions: _propTypes.default.arrayOf(_propTypes.default.number).isRequired,
@@ -16,28 +16,30 @@ 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 downloadButtonStyle = {
20
+ color: '#d1d2d3',
21
+ marginTop: '7px'
22
+ };
19
23
  const DownloadButton = _ref => {
20
24
  let {
21
- download,
22
- rows,
23
- table,
25
+ count,
24
26
  queryVariables,
25
- server
27
+ table
26
28
  } = _ref;
27
- if (!download) {
28
- return null;
29
+ if (count === 0) {
30
+ return /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, {
31
+ className: "disableButton",
32
+ style: downloadButtonStyle
33
+ });
29
34
  }
30
- const {
31
- downloadCsv = 'download',
32
- downloadTable,
33
- downloadFileName
34
- } = download;
35
35
  const client = (0, _client.useApolloClient)();
36
+ const downloadFile = 'INS ';
36
37
  async function downloadSCSVFile() {
37
38
  const {
38
39
  query,
39
40
  paginationAPIField
40
41
  } = table;
42
+ const downloadFileName = downloadFile.concat(paginationAPIField.replace('OverView', ''), ' download');
41
43
  const result = await client.query({
42
44
  query,
43
45
  variables: _objectSpread(_objectSpread({}, queryVariables), {}, {
@@ -53,20 +55,13 @@ const DownloadButton = _ref => {
53
55
  (0, _downloadTable.downloadJson)(result, table, downloadFileName);
54
56
  }
55
57
  const downloadTableCSV = (0, _react.useCallback)(() => {
56
- if (downloadTable) {
57
- downloadTable();
58
- } else if (!downloadTable && !server) {
59
- (0, _downloadTable.downloadJson)(rows, table, downloadFileName);
60
- } else {
61
- downloadSCSVFile();
62
- }
58
+ downloadSCSVFile();
63
59
  }, [queryVariables]);
64
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
65
- title: downloadCsv,
66
- className: "download-icon"
60
+ return /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
61
+ title: "Download Full Table As CSV"
67
62
  }, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
68
63
  onClick: downloadTableCSV
69
- }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null))));
64
+ }, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null)));
70
65
  };
71
66
  var _default = DownloadButton;
72
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-ins.2",
3
+ "version": "1.0.1-ins.4",
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",
@@ -9,21 +9,25 @@ 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
+ paddingRight: '41px',
16
+ };
17
+
12
18
  const ExtendedView = ({
13
19
  table,
14
- rows,
15
20
  onColumnViewChange,
16
21
  onRowsPerPageChange,
17
22
  onPageChange,
23
+ numSelected = 0,
18
24
  customTheme,
19
25
  queryVariables,
20
- server,
21
26
  }) => {
22
27
  const { extendedViewConfig } = table;
23
28
  if (!extendedViewConfig) {
24
29
  return null;
25
30
  }
26
-
27
31
  const {
28
32
  download = false,
29
33
  manageViewColumns = false,
@@ -31,41 +35,43 @@ const ExtendedView = ({
31
35
  } = extendedViewConfig;
32
36
 
33
37
  const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
34
-
35
38
  return (
36
39
  <ThemeProvider theme={themeConfig}>
37
- {(download || manageViewColumns) && (
38
- <Toolbar
39
- className="downloadAndColumnView"
40
- >
41
- <DownloadButton
42
- download={download}
43
- rows={rows}
44
- server={server}
45
- table={table}
46
- queryVariables={queryVariables}
47
- />
48
- <ManageColumnView
49
- table={table}
50
- manageViewColumns={manageViewColumns}
51
- onColumnViewChange={onColumnViewChange}
52
- />
53
- </Toolbar>
40
+ {(numSelected === 0 && (download || manageViewColumns)) && (
41
+ <Toolbar className="downloadColumnView">
42
+ {/* <DownloadButton
43
+ download={download}
44
+ /> */}
45
+ <ManageColumnView
46
+ table={table}
47
+ manageViewColumns={manageViewColumns}
48
+ onColumnViewChange={onColumnViewChange}
49
+ />
50
+ </Toolbar>
54
51
  )}
55
52
  {
56
- (pagination) && (
57
- <CustomPagination
58
- customTheme={customTheme.tblTopPgn}
59
- rowsPerPageOptions={[10, 25, 50, 100]}
60
- component="div"
61
- count={table.totalRowCount || 0}
62
- rowsPerPage={table.rowsPerPage || 10}
63
- page={table.page || 0}
64
- onPageChange={onPageChange}
65
- onRowsPerPageChange={onRowsPerPageChange}
66
- />
67
- )
68
- }
53
+ (pagination) && (
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>
73
+ )
74
+ }
69
75
  </ThemeProvider>
70
76
  );
71
77
  };
package/src/TableView.js CHANGED
@@ -12,6 +12,7 @@ import CustomTableBody from './body/CustomTblBody';
12
12
  import CustomToolbar from './toolbar/CustomToolbar';
13
13
  import DisplayErrMsg from './errMsg/DisplayErrMsg';
14
14
  import ExtendedView from './ExtendedView';
15
+ import DownloadButton from './toolbar/DownloadButtonView';
15
16
 
16
17
  const CustomTableContainer = (props) => {
17
18
  const { children, customTheme } = props;
@@ -25,9 +26,14 @@ const CustomTableContainer = (props) => {
25
26
  );
26
27
  };
27
28
 
29
+ const downloadAreaStyle = {
30
+ display: 'flex',
31
+ borderBottom: '1px solid #8A7F7C',
32
+ paddingRight: '41px',
33
+ };
34
+
28
35
  const TableView = ({
29
36
  tableRows = [],
30
- totalRows = [],
31
37
  table,
32
38
  onRowsPerPageChange,
33
39
  onPageChange,
@@ -38,13 +44,10 @@ const TableView = ({
38
44
  onColumnViewChange,
39
45
  themeConfig = {},
40
46
  queryVariables,
41
- server,
42
47
  }) => (
43
48
  <>
44
49
  <ExtendedView
45
50
  table={table}
46
- rows={totalRows}
47
- server={server}
48
51
  onColumnViewChange={onColumnViewChange}
49
52
  onRowsPerPageChange={onRowsPerPageChange}
50
53
  onPageChange={onPageChange}
@@ -84,16 +87,23 @@ const TableView = ({
84
87
  table={table}
85
88
  />
86
89
  )}
87
- <CustomPagination
88
- customTheme={themeConfig.tblPgn}
89
- rowsPerPageOptions={[10, 25, 50, 100]}
90
- component="div"
91
- count={table.totalRowCount || 0}
92
- rowsPerPage={table.rowsPerPage || 10}
93
- page={table.page || 0}
94
- onPageChange={onPageChange}
95
- onRowsPerPageChange={onRowsPerPageChange}
96
- />
90
+ <div className="downloadArea" style={downloadAreaStyle}>
91
+ <CustomPagination
92
+ customTheme={themeConfig.tblPgn}
93
+ rowsPerPageOptions={[10, 25, 50, 100]}
94
+ component="div"
95
+ count={table.totalRowCount || 0}
96
+ rowsPerPage={table.rowsPerPage || 10}
97
+ page={table.page || 0}
98
+ onPageChange={onPageChange}
99
+ onRowsPerPageChange={onRowsPerPageChange}
100
+ />
101
+ <DownloadButton
102
+ count={table.totalRowCount || 0}
103
+ queryVariables={queryVariables}
104
+ table={table}
105
+ />
106
+ </div>
97
107
  </>
98
108
  );
99
109
 
@@ -5,6 +5,79 @@ import {
5
5
  TablePagination,
6
6
  ThemeProvider,
7
7
  } from '@material-ui/core';
8
+ import { makeStyles, useTheme } from '@material-ui/core/styles';
9
+ import IconButton from '@material-ui/core/IconButton';
10
+ import FirstPageIcon from '@material-ui/icons/FirstPage';
11
+ import KeyboardArrowLeft from '@material-ui/icons/KeyboardArrowLeft';
12
+ import KeyboardArrowRight from '@material-ui/icons/KeyboardArrowRight';
13
+ import LastPageIcon from '@material-ui/icons/LastPage';
14
+
15
+ const useStyles1 = makeStyles((theme) => ({
16
+ root: {
17
+ flexShrink: 0,
18
+ marginLeft: theme.spacing(2.5),
19
+ },
20
+ }));
21
+
22
+ function TablePaginationActions(props) {
23
+ const classes = useStyles1();
24
+ const theme = useTheme();
25
+ const {
26
+ count, page, rowsPerPage, onPageChange,
27
+ } = props;
28
+
29
+ const handleFirstPageButtonClick = (event) => {
30
+ onPageChange(event, 0);
31
+ };
32
+
33
+ const handleBackButtonClick = (event) => {
34
+ onPageChange(event, page - 1);
35
+ };
36
+
37
+ const handleNextButtonClick = (event) => {
38
+ onPageChange(event, page + 1);
39
+ };
40
+
41
+ const handleLastPageButtonClick = (event) => {
42
+ onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
43
+ };
44
+
45
+ return (
46
+ <div className={classes.root}>
47
+ <IconButton
48
+ onClick={handleFirstPageButtonClick}
49
+ disabled={page === 0}
50
+ aria-label="first page"
51
+ >
52
+ {theme.direction === 'rtl' ? <LastPageIcon /> : <FirstPageIcon />}
53
+ </IconButton>
54
+ <IconButton onClick={handleBackButtonClick} disabled={page === 0} aria-label="previous page">
55
+ {theme.direction === 'rtl' ? <KeyboardArrowRight /> : <KeyboardArrowLeft />}
56
+ </IconButton>
57
+ <IconButton
58
+ onClick={handleNextButtonClick}
59
+ disabled={page >= Math.ceil(count / rowsPerPage) - 1}
60
+ aria-label="next page"
61
+ >
62
+ {theme.direction === 'rtl' ? <KeyboardArrowLeft /> : <KeyboardArrowRight />}
63
+ </IconButton>
64
+ <IconButton
65
+ onClick={handleLastPageButtonClick}
66
+ disabled={page >= Math.ceil(count / rowsPerPage) - 1}
67
+ aria-label="last page"
68
+ >
69
+ {theme.direction === 'rtl' ? <FirstPageIcon /> : <LastPageIcon />}
70
+ </IconButton>
71
+ </div>
72
+ );
73
+ }
74
+
75
+ TablePaginationActions.propTypes = {
76
+ count: PropTypes.number.isRequired,
77
+ onPageChange: PropTypes.func.isRequired,
78
+ page: PropTypes.number.isRequired,
79
+ rowsPerPage: PropTypes.number.isRequired,
80
+ };
8
81
 
9
82
  const defaultTheme = {
10
83
  MuiTablePagination: {
@@ -32,6 +105,13 @@ const defaultTheme = {
32
105
  },
33
106
  };
34
107
 
108
+ const downloadAreaStyle = {
109
+ display: 'flex',
110
+ borderTop: '1px solid #8A7F7C',
111
+ borderBottom: '1px solid #8A7F7C',
112
+ paddingRight: '41px',
113
+ };
114
+
35
115
  const CustomPagination = ({
36
116
  rowsPerPageOptions,
37
117
  count,
@@ -42,15 +122,18 @@ const CustomPagination = ({
42
122
  customTheme = {},
43
123
  }) => (
44
124
  <ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
45
- <TablePagination
46
- rowsPerPageOptions={rowsPerPageOptions}
47
- component="div"
48
- count={count}
49
- rowsPerPage={rowsPerPage}
50
- page={page}
51
- onPageChange={onPageChange}
52
- onRowsPerPageChange={onRowsPerPageChange}
53
- />
125
+ <div className="downloadArea" style={downloadAreaStyle}>
126
+ <TablePagination
127
+ rowsPerPageOptions={rowsPerPageOptions}
128
+ component="div"
129
+ count={count}
130
+ rowsPerPage={rowsPerPage}
131
+ page={page}
132
+ onPageChange={onPageChange}
133
+ onRowsPerPageChange={onRowsPerPageChange}
134
+ ActionsComponent={TablePaginationActions}
135
+ />
136
+ </div>
54
137
  </ThemeProvider>
55
138
  );
56
139
 
@@ -7,30 +7,32 @@ import {
7
7
  import { CloudDownload } from '@material-ui/icons';
8
8
  import { downloadJson } from '../util/downloadTable';
9
9
 
10
+ const downloadButtonStyle = {
11
+ color: '#d1d2d3',
12
+ marginTop: '7px',
13
+ };
14
+
10
15
  const DownloadButton = ({
11
- download,
12
- rows,
13
- table,
16
+ count,
14
17
  queryVariables,
15
- server,
18
+ table,
16
19
  }) => {
17
- if (!download) {
18
- return null;
20
+ if (count === 0) {
21
+ return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
19
22
  }
20
- const {
21
- downloadCsv = 'download',
22
- downloadTable,
23
- downloadFileName,
24
- } = download;
25
23
 
26
24
  const client = useApolloClient();
27
25
 
26
+ const downloadFile = 'INS ';
27
+
28
28
  async function downloadSCSVFile() {
29
29
  const {
30
30
  query,
31
31
  paginationAPIField,
32
32
  } = table;
33
33
 
34
+ const downloadFileName = downloadFile.concat(paginationAPIField.replace('OverView', ''), ' download');
35
+
34
36
  const result = await client.query({
35
37
  query,
36
38
  variables: {
@@ -49,28 +51,17 @@ const DownloadButton = ({
49
51
  }
50
52
 
51
53
  const downloadTableCSV = useCallback(() => {
52
- if (downloadTable) {
53
- downloadTable();
54
- } else if (!downloadTable && !server) {
55
- downloadJson(rows, table, downloadFileName);
56
- } else {
57
- downloadSCSVFile();
58
- }
54
+ downloadSCSVFile();
59
55
  }, [queryVariables]);
60
56
 
61
57
  return (
62
- <>
63
- <Tooltip
64
- title={downloadCsv}
65
- className="download-icon"
58
+ <Tooltip title="Download Full Table As CSV">
59
+ <IconButton
60
+ onClick={downloadTableCSV}
66
61
  >
67
- <IconButton
68
- onClick={downloadTableCSV}
69
- >
70
- <CloudDownload />
71
- </IconButton>
72
- </Tooltip>
73
- </>
62
+ <CloudDownload />
63
+ </IconButton>
64
+ </Tooltip>
74
65
  );
75
66
  };
76
67