@bento-core/table 1.0.1-ins.2 → 1.0.1-ins.21
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 +22 -15
- package/dist/TableView.js +16 -7
- package/dist/body/DefaultThemConfig.js +1 -1
- package/dist/body/DisplayBodyCell.js +7 -1
- package/dist/body/components/ConditionalExternalLinkView.js +51 -0
- package/dist/header/CustomCell.js +10 -1
- package/dist/header/CustomHeaderCell.css +39 -0
- package/dist/index.js +6 -0
- package/dist/pagination/CustomPagination.js +69 -2
- package/dist/toolbar/DownloadButtonView.js +21 -24
- package/dist/util/Types.js +13 -1
- package/dist/util/downloadTable.js +5 -4
- package/package.json +1 -1
- package/src/ExtendedView.js +37 -34
- package/src/TableView.js +24 -14
- package/src/body/DefaultThemConfig.js +1 -1
- package/src/body/DisplayBodyCell.js +9 -1
- package/src/body/components/ConditionalExternalLinkView.js +43 -0
- package/src/header/CustomCell.js +8 -5
- package/src/header/CustomHeaderCell.css +39 -0
- package/src/index.js +1 -0
- package/src/pagination/CustomPagination.js +90 -9
- package/src/toolbar/DownloadButtonView.js +23 -30
- package/src/util/Types.js +9 -0
- package/src/util/downloadTable.js +5 -4
package/dist/ExtendedView.js
CHANGED
|
@@ -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
|
+
paddingRight: '41px',
|
|
22
|
+
float: 'right'
|
|
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: "
|
|
48
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
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(
|
|
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
|
+
paddingRight: '41px',
|
|
39
|
+
float: 'right'
|
|
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(
|
|
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;
|
|
@@ -9,6 +9,7 @@ var _core = require("@material-ui/core");
|
|
|
9
9
|
var _Types = require("../util/Types");
|
|
10
10
|
var _CustomLinkView = _interopRequireDefault(require("./components/CustomLinkView"));
|
|
11
11
|
var _ExternalLinkView = _interopRequireDefault(require("./components/ExternalLinkView"));
|
|
12
|
+
var _ConditionalExternalLinkView = _interopRequireDefault(require("./components/ConditionalExternalLinkView"));
|
|
12
13
|
var _DataFormatView = _interopRequireDefault(require("./components/DataFormatView"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
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; }
|
|
@@ -61,6 +62,11 @@ const ViewCell = _ref2 => {
|
|
|
61
62
|
row: row,
|
|
62
63
|
column: column
|
|
63
64
|
});
|
|
65
|
+
case _Types.cellTypes.CONDITIONAL_EXTERNAL_LINK:
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_ConditionalExternalLinkView.default, {
|
|
67
|
+
row: row,
|
|
68
|
+
column: column
|
|
69
|
+
});
|
|
64
70
|
case _Types.cellTypes.CUSTOM_ELEM:
|
|
65
71
|
return /*#__PURE__*/_react.default.createElement(CustomComponent, {
|
|
66
72
|
row: row,
|
|
@@ -76,7 +82,7 @@ const DisplayCell = _ref3 => {
|
|
|
76
82
|
column
|
|
77
83
|
} = _ref3;
|
|
78
84
|
return /*#__PURE__*/_react.default.createElement(_core.TableCell, {
|
|
79
|
-
className: column.
|
|
85
|
+
className: column.className
|
|
80
86
|
}, /*#__PURE__*/_react.default.createElement(ViewCell, {
|
|
81
87
|
row: row,
|
|
82
88
|
column: column
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _core = require("@material-ui/core");
|
|
9
|
+
var _Types = require("../../util/Types");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
/* eslint-disable no-console */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Conditional External Link component
|
|
15
|
+
*/
|
|
16
|
+
const ConditionalExternalLinkView = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
column,
|
|
19
|
+
row
|
|
20
|
+
} = _ref;
|
|
21
|
+
const {
|
|
22
|
+
rootPath,
|
|
23
|
+
pathParams
|
|
24
|
+
} = column === null || column === void 0 ? void 0 : column.linkAttr;
|
|
25
|
+
const url = pathParams.map(attr => {
|
|
26
|
+
if (!rootPath) {
|
|
27
|
+
return row[attr];
|
|
28
|
+
}
|
|
29
|
+
return "".concat(rootPath, "/").concat(row[attr]);
|
|
30
|
+
});
|
|
31
|
+
const externalLinkIcon = {
|
|
32
|
+
src: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/bento/images/icons/svgs/externalLinkIcon.svg',
|
|
33
|
+
alt: 'External link icon'
|
|
34
|
+
};
|
|
35
|
+
return !url[0] || url[0] === '' ? '' : /*#__PURE__*/_react.default.createElement(_core.Link, {
|
|
36
|
+
href: url,
|
|
37
|
+
target: "_blank",
|
|
38
|
+
rel: "noopener noreferrer",
|
|
39
|
+
className: _Types.cellTypes.LINK
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Typography, null, row[column === null || column === void 0 ? void 0 : column.dataField], /*#__PURE__*/_react.default.createElement("img", {
|
|
41
|
+
src: externalLinkIcon.src,
|
|
42
|
+
alt: externalLinkIcon.alt,
|
|
43
|
+
style: {
|
|
44
|
+
width: '16px',
|
|
45
|
+
verticalAlign: 'sub',
|
|
46
|
+
marginLeft: '4px'
|
|
47
|
+
}
|
|
48
|
+
})));
|
|
49
|
+
};
|
|
50
|
+
var _default = ConditionalExternalLinkView;
|
|
51
|
+
exports.default = _default;
|
|
@@ -9,6 +9,7 @@ var _TableCell = _interopRequireDefault(require("@material-ui/core/TableCell"));
|
|
|
9
9
|
var _TableSortLabel = _interopRequireDefault(require("@material-ui/core/TableSortLabel"));
|
|
10
10
|
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
11
11
|
var _Types = require("../util/Types");
|
|
12
|
+
require("./CustomHeaderCell.css");
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
14
|
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); }
|
|
14
15
|
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; }
|
|
@@ -27,6 +28,7 @@ const CustomHeaderCell = _ref => {
|
|
|
27
28
|
const {
|
|
28
29
|
dataField,
|
|
29
30
|
tooltipText,
|
|
31
|
+
// tooltipDefinition,
|
|
30
32
|
header,
|
|
31
33
|
headerType,
|
|
32
34
|
customColHeaderRender
|
|
@@ -60,7 +62,14 @@ const CustomHeaderCell = _ref => {
|
|
|
60
62
|
hideSortIcon: sortBy !== dataField,
|
|
61
63
|
direction: sortBy === dataField ? sortOrder : 'asc',
|
|
62
64
|
onClick: toggleSort
|
|
63
|
-
}, headerType === _Types.headerTypes.CUSTOM_ELEM && customColHeaderRender ? customColHeaderRender(column) : header))
|
|
65
|
+
}, headerType === _Types.headerTypes.CUSTOM_ELEM && customColHeaderRender ? customColHeaderRender(column) : header)), /*#__PURE__*/_react.default.createElement("div", {
|
|
66
|
+
className: "tooltip-icon"
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
68
|
+
src: "https://raw.githubusercontent.com/google/material-design-icons/master/src/action/help/materialicons/24px.svg",
|
|
69
|
+
alt: "tooltipIcon"
|
|
70
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
71
|
+
className: "tooltip-text"
|
|
72
|
+
}, "TEST")));
|
|
64
73
|
};
|
|
65
74
|
var _default = CustomHeaderCell;
|
|
66
75
|
exports.default = _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.tooltip-icon {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.tooltip-text {
|
|
7
|
+
visibility: hidden;
|
|
8
|
+
width: 80px;
|
|
9
|
+
background-color: black;
|
|
10
|
+
color: #fff;
|
|
11
|
+
text-align: center;
|
|
12
|
+
border-radius: 6px;
|
|
13
|
+
padding: 5px 0;
|
|
14
|
+
position: absolute;
|
|
15
|
+
z-index: 1;
|
|
16
|
+
bottom: 125%;
|
|
17
|
+
left: 50%;
|
|
18
|
+
margin-left: -40px;
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transition: opacity 0.3s;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tooltip-text::after {
|
|
24
|
+
content: '';
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 100%;
|
|
27
|
+
left: 50%;
|
|
28
|
+
margin-left: -5px;
|
|
29
|
+
border-width: 5px;
|
|
30
|
+
border-style: solid;
|
|
31
|
+
border-color: black transparent transparent transparent;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tooltip-icon:hover .tooltip-text,
|
|
35
|
+
.tooltip-icon:focus .tooltip-text,
|
|
36
|
+
.tooltip-icon:active .tooltip-text {
|
|
37
|
+
visibility: visible;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "TableView", {
|
|
|
15
15
|
return _TableView.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "cellStyles", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _Types.cellStyles;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "cellTypes", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function get() {
|
|
@@ -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,10 @@ const defaultTheme = {
|
|
|
38
97
|
}
|
|
39
98
|
}
|
|
40
99
|
};
|
|
100
|
+
const downloadAreaStyle = {
|
|
101
|
+
display: 'flex',
|
|
102
|
+
paddingRight: '41px'
|
|
103
|
+
};
|
|
41
104
|
const CustomPagination = _ref => {
|
|
42
105
|
let {
|
|
43
106
|
rowsPerPageOptions,
|
|
@@ -52,6 +115,9 @@ const CustomPagination = _ref => {
|
|
|
52
115
|
theme: (0, _core.createTheme)({
|
|
53
116
|
overrides: _objectSpread(_objectSpread({}, defaultTheme), customTheme)
|
|
54
117
|
})
|
|
118
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
119
|
+
className: "downloadArea",
|
|
120
|
+
style: downloadAreaStyle
|
|
55
121
|
}, /*#__PURE__*/_react.default.createElement(_core.TablePagination, {
|
|
56
122
|
rowsPerPageOptions: rowsPerPageOptions,
|
|
57
123
|
component: "div",
|
|
@@ -59,8 +125,9 @@ const CustomPagination = _ref => {
|
|
|
59
125
|
rowsPerPage: rowsPerPage,
|
|
60
126
|
page: page,
|
|
61
127
|
onPageChange: onPageChange,
|
|
62
|
-
onRowsPerPageChange: onRowsPerPageChange
|
|
63
|
-
|
|
128
|
+
onRowsPerPageChange: onRowsPerPageChange,
|
|
129
|
+
ActionsComponent: TablePaginationActions
|
|
130
|
+
})));
|
|
64
131
|
};
|
|
65
132
|
CustomPagination.propTypes = {
|
|
66
133
|
rowsPerPageOptions: _propTypes.default.arrayOf(_propTypes.default.number).isRequired,
|
|
@@ -16,33 +16,37 @@ 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
|
-
|
|
22
|
-
rows,
|
|
23
|
-
table,
|
|
25
|
+
count,
|
|
24
26
|
queryVariables,
|
|
25
|
-
|
|
27
|
+
table
|
|
26
28
|
} = _ref;
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
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), {}, {
|
|
44
46
|
page: 0,
|
|
45
|
-
first: 10000
|
|
47
|
+
first: 10000,
|
|
48
|
+
sort_direction: table.sortBy,
|
|
49
|
+
order_by: table.sortOrder
|
|
46
50
|
})
|
|
47
51
|
}).then(response => {
|
|
48
52
|
if (paginationAPIField && response && response.data) {
|
|
@@ -53,20 +57,13 @@ const DownloadButton = _ref => {
|
|
|
53
57
|
(0, _downloadTable.downloadJson)(result, table, downloadFileName);
|
|
54
58
|
}
|
|
55
59
|
const downloadTableCSV = (0, _react.useCallback)(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} else {
|
|
61
|
-
downloadSCSVFile();
|
|
62
|
-
}
|
|
63
|
-
}, [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
|
+
downloadSCSVFile();
|
|
61
|
+
}, [queryVariables, table]);
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_core.Tooltip, {
|
|
63
|
+
title: "Download Full Table As CSV"
|
|
67
64
|
}, /*#__PURE__*/_react.default.createElement(_core.IconButton, {
|
|
68
65
|
onClick: downloadTableCSV
|
|
69
|
-
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null)))
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement(_icons.CloudDownload, null)));
|
|
70
67
|
};
|
|
71
68
|
var _default = DownloadButton;
|
|
72
69
|
exports.default = _default;
|
package/dist/util/Types.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.actionCellTypes = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXTERNAL_LINK = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CHECKBOX = void 0;
|
|
6
|
+
exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM_LINK = exports.TRANSFORM = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXTERNAL_LINK = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CONDITIONAL_EXTERNAL_LINK = exports.CHECKBOX = void 0;
|
|
7
7
|
const CHECKBOX = 'CHECKBOX';
|
|
8
8
|
exports.CHECKBOX = CHECKBOX;
|
|
9
9
|
const DELETE = 'DELETE';
|
|
@@ -14,6 +14,8 @@ const LINK = 'LINK';
|
|
|
14
14
|
exports.LINK = LINK;
|
|
15
15
|
const EXTERNAL_LINK = 'EXTERNAL_LINK';
|
|
16
16
|
exports.EXTERNAL_LINK = EXTERNAL_LINK;
|
|
17
|
+
const CONDITIONAL_EXTERNAL_LINK = 'CONDITIONAL_EXTERNAL_LINK';
|
|
18
|
+
exports.CONDITIONAL_EXTERNAL_LINK = CONDITIONAL_EXTERNAL_LINK;
|
|
17
19
|
const DISPLAY = 'DISPLAY';
|
|
18
20
|
exports.DISPLAY = DISPLAY;
|
|
19
21
|
const DEFAULT = 'DEFAULT';
|
|
@@ -22,10 +24,15 @@ const FORMAT_DATA = 'FORMAT_DATA';
|
|
|
22
24
|
exports.FORMAT_DATA = FORMAT_DATA;
|
|
23
25
|
const FORMAT_BYTES = 'FORMAT_BYTES';
|
|
24
26
|
exports.FORMAT_BYTES = FORMAT_BYTES;
|
|
27
|
+
const TRANSFORM = 'TRANSFORM';
|
|
28
|
+
exports.TRANSFORM = TRANSFORM;
|
|
29
|
+
const TRANSFORM_LINK = 'TRANSFORM_LINK';
|
|
30
|
+
exports.TRANSFORM_LINK = TRANSFORM_LINK;
|
|
25
31
|
const cellTypes = {
|
|
26
32
|
CUSTOM_ELEM,
|
|
27
33
|
LINK,
|
|
28
34
|
EXTERNAL_LINK,
|
|
35
|
+
CONDITIONAL_EXTERNAL_LINK,
|
|
29
36
|
DISPLAY,
|
|
30
37
|
CHECKBOX,
|
|
31
38
|
DELETE,
|
|
@@ -33,6 +40,11 @@ const cellTypes = {
|
|
|
33
40
|
FORMAT_DATA
|
|
34
41
|
};
|
|
35
42
|
exports.cellTypes = cellTypes;
|
|
43
|
+
const cellStyles = {
|
|
44
|
+
TRANSFORM,
|
|
45
|
+
TRANSFORM_LINK
|
|
46
|
+
};
|
|
47
|
+
exports.cellStyles = cellStyles;
|
|
36
48
|
const actionCellTypes = [CHECKBOX, DELETE];
|
|
37
49
|
exports.actionCellTypes = actionCellTypes;
|
|
38
50
|
const FORMAT_DATA_CELLS = [FORMAT_BYTES];
|
|
@@ -62,9 +62,10 @@ function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
62
62
|
}
|
|
63
63
|
function downloadJson(tableData, table, downloadFileName) {
|
|
64
64
|
const {
|
|
65
|
-
|
|
65
|
+
downloadColumns = []
|
|
66
66
|
} = table;
|
|
67
|
-
|
|
67
|
+
// eslint-disable-next-line max-len
|
|
68
|
+
const filterColumns = downloadColumns.filter(_ref => {
|
|
68
69
|
let {
|
|
69
70
|
cellType
|
|
70
71
|
} = _ref;
|
|
@@ -72,7 +73,7 @@ function downloadJson(tableData, table, downloadFileName) {
|
|
|
72
73
|
});
|
|
73
74
|
const formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
|
74
75
|
const jsonse = JSON.stringify(formatDataVal);
|
|
75
|
-
const keysToInclude =
|
|
76
|
+
const keysToInclude = downloadColumns.filter(_ref2 => {
|
|
76
77
|
let {
|
|
77
78
|
dataField
|
|
78
79
|
} = _ref2;
|
|
@@ -83,7 +84,7 @@ function downloadJson(tableData, table, downloadFileName) {
|
|
|
83
84
|
} = _ref3;
|
|
84
85
|
return dataField;
|
|
85
86
|
});
|
|
86
|
-
const headers =
|
|
87
|
+
const headers = downloadColumns.filter(_ref4 => {
|
|
87
88
|
let {
|
|
88
89
|
dataField
|
|
89
90
|
} = _ref4;
|
package/package.json
CHANGED
package/src/ExtendedView.js
CHANGED
|
@@ -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
|
+
paddingRight: '41px',
|
|
15
|
+
float: 'right',
|
|
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,40 @@ 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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
<ManageColumnView
|
|
43
|
+
table={table}
|
|
44
|
+
manageViewColumns={manageViewColumns}
|
|
45
|
+
onColumnViewChange={onColumnViewChange}
|
|
46
|
+
/>
|
|
47
|
+
</Toolbar>
|
|
54
48
|
)}
|
|
55
49
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
(pagination) && (
|
|
51
|
+
<div className="downloadArea" style={downloadAreaStyle}>
|
|
52
|
+
<CustomPagination
|
|
53
|
+
customTheme={customTheme.tblTopPgn}
|
|
54
|
+
rowsPerPageOptions={[10, 25, 50, 100]}
|
|
55
|
+
component="div"
|
|
56
|
+
count={table.totalRowCount || 0}
|
|
57
|
+
rowsPerPage={table.rowsPerPage || 10}
|
|
58
|
+
page={table.page || 0}
|
|
59
|
+
onPageChange={onPageChange}
|
|
60
|
+
onRowsPerPageChange={onRowsPerPageChange}
|
|
61
|
+
queryVariables={queryVariables}
|
|
62
|
+
table={table}
|
|
63
|
+
/>
|
|
64
|
+
<DownloadButton
|
|
65
|
+
count={table.totalRowCount || 0}
|
|
66
|
+
queryVariables={queryVariables}
|
|
67
|
+
table={table}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
69
72
|
</ThemeProvider>
|
|
70
73
|
);
|
|
71
74
|
};
|
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
|
+
paddingRight: '41px',
|
|
32
|
+
float: 'right',
|
|
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
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { cellTypes } from '../util/Types';
|
|
7
7
|
import CustomLinkView from './components/CustomLinkView';
|
|
8
8
|
import ExternalLinkView from './components/ExternalLinkView';
|
|
9
|
+
import ConditionalExternalLinkView from './components/ConditionalExternalLinkView';
|
|
9
10
|
import DataFormatView from './components/DataFormatView';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -54,6 +55,13 @@ const ViewCell = ({
|
|
|
54
55
|
column={column}
|
|
55
56
|
/>
|
|
56
57
|
);
|
|
58
|
+
case cellTypes.CONDITIONAL_EXTERNAL_LINK:
|
|
59
|
+
return (
|
|
60
|
+
<ConditionalExternalLinkView
|
|
61
|
+
row={row}
|
|
62
|
+
column={column}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
57
65
|
case cellTypes.CUSTOM_ELEM:
|
|
58
66
|
return (
|
|
59
67
|
<CustomComponent
|
|
@@ -74,7 +82,7 @@ const DisplayCell = ({
|
|
|
74
82
|
row,
|
|
75
83
|
column,
|
|
76
84
|
}) => (
|
|
77
|
-
<TableCell className={column.
|
|
85
|
+
<TableCell className={column.className}>
|
|
78
86
|
<ViewCell
|
|
79
87
|
row={row}
|
|
80
88
|
column={column}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Link, Typography,
|
|
5
|
+
} from '@material-ui/core';
|
|
6
|
+
import { cellTypes } from '../../util/Types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Conditional External Link component
|
|
10
|
+
*/
|
|
11
|
+
const ConditionalExternalLinkView = ({
|
|
12
|
+
column,
|
|
13
|
+
row,
|
|
14
|
+
}) => {
|
|
15
|
+
const { rootPath, pathParams } = column?.linkAttr;
|
|
16
|
+
const url = pathParams.map((attr) => {
|
|
17
|
+
if (!rootPath) {
|
|
18
|
+
return row[attr];
|
|
19
|
+
}
|
|
20
|
+
return `${rootPath}/`.concat(row[attr]);
|
|
21
|
+
});
|
|
22
|
+
const externalLinkIcon = {
|
|
23
|
+
src: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/bento/images/icons/svgs/externalLinkIcon.svg',
|
|
24
|
+
alt: 'External link icon',
|
|
25
|
+
};
|
|
26
|
+
return (
|
|
27
|
+
!url[0] || url[0] === '' ? ''
|
|
28
|
+
: (
|
|
29
|
+
<Link href={url} target="_blank" rel="noopener noreferrer" className={cellTypes.LINK}>
|
|
30
|
+
<Typography>
|
|
31
|
+
{row[column?.dataField]}
|
|
32
|
+
<img
|
|
33
|
+
src={externalLinkIcon.src}
|
|
34
|
+
alt={externalLinkIcon.alt}
|
|
35
|
+
style={{ width: '16px', verticalAlign: 'sub', marginLeft: '4px' }}
|
|
36
|
+
/>
|
|
37
|
+
</Typography>
|
|
38
|
+
</Link>
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default ConditionalExternalLinkView;
|
package/src/header/CustomCell.js
CHANGED
|
@@ -3,6 +3,7 @@ import TableCell from '@material-ui/core/TableCell';
|
|
|
3
3
|
import TableSortLabel from '@material-ui/core/TableSortLabel';
|
|
4
4
|
import MuiTooltip from '@material-ui/core/Tooltip';
|
|
5
5
|
import { headerTypes } from '../util/Types';
|
|
6
|
+
import './CustomHeaderCell.css';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
@@ -18,6 +19,7 @@ const CustomHeaderCell = ({
|
|
|
18
19
|
const {
|
|
19
20
|
dataField,
|
|
20
21
|
tooltipText,
|
|
22
|
+
// tooltipDefinition,
|
|
21
23
|
header,
|
|
22
24
|
headerType,
|
|
23
25
|
customColHeaderRender,
|
|
@@ -27,11 +29,7 @@ const CustomHeaderCell = ({
|
|
|
27
29
|
// return custom tooltips
|
|
28
30
|
if (components.Tooltip) {
|
|
29
31
|
const CustomToolTip = components.Tooltip;
|
|
30
|
-
return
|
|
31
|
-
<CustomToolTip>
|
|
32
|
-
{children}
|
|
33
|
-
</CustomToolTip>
|
|
34
|
-
);
|
|
32
|
+
return <CustomToolTip>{children}</CustomToolTip>;
|
|
35
33
|
}
|
|
36
34
|
// return default tooltip
|
|
37
35
|
if (tooltipText) {
|
|
@@ -63,6 +61,11 @@ const CustomHeaderCell = ({
|
|
|
63
61
|
? customColHeaderRender(column) : header}
|
|
64
62
|
</TableSortLabel>
|
|
65
63
|
</Tooltip>
|
|
64
|
+
<div className="tooltip-icon">
|
|
65
|
+
<img src="https://raw.githubusercontent.com/google/material-design-icons/master/src/action/help/materialicons/24px.svg" alt="tooltipIcon" />
|
|
66
|
+
{/* <div className="tooltip-text">{{ tooltipDefinition }}</div> */}
|
|
67
|
+
<div className="tooltip-text">TEST</div>
|
|
68
|
+
</div>
|
|
66
69
|
</TableCell>
|
|
67
70
|
);
|
|
68
71
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.tooltip-icon {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.tooltip-text {
|
|
7
|
+
visibility: hidden;
|
|
8
|
+
width: 80px;
|
|
9
|
+
background-color: black;
|
|
10
|
+
color: #fff;
|
|
11
|
+
text-align: center;
|
|
12
|
+
border-radius: 6px;
|
|
13
|
+
padding: 5px 0;
|
|
14
|
+
position: absolute;
|
|
15
|
+
z-index: 1;
|
|
16
|
+
bottom: 125%;
|
|
17
|
+
left: 50%;
|
|
18
|
+
margin-left: -40px;
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transition: opacity 0.3s;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.tooltip-text::after {
|
|
24
|
+
content: '';
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 100%;
|
|
27
|
+
left: 50%;
|
|
28
|
+
margin-left: -5px;
|
|
29
|
+
border-width: 5px;
|
|
30
|
+
border-style: solid;
|
|
31
|
+
border-color: black transparent transparent transparent;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.tooltip-icon:hover .tooltip-text,
|
|
35
|
+
.tooltip-icon:focus .tooltip-text,
|
|
36
|
+
.tooltip-icon:active .tooltip-text {
|
|
37
|
+
visibility: visible;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
}
|
package/src/index.js
CHANGED
|
@@ -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,11 @@ const defaultTheme = {
|
|
|
32
105
|
},
|
|
33
106
|
};
|
|
34
107
|
|
|
108
|
+
const downloadAreaStyle = {
|
|
109
|
+
display: 'flex',
|
|
110
|
+
paddingRight: '41px',
|
|
111
|
+
};
|
|
112
|
+
|
|
35
113
|
const CustomPagination = ({
|
|
36
114
|
rowsPerPageOptions,
|
|
37
115
|
count,
|
|
@@ -42,15 +120,18 @@ const CustomPagination = ({
|
|
|
42
120
|
customTheme = {},
|
|
43
121
|
}) => (
|
|
44
122
|
<ThemeProvider theme={createTheme({ overrides: { ...defaultTheme, ...customTheme } })}>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
123
|
+
<div className="downloadArea" style={downloadAreaStyle}>
|
|
124
|
+
<TablePagination
|
|
125
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
126
|
+
component="div"
|
|
127
|
+
count={count}
|
|
128
|
+
rowsPerPage={rowsPerPage}
|
|
129
|
+
page={page}
|
|
130
|
+
onPageChange={onPageChange}
|
|
131
|
+
onRowsPerPageChange={onRowsPerPageChange}
|
|
132
|
+
ActionsComponent={TablePaginationActions}
|
|
133
|
+
/>
|
|
134
|
+
</div>
|
|
54
135
|
</ThemeProvider>
|
|
55
136
|
);
|
|
56
137
|
|
|
@@ -7,36 +7,40 @@ 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
|
-
|
|
12
|
-
rows,
|
|
13
|
-
table,
|
|
16
|
+
count,
|
|
14
17
|
queryVariables,
|
|
15
|
-
|
|
18
|
+
table,
|
|
16
19
|
}) => {
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
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: {
|
|
37
39
|
...queryVariables,
|
|
38
40
|
page: 0,
|
|
39
41
|
first: 10000,
|
|
42
|
+
sort_direction: table.sortBy,
|
|
43
|
+
order_by: table.sortOrder,
|
|
40
44
|
},
|
|
41
45
|
})
|
|
42
46
|
.then((response) => {
|
|
@@ -49,28 +53,17 @@ const DownloadButton = ({
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
const downloadTableCSV = useCallback(() => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} else if (!downloadTable && !server) {
|
|
55
|
-
downloadJson(rows, table, downloadFileName);
|
|
56
|
-
} else {
|
|
57
|
-
downloadSCSVFile();
|
|
58
|
-
}
|
|
59
|
-
}, [queryVariables]);
|
|
56
|
+
downloadSCSVFile();
|
|
57
|
+
}, [queryVariables, table]);
|
|
60
58
|
|
|
61
59
|
return (
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
className="download-icon"
|
|
60
|
+
<Tooltip title="Download Full Table As CSV">
|
|
61
|
+
<IconButton
|
|
62
|
+
onClick={downloadTableCSV}
|
|
66
63
|
>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<CloudDownload />
|
|
71
|
-
</IconButton>
|
|
72
|
-
</Tooltip>
|
|
73
|
-
</>
|
|
64
|
+
<CloudDownload />
|
|
65
|
+
</IconButton>
|
|
66
|
+
</Tooltip>
|
|
74
67
|
);
|
|
75
68
|
};
|
|
76
69
|
|
package/src/util/Types.js
CHANGED
|
@@ -3,15 +3,19 @@ export const DELETE = 'DELETE';
|
|
|
3
3
|
export const CUSTOM_ELEM = 'CUSTOM_ELEM';
|
|
4
4
|
export const LINK = 'LINK';
|
|
5
5
|
export const EXTERNAL_LINK = 'EXTERNAL_LINK';
|
|
6
|
+
export const CONDITIONAL_EXTERNAL_LINK = 'CONDITIONAL_EXTERNAL_LINK';
|
|
6
7
|
export const DISPLAY = 'DISPLAY';
|
|
7
8
|
export const DEFAULT = 'DEFAULT';
|
|
8
9
|
export const FORMAT_DATA = 'FORMAT_DATA';
|
|
9
10
|
export const FORMAT_BYTES = 'FORMAT_BYTES';
|
|
11
|
+
export const TRANSFORM = 'TRANSFORM';
|
|
12
|
+
export const TRANSFORM_LINK = 'TRANSFORM_LINK';
|
|
10
13
|
|
|
11
14
|
export const cellTypes = {
|
|
12
15
|
CUSTOM_ELEM,
|
|
13
16
|
LINK,
|
|
14
17
|
EXTERNAL_LINK,
|
|
18
|
+
CONDITIONAL_EXTERNAL_LINK,
|
|
15
19
|
DISPLAY,
|
|
16
20
|
CHECKBOX,
|
|
17
21
|
DELETE,
|
|
@@ -19,6 +23,11 @@ export const cellTypes = {
|
|
|
19
23
|
FORMAT_DATA,
|
|
20
24
|
};
|
|
21
25
|
|
|
26
|
+
export const cellStyles = {
|
|
27
|
+
TRANSFORM,
|
|
28
|
+
TRANSFORM_LINK,
|
|
29
|
+
};
|
|
30
|
+
|
|
22
31
|
export const actionCellTypes = [CHECKBOX, DELETE];
|
|
23
32
|
|
|
24
33
|
export const FORMAT_DATA_CELLS = [FORMAT_BYTES];
|
|
@@ -54,13 +54,14 @@ export function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export function downloadJson(tableData, table, downloadFileName) {
|
|
57
|
-
const {
|
|
58
|
-
|
|
57
|
+
const { downloadColumns = [] } = table;
|
|
58
|
+
// eslint-disable-next-line max-len
|
|
59
|
+
const filterColumns = downloadColumns.filter(({ cellType }) => !actionCellTypes.includes(cellType));
|
|
59
60
|
const formatDataVal = formatColumnValues(filterColumns, tableData);
|
|
60
61
|
const jsonse = JSON.stringify(formatDataVal);
|
|
61
|
-
const keysToInclude =
|
|
62
|
+
const keysToInclude = downloadColumns.filter(({ dataField }) => dataField)
|
|
62
63
|
.map(({ dataField }) => dataField);
|
|
63
|
-
const headers =
|
|
64
|
+
const headers = downloadColumns.filter(({ dataField }) => dataField).map(({ header }) => header);
|
|
64
65
|
const csv = convertToCSV(jsonse, keysToInclude, headers);
|
|
65
66
|
const exportData = new Blob([csv], { type: 'text/csv' });
|
|
66
67
|
const JsonURL = window.URL.createObjectURL(exportData);
|