@bento-core/table 1.0.0 → 1.0.1-CDS.1
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 +11 -5
- package/dist/TableView.js +13 -3
- package/dist/body/ActionBodyCell.js +4 -1
- package/dist/body/CustomTblBody.js +6 -2
- package/dist/body/components/CheckBoxView.js +7 -3
- package/dist/body/components/DeleteCellView.js +6 -2
- package/dist/header/ActionHeaderCell.js +3 -1
- package/dist/header/ColumnGrouping.js +52 -0
- package/dist/header/CustomCell.js +3 -2
- package/dist/header/CustomTblHeader.js +10 -3
- package/dist/header/components/DeleteCellView.js +11 -6
- package/dist/header/components/RemoveAllDialog.js +3 -1
- package/dist/toolbar/DownloadButtonView.js +57 -5
- package/dist/toolbar/ManageColumnView.js +7 -8
- package/dist/util/Dataformat.js +41 -1
- package/dist/util/downloadTable.js +109 -0
- package/package.json +7 -2
- package/src/ExtendedView.js +35 -25
- package/src/TableView.js +10 -0
- package/src/body/ActionBodyCell.js +3 -0
- package/src/body/CustomTblBody.js +5 -1
- package/src/body/components/CheckBoxView.js +23 -9
- package/src/body/components/DeleteCellView.js +28 -16
- package/src/header/ActionHeaderCell.js +2 -0
- package/src/header/ColumnGrouping.js +55 -0
- package/src/header/CustomCell.js +2 -1
- package/src/header/CustomTblHeader.js +5 -0
- package/src/header/components/DeleteCellView.js +41 -26
- package/src/header/components/RemoveAllDialog.js +2 -0
- package/src/toolbar/DownloadButtonView.js +57 -3
- package/src/toolbar/ManageColumnView.js +9 -6
- package/src/util/Dataformat.js +25 -0
- package/src/util/downloadTable.js +74 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertToCSV = convertToCSV;
|
|
7
|
+
exports.createFileName = createFileName;
|
|
8
|
+
exports.downloadJson = downloadJson;
|
|
9
|
+
var _Dataformat = require("./Dataformat");
|
|
10
|
+
var _Types = require("./Types");
|
|
11
|
+
function createFileName(fileName) {
|
|
12
|
+
const date = new Date();
|
|
13
|
+
const yyyy = date.getFullYear();
|
|
14
|
+
let dd = date.getDate();
|
|
15
|
+
let mm = date.getMonth() + 1;
|
|
16
|
+
if (dd < 10) {
|
|
17
|
+
dd = "0".concat(dd);
|
|
18
|
+
}
|
|
19
|
+
if (mm < 10) {
|
|
20
|
+
mm = "0".concat(mm);
|
|
21
|
+
}
|
|
22
|
+
const todaysDate = "".concat(yyyy, "-").concat(mm, "-").concat(dd);
|
|
23
|
+
let hours = date.getHours();
|
|
24
|
+
let minutes = date.getMinutes();
|
|
25
|
+
let seconds = date.getSeconds();
|
|
26
|
+
if (hours < 10) {
|
|
27
|
+
hours = "0".concat(hours);
|
|
28
|
+
}
|
|
29
|
+
if (minutes < 10) {
|
|
30
|
+
minutes = "0".concat(minutes);
|
|
31
|
+
}
|
|
32
|
+
if (seconds < 10) {
|
|
33
|
+
seconds = "0".concat(seconds);
|
|
34
|
+
}
|
|
35
|
+
return "".concat(fileName, " ").concat(todaysDate, " ").concat(hours, "-").concat(minutes, "-").concat(seconds, '.csv');
|
|
36
|
+
}
|
|
37
|
+
function convertToCSV(jsonse, keysToInclude, header) {
|
|
38
|
+
const objArray = jsonse;
|
|
39
|
+
// To Do empty object just print headers
|
|
40
|
+
const array = typeof objArray !== 'object' ? JSON.parse(objArray) : objArray;
|
|
41
|
+
let str = header.join(',');
|
|
42
|
+
array.map((entry, index) => {
|
|
43
|
+
let line = '';
|
|
44
|
+
keysToInclude.map(keyName => {
|
|
45
|
+
if (line !== '') line += ',';
|
|
46
|
+
if (keyName === 'file_size') {
|
|
47
|
+
line += entry[keyName] !== null ? "\"".concat((0, _Dataformat.formatBytes)(entry[keyName]), "\"") : ' ';
|
|
48
|
+
} else {
|
|
49
|
+
line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
|
|
50
|
+
}
|
|
51
|
+
return line;
|
|
52
|
+
});
|
|
53
|
+
if (index === 0) {
|
|
54
|
+
// str = header.join(',');
|
|
55
|
+
str += "\r\n".concat(line, "\r\n");
|
|
56
|
+
} else {
|
|
57
|
+
str += "".concat(line, "\r\n");
|
|
58
|
+
}
|
|
59
|
+
return str;
|
|
60
|
+
});
|
|
61
|
+
return str;
|
|
62
|
+
}
|
|
63
|
+
function downloadJson(tableData, table, downloadFileName) {
|
|
64
|
+
const {
|
|
65
|
+
columns = []
|
|
66
|
+
} = table;
|
|
67
|
+
const filterColumns = columns.filter(_ref => {
|
|
68
|
+
let {
|
|
69
|
+
cellType
|
|
70
|
+
} = _ref;
|
|
71
|
+
return !_Types.actionCellTypes.includes(cellType);
|
|
72
|
+
});
|
|
73
|
+
const formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
|
74
|
+
const jsonse = JSON.stringify(formatDataVal);
|
|
75
|
+
const keysToInclude = columns.filter(_ref2 => {
|
|
76
|
+
let {
|
|
77
|
+
dataField
|
|
78
|
+
} = _ref2;
|
|
79
|
+
return dataField;
|
|
80
|
+
}).map(_ref3 => {
|
|
81
|
+
let {
|
|
82
|
+
dataField
|
|
83
|
+
} = _ref3;
|
|
84
|
+
return dataField;
|
|
85
|
+
});
|
|
86
|
+
const headers = columns.filter(_ref4 => {
|
|
87
|
+
let {
|
|
88
|
+
dataField
|
|
89
|
+
} = _ref4;
|
|
90
|
+
return dataField;
|
|
91
|
+
}).map(_ref5 => {
|
|
92
|
+
let {
|
|
93
|
+
header
|
|
94
|
+
} = _ref5;
|
|
95
|
+
return header;
|
|
96
|
+
});
|
|
97
|
+
const csv = convertToCSV(jsonse, keysToInclude, headers);
|
|
98
|
+
const exportData = new Blob([csv], {
|
|
99
|
+
type: 'text/csv'
|
|
100
|
+
});
|
|
101
|
+
const JsonURL = window.URL.createObjectURL(exportData);
|
|
102
|
+
let tempLink = '';
|
|
103
|
+
tempLink = document.createElement('a');
|
|
104
|
+
tempLink.setAttribute('href', JsonURL);
|
|
105
|
+
tempLink.setAttribute('download', createFileName(downloadFileName || ''));
|
|
106
|
+
document.body.appendChild(tempLink);
|
|
107
|
+
tempLink.click();
|
|
108
|
+
document.body.removeChild(tempLink);
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-CDS.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@bento-core/util": "^1.0.0"
|
|
17
|
+
},
|
|
15
18
|
"peerDependencies": {
|
|
19
|
+
"@apollo/client": "^3.6.9",
|
|
16
20
|
"@material-ui/core": "^4.12.4",
|
|
17
21
|
"@material-ui/icons": "^4.9.1",
|
|
22
|
+
"clsx": "^1.2.1",
|
|
18
23
|
"prop-types": "^15.7.2",
|
|
19
24
|
"react": "^17.0.2",
|
|
20
25
|
"react-dom": "^17.0.0",
|
|
@@ -22,5 +27,5 @@
|
|
|
22
27
|
},
|
|
23
28
|
"author": "CTOS Bento Team",
|
|
24
29
|
"license": "ISC",
|
|
25
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "7da350e271a629e43c5cecf1b7c5db44d2270f40"
|
|
26
31
|
}
|
package/src/ExtendedView.js
CHANGED
|
@@ -11,16 +11,19 @@ import DownloadButton from './toolbar/DownloadButtonView';
|
|
|
11
11
|
|
|
12
12
|
const ExtendedView = ({
|
|
13
13
|
table,
|
|
14
|
+
rows,
|
|
14
15
|
onColumnViewChange,
|
|
15
16
|
onRowsPerPageChange,
|
|
16
17
|
onPageChange,
|
|
17
|
-
numSelected = 0,
|
|
18
18
|
customTheme,
|
|
19
|
+
queryVariables,
|
|
20
|
+
server,
|
|
19
21
|
}) => {
|
|
20
22
|
const { extendedViewConfig } = table;
|
|
21
23
|
if (!extendedViewConfig) {
|
|
22
24
|
return null;
|
|
23
25
|
}
|
|
26
|
+
|
|
24
27
|
const {
|
|
25
28
|
download = false,
|
|
26
29
|
manageViewColumns = false,
|
|
@@ -28,34 +31,41 @@ const ExtendedView = ({
|
|
|
28
31
|
} = extendedViewConfig;
|
|
29
32
|
|
|
30
33
|
const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
|
|
34
|
+
|
|
31
35
|
return (
|
|
32
36
|
<ThemeProvider theme={themeConfig}>
|
|
33
|
-
{(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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>
|
|
44
54
|
)}
|
|
45
55
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
}
|
|
59
69
|
</ThemeProvider>
|
|
60
70
|
);
|
|
61
71
|
};
|
package/src/TableView.js
CHANGED
|
@@ -27,6 +27,7 @@ const CustomTableContainer = (props) => {
|
|
|
27
27
|
|
|
28
28
|
const TableView = ({
|
|
29
29
|
tableRows = [],
|
|
30
|
+
totalRows = [],
|
|
30
31
|
table,
|
|
31
32
|
onRowsPerPageChange,
|
|
32
33
|
onPageChange,
|
|
@@ -35,16 +36,23 @@ const TableView = ({
|
|
|
35
36
|
totalRowCount,
|
|
36
37
|
onSortByColumn,
|
|
37
38
|
onColumnViewChange,
|
|
39
|
+
onDeleteRow,
|
|
40
|
+
onDeleteAllFiles,
|
|
38
41
|
themeConfig = {},
|
|
42
|
+
queryVariables,
|
|
43
|
+
server,
|
|
39
44
|
}) => (
|
|
40
45
|
<>
|
|
41
46
|
<ExtendedView
|
|
42
47
|
table={table}
|
|
48
|
+
rows={totalRows}
|
|
49
|
+
server={server}
|
|
43
50
|
onColumnViewChange={onColumnViewChange}
|
|
44
51
|
onRowsPerPageChange={onRowsPerPageChange}
|
|
45
52
|
onPageChange={onPageChange}
|
|
46
53
|
numSelected={table?.selectedRows?.length || 0}
|
|
47
54
|
customTheme={themeConfig.extendedView}
|
|
55
|
+
queryVariables={queryVariables}
|
|
48
56
|
/>
|
|
49
57
|
<CustomToolbar
|
|
50
58
|
numSelected={table?.selectedRows?.length || 0}
|
|
@@ -62,6 +70,7 @@ const TableView = ({
|
|
|
62
70
|
rows={tableRows}
|
|
63
71
|
count={totalRowCount}
|
|
64
72
|
toggleSelectAll={onToggleSelectAll}
|
|
73
|
+
onDeleteAllFiles={onDeleteAllFiles}
|
|
65
74
|
sortByColumn={onSortByColumn}
|
|
66
75
|
/>
|
|
67
76
|
<CustomTableBody
|
|
@@ -69,6 +78,7 @@ const TableView = ({
|
|
|
69
78
|
rows={tableRows}
|
|
70
79
|
table={table}
|
|
71
80
|
onRowSelectChange={onRowSelectChange}
|
|
81
|
+
onDeleteRow={onDeleteRow}
|
|
72
82
|
/>
|
|
73
83
|
</Table>
|
|
74
84
|
</CustomTableContainer>
|
|
@@ -7,6 +7,7 @@ import { cellTypes } from '../util/Types';
|
|
|
7
7
|
const ActionCell = ({
|
|
8
8
|
row,
|
|
9
9
|
onRowSelectChange,
|
|
10
|
+
onDeleteRow,
|
|
10
11
|
column,
|
|
11
12
|
}) => {
|
|
12
13
|
const { cellType } = column;
|
|
@@ -15,6 +16,7 @@ const ActionCell = ({
|
|
|
15
16
|
return (
|
|
16
17
|
<CheckboxView
|
|
17
18
|
row={row}
|
|
19
|
+
column={column}
|
|
18
20
|
onRowSelectChange={onRowSelectChange}
|
|
19
21
|
/>
|
|
20
22
|
);
|
|
@@ -25,6 +27,7 @@ const ActionCell = ({
|
|
|
25
27
|
<DeleteCellView
|
|
26
28
|
row={row}
|
|
27
29
|
column={column}
|
|
30
|
+
onDeleteRow={onDeleteRow}
|
|
28
31
|
/>
|
|
29
32
|
);
|
|
30
33
|
}
|
|
@@ -12,6 +12,7 @@ import DisplayCell from './DisplayBodyCell';
|
|
|
12
12
|
import defaultTheme from './DefaultThemConfig';
|
|
13
13
|
import { actionCellTypes } from '../util/Types';
|
|
14
14
|
import ActionCell from './ActionBodyCell';
|
|
15
|
+
import { formatColumnValues } from '../util/Dataformat';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* 1. Returns cell associated with action (checkbox / delete view)
|
|
@@ -21,16 +22,18 @@ const CustomTableBody = ({
|
|
|
21
22
|
rows = [],
|
|
22
23
|
table,
|
|
23
24
|
onRowSelectChange,
|
|
25
|
+
onDeleteRow,
|
|
24
26
|
customTheme = {},
|
|
25
27
|
}) => {
|
|
26
28
|
const { columns } = table;
|
|
29
|
+
const formatRows = formatColumnValues(columns, rows);
|
|
27
30
|
const displayColunms = columns.filter((col) => col.display);
|
|
28
31
|
const themeConfig = createTheme({ overrides: { ...defaultTheme(), ...customTheme } });
|
|
29
32
|
|
|
30
33
|
return (
|
|
31
34
|
<ThemeProvider theme={themeConfig}>
|
|
32
35
|
<TableBody>
|
|
33
|
-
{
|
|
36
|
+
{formatRows
|
|
34
37
|
.map((row) => (
|
|
35
38
|
<TableRow>
|
|
36
39
|
{
|
|
@@ -43,6 +46,7 @@ const CustomTableBody = ({
|
|
|
43
46
|
row={row}
|
|
44
47
|
column={column}
|
|
45
48
|
onRowSelectChange={onRowSelectChange}
|
|
49
|
+
onDeleteRow={onDeleteRow}
|
|
46
50
|
/>
|
|
47
51
|
);
|
|
48
52
|
}
|
|
@@ -7,14 +7,28 @@ import {
|
|
|
7
7
|
const CheckboxView = ({
|
|
8
8
|
row,
|
|
9
9
|
onRowSelectChange,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
10
|
+
column,
|
|
11
|
+
}) => {
|
|
12
|
+
const { customCellRender } = column;
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{
|
|
16
|
+
customCellRender ? (
|
|
17
|
+
<>
|
|
18
|
+
{customCellRender(row, onRowSelectChange)}
|
|
19
|
+
</>
|
|
20
|
+
) : (
|
|
21
|
+
<TableCell padding="checkbox">
|
|
22
|
+
<Checkbox
|
|
23
|
+
disableRipple
|
|
24
|
+
onClick={(event) => onRowSelectChange(event, row)}
|
|
25
|
+
checked={row.isChecked}
|
|
26
|
+
/>
|
|
27
|
+
</TableCell>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
19
33
|
|
|
20
34
|
export default CheckboxView;
|
|
@@ -10,22 +10,34 @@ import {
|
|
|
10
10
|
const DeleteCellView = ({
|
|
11
11
|
column,
|
|
12
12
|
row,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
className="del_row_btn"
|
|
21
|
-
onClick={() => column.cellEventHandler(row)}
|
|
13
|
+
onDeleteRow,
|
|
14
|
+
}) => {
|
|
15
|
+
const { customCellRender } = column;
|
|
16
|
+
return (
|
|
17
|
+
<TableCell
|
|
18
|
+
scope="col"
|
|
19
|
+
className="delete_row"
|
|
22
20
|
>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
{
|
|
22
|
+
customCellRender ? (
|
|
23
|
+
<>
|
|
24
|
+
{customCellRender(row, onDeleteRow)}
|
|
25
|
+
</>
|
|
26
|
+
) : (
|
|
27
|
+
<IconButton
|
|
28
|
+
disableRipple
|
|
29
|
+
className="del_row_btn"
|
|
30
|
+
onClick={() => column.cellEventHandler(row)}
|
|
31
|
+
>
|
|
32
|
+
<DeleteOutlineIcon
|
|
33
|
+
className="del_row_btn_icon"
|
|
34
|
+
fontSize="small"
|
|
35
|
+
/>
|
|
36
|
+
</IconButton>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
</TableCell>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
30
42
|
|
|
31
43
|
export default DeleteCellView;
|
|
@@ -6,6 +6,7 @@ import DeleteCellView from './components/DeleteCellView';
|
|
|
6
6
|
const ActionHeaderCell = ({
|
|
7
7
|
includeSelectedIds,
|
|
8
8
|
toggleSelectAll,
|
|
9
|
+
onDeleteAllFiles,
|
|
9
10
|
Ids,
|
|
10
11
|
count,
|
|
11
12
|
rows,
|
|
@@ -29,6 +30,7 @@ const ActionHeaderCell = ({
|
|
|
29
30
|
rows={rows}
|
|
30
31
|
count={count}
|
|
31
32
|
column={column}
|
|
33
|
+
onDeleteAllFiles={onDeleteAllFiles}
|
|
32
34
|
/>
|
|
33
35
|
);
|
|
34
36
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TableRow,
|
|
4
|
+
TableCell,
|
|
5
|
+
Typography,
|
|
6
|
+
} from '@material-ui/core';
|
|
7
|
+
|
|
8
|
+
const ColumnGrouping = ({
|
|
9
|
+
columnGroups = [],
|
|
10
|
+
columns = [],
|
|
11
|
+
}) => {
|
|
12
|
+
if (columnGroups.length === 0) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const getColSpan = (indexes = [0, 0]) => {
|
|
17
|
+
const startIndex = indexes[0];
|
|
18
|
+
const endIndex = indexes[1];
|
|
19
|
+
const displayGroupCols = columns
|
|
20
|
+
.map((col, index) => ((startIndex <= index && index <= endIndex) && col.display))
|
|
21
|
+
.filter((item) => item);
|
|
22
|
+
return displayGroupCols.length;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<TableRow className="column_grouping">
|
|
27
|
+
{columnGroups.map((group) => {
|
|
28
|
+
const {
|
|
29
|
+
title,
|
|
30
|
+
customViewRender,
|
|
31
|
+
clsName,
|
|
32
|
+
columnIndexes,
|
|
33
|
+
} = group;
|
|
34
|
+
if (!columnIndexes) {
|
|
35
|
+
return (
|
|
36
|
+
<Typography variant="subtitle1" color="error" size="sm">
|
|
37
|
+
Missing columnIndexes [startColIndex, endColIndex]
|
|
38
|
+
</Typography>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
const colSpan = getColSpan(columnIndexes);
|
|
42
|
+
if (colSpan > 0) {
|
|
43
|
+
return (
|
|
44
|
+
<TableCell colSpan={colSpan} className={clsName}>
|
|
45
|
+
{customViewRender ? customViewRender() : title}
|
|
46
|
+
</TableCell>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
})}
|
|
51
|
+
</TableRow>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default ColumnGrouping;
|
package/src/header/CustomCell.js
CHANGED
|
@@ -43,13 +43,14 @@ const CustomHeaderCell = ({
|
|
|
43
43
|
}
|
|
44
44
|
// return default view
|
|
45
45
|
return <>{children}</>;
|
|
46
|
-
}, []);
|
|
46
|
+
}, [components, tooltipText]);
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
<TableCell
|
|
50
50
|
scope="col"
|
|
51
51
|
active={sortBy === dataField}
|
|
52
52
|
direction={sortOrder}
|
|
53
|
+
className={dataField}
|
|
53
54
|
>
|
|
54
55
|
<Tooltip>
|
|
55
56
|
<TableSortLabel
|
|
@@ -12,6 +12,7 @@ import HeaderCell from './CustomCell';
|
|
|
12
12
|
import defaultTheme from './DefaultThemConfig';
|
|
13
13
|
import { actionCellTypes } from '../util/Types';
|
|
14
14
|
import ActionHeaderCell from './ActionHeaderCell';
|
|
15
|
+
import ColumnGrouping from './ColumnGrouping';
|
|
15
16
|
|
|
16
17
|
const CustomTableHeader = ({
|
|
17
18
|
table,
|
|
@@ -21,12 +22,14 @@ const CustomTableHeader = ({
|
|
|
21
22
|
components = {},
|
|
22
23
|
customTheme = {},
|
|
23
24
|
count,
|
|
25
|
+
onDeleteAllFiles,
|
|
24
26
|
}) => {
|
|
25
27
|
const {
|
|
26
28
|
columns,
|
|
27
29
|
selectedRows = [],
|
|
28
30
|
sortBy,
|
|
29
31
|
sortOrder,
|
|
32
|
+
columnGroups,
|
|
30
33
|
} = table;
|
|
31
34
|
const Ids = rows.map((row) => row[table.dataKey]);
|
|
32
35
|
const includeSelectedIds = Ids.some((id) => selectedRows.includes(id));
|
|
@@ -40,6 +43,7 @@ const CustomTableHeader = ({
|
|
|
40
43
|
return (
|
|
41
44
|
<ThemeProvider theme={themeConfig}>
|
|
42
45
|
<TableHead>
|
|
46
|
+
<ColumnGrouping columnGroups={columnGroups} columns={columns} />
|
|
43
47
|
<TableRow>
|
|
44
48
|
{
|
|
45
49
|
displayColunms.map((column) => {
|
|
@@ -51,6 +55,7 @@ const CustomTableHeader = ({
|
|
|
51
55
|
<ActionHeaderCell
|
|
52
56
|
includeSelectedIds={includeSelectedIds}
|
|
53
57
|
toggleSelectAll={toggleSelectAll}
|
|
58
|
+
onDeleteAllFiles={onDeleteAllFiles}
|
|
54
59
|
Ids={Ids}
|
|
55
60
|
rows={rows}
|
|
56
61
|
count={count}
|
|
@@ -25,37 +25,52 @@ const TooltipContent = () => (
|
|
|
25
25
|
const DeleteCellView = ({
|
|
26
26
|
column,
|
|
27
27
|
count,
|
|
28
|
+
onDeleteAllFiles,
|
|
28
29
|
}) => {
|
|
29
30
|
const [displayDialog, setDisplay] = useState(false);
|
|
30
31
|
const toggleDialogDisplay = () => setDisplay(!displayDialog);
|
|
32
|
+
const { customColHeaderRender } = column;
|
|
31
33
|
return (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<Typography className="del_all_row_text">
|
|
37
|
-
Remove
|
|
38
|
-
</Typography>
|
|
39
|
-
<Tooltip
|
|
40
|
-
id="del_all_row_tooltip"
|
|
41
|
-
className="del_all_row_tooltip"
|
|
42
|
-
title={TooltipContent()}
|
|
43
|
-
renderComponent={TooltipContent()}
|
|
34
|
+
<>
|
|
35
|
+
<TableCell
|
|
36
|
+
scope="col"
|
|
37
|
+
className="del_all_row"
|
|
44
38
|
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
{
|
|
40
|
+
customColHeaderRender ? (
|
|
41
|
+
<>
|
|
42
|
+
{customColHeaderRender(toggleDialogDisplay)}
|
|
43
|
+
</>
|
|
44
|
+
) : (
|
|
45
|
+
<>
|
|
46
|
+
<Typography className="del_all_row_text">
|
|
47
|
+
Remove
|
|
48
|
+
</Typography>
|
|
49
|
+
<Tooltip
|
|
50
|
+
id="del_all_row_tooltip"
|
|
51
|
+
className="del_all_row_tooltip"
|
|
52
|
+
title={TooltipContent()}
|
|
53
|
+
renderComponent={TooltipContent()}
|
|
54
|
+
>
|
|
55
|
+
<IconButton aria-label="help" className="del_all_row_btn">
|
|
56
|
+
<ArrowDropDownIcon
|
|
57
|
+
className="del_all_row_btn_icon"
|
|
58
|
+
onClick={toggleDialogDisplay}
|
|
59
|
+
/>
|
|
60
|
+
</IconButton>
|
|
61
|
+
</Tooltip>
|
|
62
|
+
</>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
<RemoveAllDialogView
|
|
66
|
+
open={displayDialog}
|
|
67
|
+
removeAllFiles={column.headerEventHandler}
|
|
68
|
+
count={count}
|
|
69
|
+
toggleDisplay={toggleDialogDisplay}
|
|
70
|
+
onDeleteAllFiles={onDeleteAllFiles}
|
|
71
|
+
/>
|
|
72
|
+
</TableCell>
|
|
73
|
+
</>
|
|
59
74
|
);
|
|
60
75
|
};
|
|
61
76
|
|