@bento-core/table 1.0.0-c3dc.3 → 1.0.0-c3dc.30
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 +9 -11
- package/dist/TableView.js +7 -4
- package/dist/assets/cpi_icon.svg +22 -0
- package/dist/assets/downArrow.svg +3 -0
- package/dist/assets/leftArrow.svg +3 -0
- package/dist/assets/rightArrow.svg +3 -0
- package/dist/body/CustomTblBody.js +9 -4
- package/dist/body/DisplayBodyCell.js +18 -3
- package/dist/body/components/CPIModal.js +210 -0
- package/dist/body/components/CPIView.js +115 -0
- package/dist/body/components/CustomLinkView.js +1 -1
- package/dist/body/components/ModalStyle.js +121 -0
- package/dist/header/ActionHeaderCell.js +2 -1
- package/dist/header/CustomCell.js +8 -5
- package/dist/header/CustomTblHeader.js +3 -1
- package/dist/header/components/CheckBoxView.js +3 -2
- package/dist/pagination/CustomPagination.js +84 -28
- package/dist/toolbar/DownloadButtonView.js +152 -45
- package/dist/util/Types.js +8 -2
- package/dist/util/downloadTable.js +72 -37
- package/package.json +2 -2
- package/src/ExtendedView.js +34 -33
- package/src/TableView.js +11 -8
- package/src/assets/cpi_icon.svg +22 -0
- package/src/assets/downArrow.svg +3 -0
- package/src/assets/leftArrow.svg +3 -0
- package/src/assets/rightArrow.svg +3 -0
- package/src/body/CustomTblBody.js +6 -1
- package/src/body/DisplayBodyCell.js +23 -0
- package/src/body/components/CPIModal.js +245 -0
- package/src/body/components/CPIView.js +133 -0
- package/src/body/components/CustomLinkView.js +1 -1
- package/src/body/components/ModalStyle.js +115 -0
- package/src/header/ActionHeaderCell.js +1 -0
- package/src/header/CustomCell.js +6 -3
- package/src/header/CustomTblHeader.js +3 -1
- package/src/header/components/CheckBoxView.js +2 -1
- package/src/pagination/CustomPagination.js +97 -40
- package/src/toolbar/DownloadButtonView.js +168 -55
- package/src/util/Types.js +4 -0
- package/src/util/downloadTable.js +51 -17
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export default () => ({
|
|
2
|
+
header: {
|
|
3
|
+
display: 'flex',
|
|
4
|
+
justifyContent: 'center',
|
|
5
|
+
alignItems: 'center',
|
|
6
|
+
height: '55px',
|
|
7
|
+
},
|
|
8
|
+
closeButton: {
|
|
9
|
+
marginLeft: '769px',
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
},
|
|
12
|
+
resetIcon: {
|
|
13
|
+
marginLeft: '10px',
|
|
14
|
+
minWidth: '5px',
|
|
15
|
+
width: '5px',
|
|
16
|
+
borderRadius: '9px',
|
|
17
|
+
height: '30px',
|
|
18
|
+
},
|
|
19
|
+
modalTitle: {
|
|
20
|
+
fontFamily: 'Poppins',
|
|
21
|
+
fontSize: '19px',
|
|
22
|
+
fontWeight: '400',
|
|
23
|
+
lineHeight: '21px',
|
|
24
|
+
letterSpacing: '0.02em',
|
|
25
|
+
textAlign: 'center',
|
|
26
|
+
color: '#000000',
|
|
27
|
+
},
|
|
28
|
+
modalBody: {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: '5%',
|
|
31
|
+
left: '25%',
|
|
32
|
+
width: '840px',
|
|
33
|
+
height: '671px',
|
|
34
|
+
background: '#FFFFFF',
|
|
35
|
+
border: '1px solid #505050',
|
|
36
|
+
borderRadius: '40px',
|
|
37
|
+
overflow: 'hidden',
|
|
38
|
+
},
|
|
39
|
+
tableContainer: {
|
|
40
|
+
'&::-webkit-scrollbar': {
|
|
41
|
+
width: '6px',
|
|
42
|
+
borderWidth: '0px 1px 1px 1px',
|
|
43
|
+
borderStyle: 'solid',
|
|
44
|
+
borderColor: '#B0B0B0',
|
|
45
|
+
},
|
|
46
|
+
'&::-webkit-scrollbar-track': {
|
|
47
|
+
backgroundColor: '#CECECE',
|
|
48
|
+
},
|
|
49
|
+
'&::-webkit-scrollbar-thumb': {
|
|
50
|
+
backgroundColor: '#003F74',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
searchContainer: {
|
|
54
|
+
display: 'flex',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
borderTop: '3px solid #939393',
|
|
58
|
+
borderBottom: '3px solid #939393',
|
|
59
|
+
height: '51px',
|
|
60
|
+
},
|
|
61
|
+
searchInputbox: {
|
|
62
|
+
marginRight: '10px',
|
|
63
|
+
fontFamily: 'Poppins',
|
|
64
|
+
fontSize: '18px',
|
|
65
|
+
fontWeight: '600',
|
|
66
|
+
lineHeight: '27px',
|
|
67
|
+
letterSpacing: '-0.02em',
|
|
68
|
+
textAlign: 'left',
|
|
69
|
+
color: '#7A437A',
|
|
70
|
+
},
|
|
71
|
+
highlight: {
|
|
72
|
+
color: '#b2c6d6',
|
|
73
|
+
},
|
|
74
|
+
sortGroup: {
|
|
75
|
+
paddingTop: '10px',
|
|
76
|
+
marginBottom: '5px',
|
|
77
|
+
borderTop: '1px solid #B1B1B1',
|
|
78
|
+
textAlign: 'left',
|
|
79
|
+
marginLeft: '-5px',
|
|
80
|
+
},
|
|
81
|
+
sortGroupIcon: {
|
|
82
|
+
cursor: 'pointer',
|
|
83
|
+
fontFamily: 'Nunito',
|
|
84
|
+
fontSize: '10px',
|
|
85
|
+
marginRight: '12px',
|
|
86
|
+
marginLeft: '24px',
|
|
87
|
+
},
|
|
88
|
+
sortGroupItem: {
|
|
89
|
+
cursor: 'pointer',
|
|
90
|
+
fontFamily: 'Nunito',
|
|
91
|
+
fontSize: '10px',
|
|
92
|
+
marginRight: '32px',
|
|
93
|
+
},
|
|
94
|
+
NonSortGroup: {
|
|
95
|
+
marginBottom: '5px',
|
|
96
|
+
borderTop: '1px solid #B1B1B1',
|
|
97
|
+
textAlign: 'left',
|
|
98
|
+
paddingLeft: '10px',
|
|
99
|
+
},
|
|
100
|
+
NonSortGroupItem: {
|
|
101
|
+
fontFamily: 'Nunito',
|
|
102
|
+
fontSize: '10px',
|
|
103
|
+
marginRight: '32px',
|
|
104
|
+
},
|
|
105
|
+
sortGroupItemCounts: {
|
|
106
|
+
cursor: 'pointer',
|
|
107
|
+
fontFamily: 'Nunito',
|
|
108
|
+
fontSize: '10px',
|
|
109
|
+
float: 'right',
|
|
110
|
+
marginRight: '10px',
|
|
111
|
+
marginTop: '5px',
|
|
112
|
+
},
|
|
113
|
+
itemContainer: {
|
|
114
|
+
},
|
|
115
|
+
});
|
package/src/header/CustomCell.js
CHANGED
|
@@ -14,12 +14,14 @@ const CustomHeaderCell = ({
|
|
|
14
14
|
column,
|
|
15
15
|
components = {},
|
|
16
16
|
toggleSort,
|
|
17
|
+
style,
|
|
17
18
|
}) => {
|
|
18
19
|
const {
|
|
19
20
|
dataField,
|
|
20
21
|
tooltipText,
|
|
21
22
|
header,
|
|
22
23
|
headerType,
|
|
24
|
+
sortField,
|
|
23
25
|
customColHeaderRender,
|
|
24
26
|
sortable,
|
|
25
27
|
} = column;
|
|
@@ -61,12 +63,13 @@ const CustomHeaderCell = ({
|
|
|
61
63
|
scope="col"
|
|
62
64
|
active={sortBy === dataField}
|
|
63
65
|
direction={sortOrder}
|
|
66
|
+
style={style}
|
|
64
67
|
>
|
|
65
68
|
<Tooltip>
|
|
66
69
|
<TableSortLabel
|
|
67
|
-
active={sortBy === dataField}
|
|
68
|
-
hideSortIcon={sortBy !== dataField}
|
|
69
|
-
direction={sortBy === dataField ? sortOrder : 'asc'}
|
|
70
|
+
active={sortBy === ( sortField ? sortField : dataField)}
|
|
71
|
+
hideSortIcon={sortBy !== ( sortField ? sortField : dataField)}
|
|
72
|
+
direction={sortBy === ( sortField ? sortField : dataField) ? sortOrder : 'asc'}
|
|
70
73
|
onClick={toggleSort}
|
|
71
74
|
>
|
|
72
75
|
{(headerType === headerTypes.CUSTOM_ELEM && customColHeaderRender)
|
|
@@ -65,7 +65,9 @@ const CustomTableHeader = ({
|
|
|
65
65
|
column={column}
|
|
66
66
|
sortBy={sortBy}
|
|
67
67
|
sortOrder={sortOrder}
|
|
68
|
-
toggleSort={() =>
|
|
68
|
+
toggleSort={() => {
|
|
69
|
+
sortByColumn(column.sortField ? column.sortField : column.dataField, sortOrder);
|
|
70
|
+
}}
|
|
69
71
|
/>
|
|
70
72
|
);
|
|
71
73
|
})
|
|
@@ -10,6 +10,7 @@ const CheckboxView = ({
|
|
|
10
10
|
includeSelectedIds,
|
|
11
11
|
toggleSelectAll,
|
|
12
12
|
Ids,
|
|
13
|
+
rows,
|
|
13
14
|
}) => (
|
|
14
15
|
<TableCell padding="checkbox">
|
|
15
16
|
<span style={{ display: 'none' }}>Select all</span>
|
|
@@ -18,7 +19,7 @@ const CheckboxView = ({
|
|
|
18
19
|
color="primary"
|
|
19
20
|
indeterminate={includeSelectedIds}
|
|
20
21
|
checked={includeSelectedIds}
|
|
21
|
-
onChange={(event) => toggleSelectAll(event, Ids, includeSelectedIds)}
|
|
22
|
+
onChange={(event) => toggleSelectAll(event, Ids, includeSelectedIds, rows)}
|
|
22
23
|
/>
|
|
23
24
|
</TableCell>
|
|
24
25
|
);
|
|
@@ -1,37 +1,59 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
createMuiTheme,
|
|
5
5
|
TablePagination,
|
|
6
6
|
ThemeProvider,
|
|
7
|
+
IconButton,
|
|
8
|
+
makeStyles,
|
|
7
9
|
} from '@material-ui/core';
|
|
8
|
-
import
|
|
10
|
+
import {
|
|
11
|
+
ArrowDropDown,
|
|
12
|
+
} from '@material-ui/icons';
|
|
13
|
+
import rightArrow from '../assets/rightArrow.svg';
|
|
14
|
+
import leftArrow from '../assets/leftArrow.svg';
|
|
9
15
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const useStyles = makeStyles(() => ({
|
|
17
|
+
paginationRoot: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
justifyContent: 'flex-end', // Moves pagination to the right
|
|
20
|
+
paddingRight: '10px', // Optional spacing
|
|
21
|
+
},
|
|
22
|
+
actionsContainer: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
justifyContent: 'flex-end', // Align pagination buttons to the right
|
|
19
25
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const defaultTheme = createMuiTheme({
|
|
29
|
+
overrides: {
|
|
30
|
+
MuiTablePagination: {
|
|
31
|
+
root: {
|
|
32
|
+
paddingRight: '50px',
|
|
33
|
+
width: '100%',
|
|
34
|
+
},
|
|
35
|
+
toolbar: {
|
|
36
|
+
minHeight: '45px',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
},
|
|
24
40
|
},
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
MuiTypography: {
|
|
42
|
+
body2: {
|
|
43
|
+
fontSize: '14px',
|
|
44
|
+
textTransform: 'uppercase',
|
|
45
|
+
},
|
|
46
|
+
root: {
|
|
47
|
+
fontSize: '14px',
|
|
48
|
+
},
|
|
27
49
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
50
|
+
MuiIconButton: {
|
|
51
|
+
root: {
|
|
52
|
+
padding: '2px',
|
|
53
|
+
},
|
|
32
54
|
},
|
|
33
55
|
},
|
|
34
|
-
};
|
|
56
|
+
});
|
|
35
57
|
|
|
36
58
|
const CustomPagination = ({
|
|
37
59
|
rowsPerPageOptions,
|
|
@@ -41,24 +63,59 @@ const CustomPagination = ({
|
|
|
41
63
|
onPageChange,
|
|
42
64
|
onRowsPerPageChange,
|
|
43
65
|
customTheme = {},
|
|
44
|
-
}) =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
}) => {
|
|
67
|
+
const classes = useStyles();
|
|
68
|
+
return (
|
|
69
|
+
<ThemeProvider
|
|
70
|
+
theme={createMuiTheme({ overrides: { ...defaultTheme.overrides, ...customTheme } })}
|
|
71
|
+
>
|
|
72
|
+
<TablePagination
|
|
73
|
+
labelRowsPerPage={<span id="rows-per-page-label">Rows per page:</span>}
|
|
74
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
75
|
+
component="div"
|
|
76
|
+
count={count}
|
|
77
|
+
rowsPerPage={rowsPerPage}
|
|
78
|
+
page={page}
|
|
79
|
+
onPageChange={onPageChange}
|
|
80
|
+
onRowsPerPageChange={onRowsPerPageChange}
|
|
81
|
+
SelectProps={{
|
|
82
|
+
IconComponent: ArrowDropDown,
|
|
83
|
+
inputProps: {
|
|
84
|
+
'aria-label': 'Selection dropdown for displaying the number of results per page',
|
|
85
|
+
'aria-labelledby': 'rows-per-page-label',
|
|
86
|
+
style: {
|
|
87
|
+
visibility: 'hidden',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
}}
|
|
91
|
+
nextIconButtonProps={{
|
|
92
|
+
'aria-label': 'Next page',
|
|
93
|
+
}}
|
|
94
|
+
backIconButtonProps={{
|
|
95
|
+
'aria-label': 'Previous page',
|
|
96
|
+
}}
|
|
97
|
+
ActionsComponent={() => (
|
|
98
|
+
<div className={classes.actionsContainer}>
|
|
99
|
+
<IconButton
|
|
100
|
+
onClick={(event) => onPageChange(event, page - 1)}
|
|
101
|
+
disabled={page === 0}
|
|
102
|
+
aria-label="Previous page"
|
|
103
|
+
>
|
|
104
|
+
<img src={leftArrow} style={{ opacity: page === 0 ? 0.2 : 1 }} alt="Left Arrow" />
|
|
105
|
+
</IconButton>
|
|
106
|
+
<IconButton
|
|
107
|
+
onClick={(event) => onPageChange(event, page + 1)}
|
|
108
|
+
disabled={page >= Math.ceil(count / rowsPerPage) - 1}
|
|
109
|
+
aria-label="Next page"
|
|
110
|
+
>
|
|
111
|
+
<img src={rightArrow} style={{ opacity: page >= Math.ceil(count / rowsPerPage) - 1 ? 0.2 : 1 }} alt="Right Arrow" />
|
|
112
|
+
</IconButton>
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
/>
|
|
116
|
+
</ThemeProvider>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
62
119
|
|
|
63
120
|
CustomPagination.propTypes = {
|
|
64
121
|
rowsPerPageOptions: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
@@ -1,50 +1,73 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
useEffect,
|
|
4
|
+
useRef,
|
|
5
|
+
useCallback,
|
|
6
|
+
} from 'react';
|
|
2
7
|
import { useApolloClient } from '@apollo/client';
|
|
3
8
|
import {
|
|
4
9
|
IconButton,
|
|
5
10
|
Tooltip,
|
|
6
|
-
|
|
11
|
+
makeStyles,
|
|
7
12
|
} from '@material-ui/core';
|
|
8
|
-
|
|
13
|
+
import KeyboardArrowDownOutlinedIcon from '@material-ui/icons/KeyboardArrowDownOutlined';
|
|
9
14
|
import { CloudDownload } from '@material-ui/icons';
|
|
10
|
-
import {
|
|
15
|
+
import { downloadData } from '../util/downloadTable';
|
|
11
16
|
|
|
12
|
-
const downloadButtonStyle = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Default style for Download Button with Text.
|
|
18
|
-
const DEFAULT_BUTTON_STYLE = {
|
|
19
|
-
width: '223px',
|
|
20
|
-
height: '41px',
|
|
21
|
-
borderRadius: '5px',
|
|
22
|
-
backgroundColor: '#2A6E93',
|
|
23
|
-
color: '#fff',
|
|
24
|
-
marginTop: '10px',
|
|
25
|
-
fontFamily: 'poppins',
|
|
26
|
-
'& #cloudIcon': {
|
|
27
|
-
margin: '10px',
|
|
28
|
-
marginTop: '6px',
|
|
29
|
-
},
|
|
30
|
-
};
|
|
17
|
+
// const downloadButtonStyle = {
|
|
18
|
+
// color: '#d1d2d3',
|
|
19
|
+
// marginTop: '7px',
|
|
20
|
+
// };
|
|
31
21
|
|
|
32
22
|
const DownloadButton = ({
|
|
33
23
|
count,
|
|
34
24
|
queryVariables,
|
|
35
25
|
table,
|
|
36
|
-
buttonConfig = {},
|
|
37
|
-
isIcon = false,
|
|
38
26
|
}) => {
|
|
27
|
+
const [listDisplay, setListDisplay] = useState('none');
|
|
28
|
+
const dropdownSelection = useRef(null);
|
|
29
|
+
const useOutsideAlerter = (ref) => {
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
function handleClickOutside(event) {
|
|
32
|
+
if (!(event.target.getAttribute('id') && event.target.getAttribute('id').includes('dropdownListItem'))) {
|
|
33
|
+
setListDisplay('none');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
37
|
+
return () => {
|
|
38
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
39
|
+
};
|
|
40
|
+
}, [ref]);
|
|
41
|
+
};
|
|
42
|
+
useOutsideAlerter(dropdownSelection);
|
|
43
|
+
|
|
39
44
|
if (table.paginationAPIField === 'filesInList') {
|
|
40
45
|
return <></>;
|
|
41
46
|
}
|
|
42
|
-
if (count === 0) {
|
|
43
|
-
return <CloudDownload className="disableButton" style={downloadButtonStyle} />;
|
|
44
|
-
}
|
|
45
47
|
|
|
46
48
|
const client = useApolloClient();
|
|
47
49
|
|
|
50
|
+
function cleanData(result) {
|
|
51
|
+
function hasHTMLTags(str) {
|
|
52
|
+
const htmlTagPattern = /<\/?[a-z][\s\S]*>/i; // Regex to match HTML tags
|
|
53
|
+
return htmlTagPattern.test(str);
|
|
54
|
+
}
|
|
55
|
+
const cleanedResult = result.map((res) => {
|
|
56
|
+
const newObj = {};
|
|
57
|
+
Object.keys(res).forEach((key) => {
|
|
58
|
+
if (hasHTMLTags(res[key])) {
|
|
59
|
+
const div = document.createElement('div');
|
|
60
|
+
div.innerHTML = res[key];
|
|
61
|
+
newObj[key] = div.textContent || div.innerText || res[key];
|
|
62
|
+
} else {
|
|
63
|
+
newObj[key] = res[key];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return newObj;
|
|
67
|
+
});
|
|
68
|
+
return cleanedResult;
|
|
69
|
+
}
|
|
70
|
+
|
|
48
71
|
async function downloadSCSVFile() {
|
|
49
72
|
const {
|
|
50
73
|
query,
|
|
@@ -57,6 +80,34 @@ const DownloadButton = ({
|
|
|
57
80
|
...queryVariables,
|
|
58
81
|
page: 0,
|
|
59
82
|
first: 10000,
|
|
83
|
+
order_by: table.sortBy,
|
|
84
|
+
sort_direction: table.sortOrder,
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
.then((response) => {
|
|
88
|
+
if (paginationAPIField && response && response.data) {
|
|
89
|
+
return response.data[paginationAPIField];
|
|
90
|
+
}
|
|
91
|
+
return response.data;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
downloadData(cleanData(result), table, table.downloadFileName, 'csv');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function downloadJsonFile() {
|
|
98
|
+
const {
|
|
99
|
+
query,
|
|
100
|
+
paginationAPIField,
|
|
101
|
+
} = table;
|
|
102
|
+
|
|
103
|
+
const result = await client.query({
|
|
104
|
+
query,
|
|
105
|
+
variables: {
|
|
106
|
+
...queryVariables,
|
|
107
|
+
page: 0,
|
|
108
|
+
first: 10000,
|
|
109
|
+
order_by: table.sortBy,
|
|
110
|
+
sort_direction: table.sortOrder,
|
|
60
111
|
},
|
|
61
112
|
})
|
|
62
113
|
.then((response) => {
|
|
@@ -65,37 +116,99 @@ const DownloadButton = ({
|
|
|
65
116
|
}
|
|
66
117
|
return response.data;
|
|
67
118
|
});
|
|
68
|
-
|
|
119
|
+
downloadData(cleanData(result), table, table.downloadFileName, 'json');
|
|
69
120
|
}
|
|
70
121
|
|
|
71
122
|
const downloadTableCSV = useCallback(() => {
|
|
72
123
|
downloadSCSVFile();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
124
|
+
setListDisplay('none');
|
|
125
|
+
}, [queryVariables, table]);
|
|
126
|
+
|
|
127
|
+
const downloadTableJson = useCallback(() => {
|
|
128
|
+
downloadJsonFile();
|
|
129
|
+
setListDisplay('none');
|
|
130
|
+
}, [queryVariables, table]);
|
|
131
|
+
|
|
132
|
+
const handleClickButton = () => {
|
|
133
|
+
if (listDisplay === 'none') {
|
|
134
|
+
setListDisplay('block');
|
|
135
|
+
} else {
|
|
136
|
+
setListDisplay('none');
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const useStyles = makeStyles({
|
|
141
|
+
dropdown: {
|
|
142
|
+
width: '60px',
|
|
143
|
+
height: '25px',
|
|
144
|
+
marginTop: '8px',
|
|
145
|
+
paddingLeft: '5px',
|
|
146
|
+
border: '0.75px solid #606060',
|
|
147
|
+
borderRadius: '5px',
|
|
148
|
+
display: 'inline-block',
|
|
149
|
+
position: 'relative',
|
|
150
|
+
alignSelf: 'center',
|
|
151
|
+
},
|
|
152
|
+
dropdownList: {
|
|
153
|
+
display: 'block',
|
|
154
|
+
position: 'absolute',
|
|
155
|
+
width: '60px',
|
|
156
|
+
marginTop: '3px',
|
|
157
|
+
marginLeft: '-5px',
|
|
158
|
+
overflow: 'auto',
|
|
159
|
+
zIndex: '20',
|
|
160
|
+
border: '1.5px solid #41545E',
|
|
161
|
+
borderRadius: '5px',
|
|
162
|
+
background: '#ffffff',
|
|
163
|
+
},
|
|
164
|
+
dropdownListItem: {
|
|
165
|
+
padding: '2px 4px',
|
|
166
|
+
font: 'Poppins',
|
|
167
|
+
fontSize: '14px',
|
|
168
|
+
fontWeight: 400,
|
|
169
|
+
lineHeight: '21px',
|
|
170
|
+
'&:hover': {
|
|
171
|
+
background: '#D7D7D7',
|
|
172
|
+
cursor: 'pointer',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
arrowdownIcon: {
|
|
176
|
+
marginLeft: '5px',
|
|
177
|
+
fill: '#606060',
|
|
178
|
+
},
|
|
179
|
+
arrowdownIconDisabled: {
|
|
180
|
+
marginLeft: '5px',
|
|
181
|
+
fill: '#00000042',
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const classes = useStyles();
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<div className={classes.dropdown}>
|
|
189
|
+
|
|
190
|
+
<Tooltip title={table.downloadButtonTooltipText || 'Download filtered results'}>
|
|
191
|
+
{
|
|
192
|
+
count !== 0
|
|
193
|
+
? (
|
|
194
|
+
<IconButton onClick={handleClickButton} style={{ padding: '0' }}>
|
|
195
|
+
<CloudDownload />
|
|
196
|
+
<KeyboardArrowDownOutlinedIcon className={classes.arrowdownIcon} />
|
|
197
|
+
</IconButton>
|
|
198
|
+
)
|
|
199
|
+
: (
|
|
200
|
+
<IconButton disabled>
|
|
201
|
+
<CloudDownload />
|
|
202
|
+
<KeyboardArrowDownOutlinedIcon className={classes.arrowdownIconDisabled} />
|
|
203
|
+
</IconButton>
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
</Tooltip>
|
|
207
|
+
<div className={classes.dropdownList} style={{ display: listDisplay }}>
|
|
208
|
+
<div id="dropdownListItemCSV" className={classes.dropdownListItem} onClick={downloadTableCSV}>CSV</div>
|
|
209
|
+
<div id="dropdownListItemJSON" className={classes.dropdownListItem} onClick={downloadTableJson}>JSON</div>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
99
212
|
);
|
|
100
213
|
};
|
|
101
214
|
|
package/src/util/Types.js
CHANGED
|
@@ -8,6 +8,8 @@ export const FORMAT_DATA = 'FORMAT_DATA';
|
|
|
8
8
|
export const FORMAT_BYTES = 'FORMAT_BYTES';
|
|
9
9
|
export const TRANSFORM = 'TRANSFORM';
|
|
10
10
|
export const EXPAND = 'EXPAND';
|
|
11
|
+
export const COMMA = 'COMMA';
|
|
12
|
+
export const CPI = 'CPI';
|
|
11
13
|
|
|
12
14
|
export const cellTypes = {
|
|
13
15
|
CUSTOM_ELEM,
|
|
@@ -17,6 +19,8 @@ export const cellTypes = {
|
|
|
17
19
|
DELETE,
|
|
18
20
|
DEFAULT,
|
|
19
21
|
FORMAT_DATA,
|
|
22
|
+
COMMA,
|
|
23
|
+
CPI,
|
|
20
24
|
};
|
|
21
25
|
|
|
22
26
|
export const cellStyles = {
|