@bento-core/table 1.0.0-c3dc.3 → 1.0.0-c3dc.31
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 +254 -51
- 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 +243 -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 +257 -73
- package/src/util/Types.js +4 -0
- package/src/util/downloadTable.js +51 -17
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.convertToCSV = convertToCSV;
|
|
7
7
|
exports.createFileName = createFileName;
|
|
8
|
-
exports.
|
|
8
|
+
exports.downloadData = downloadData;
|
|
9
9
|
var _Dataformat = require("./Dataformat");
|
|
10
10
|
var _Types = require("./Types");
|
|
11
11
|
function createFileName(fileName) {
|
|
@@ -32,7 +32,7 @@ function createFileName(fileName) {
|
|
|
32
32
|
if (seconds < 10) {
|
|
33
33
|
seconds = "0".concat(seconds);
|
|
34
34
|
}
|
|
35
|
-
return "".concat(fileName, " ").concat(todaysDate, " ").concat(hours, "-").concat(minutes, "-").concat(seconds
|
|
35
|
+
return "".concat(fileName, " ").concat(todaysDate, " ").concat(hours, "-").concat(minutes, "-").concat(seconds);
|
|
36
36
|
}
|
|
37
37
|
function convertToCSV(jsonse, keysToInclude, header) {
|
|
38
38
|
const objArray = jsonse;
|
|
@@ -51,8 +51,11 @@ function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
51
51
|
} else {
|
|
52
52
|
line += entry[keyName] !== null ? "\"".concat(entry[keyName], "\"") : ' ';
|
|
53
53
|
}
|
|
54
|
+
} else if (keyName === 'participant') {
|
|
55
|
+
line += entry[keyName].participant_id;
|
|
54
56
|
} else {
|
|
55
|
-
|
|
57
|
+
const newLine = entry[keyName] !== null ? String(entry[keyName]).replace(/"/g, '""') : '';
|
|
58
|
+
line += "\"".concat(newLine, "\"");
|
|
56
59
|
}
|
|
57
60
|
return line;
|
|
58
61
|
});
|
|
@@ -66,49 +69,81 @@ function convertToCSV(jsonse, keysToInclude, header) {
|
|
|
66
69
|
});
|
|
67
70
|
return str;
|
|
68
71
|
}
|
|
69
|
-
function
|
|
72
|
+
function downloadData(tableData, table, downloadFileName) {
|
|
73
|
+
let format = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'csv';
|
|
70
74
|
const {
|
|
71
75
|
columns = []
|
|
72
76
|
} = table;
|
|
73
77
|
const filterColumns = columns.filter(_ref => {
|
|
74
78
|
let {
|
|
75
|
-
cellType
|
|
79
|
+
cellType,
|
|
80
|
+
doNotDownload
|
|
76
81
|
} = _ref;
|
|
77
|
-
return !_Types.actionCellTypes.includes(cellType);
|
|
82
|
+
return !_Types.actionCellTypes.includes(cellType) && !doNotDownload;
|
|
78
83
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
} = _ref3;
|
|
90
|
-
return dataField;
|
|
91
|
-
});
|
|
92
|
-
const headers = columns.filter(_ref4 => {
|
|
93
|
-
let {
|
|
94
|
-
dataField
|
|
95
|
-
} = _ref4;
|
|
96
|
-
return dataField;
|
|
97
|
-
}).map(_ref5 => {
|
|
98
|
-
let {
|
|
99
|
-
header,
|
|
100
|
-
downloadHeader
|
|
101
|
-
} = _ref5;
|
|
102
|
-
return downloadHeader || header;
|
|
84
|
+
let formatDataVal = (0, _Dataformat.formatColumnValues)(filterColumns, tableData);
|
|
85
|
+
formatDataVal = formatDataVal.map(item => {
|
|
86
|
+
const updatedItem = {};
|
|
87
|
+
filterColumns.forEach(_ref2 => {
|
|
88
|
+
let {
|
|
89
|
+
dataField
|
|
90
|
+
} = _ref2;
|
|
91
|
+
updatedItem[dataField] = item[dataField];
|
|
92
|
+
});
|
|
93
|
+
return updatedItem;
|
|
103
94
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
95
|
+
let fileContent;
|
|
96
|
+
let fileType;
|
|
97
|
+
if (format === 'json') {
|
|
98
|
+
filterColumns.forEach(column => {
|
|
99
|
+
const mapData = data => {
|
|
100
|
+
var _dataObject$column$da;
|
|
101
|
+
const dataObject = data;
|
|
102
|
+
if (dataObject !== null && dataObject !== void 0 && (_dataObject$column$da = dataObject[column.dataField]) !== null && _dataObject$column$da !== void 0 && _dataObject$column$da.participant_id) {
|
|
103
|
+
var _dataObject$column$da2;
|
|
104
|
+
dataObject[column.dataField] = dataObject === null || dataObject === void 0 ? void 0 : (_dataObject$column$da2 = dataObject[column.dataField]) === null || _dataObject$column$da2 === void 0 ? void 0 : _dataObject$column$da2.participant_id;
|
|
105
|
+
}
|
|
106
|
+
return dataObject;
|
|
107
|
+
};
|
|
108
|
+
formatDataVal = formatDataVal.map(mapData);
|
|
109
|
+
formatDataVal = JSON.parse(JSON.stringify(formatDataVal).split("\"".concat(column.dataField, "\":")).join("\"".concat(column.header, "\":")));
|
|
110
|
+
});
|
|
111
|
+
fileContent = JSON.stringify(formatDataVal);
|
|
112
|
+
fileType = 'application/json';
|
|
113
|
+
} else {
|
|
114
|
+
const jsonse = JSON.stringify(formatDataVal);
|
|
115
|
+
const keysToInclude = filterColumns.filter(_ref3 => {
|
|
116
|
+
let {
|
|
117
|
+
dataField
|
|
118
|
+
} = _ref3;
|
|
119
|
+
return dataField;
|
|
120
|
+
}).map(_ref4 => {
|
|
121
|
+
let {
|
|
122
|
+
dataField
|
|
123
|
+
} = _ref4;
|
|
124
|
+
return dataField;
|
|
125
|
+
});
|
|
126
|
+
const headers = filterColumns.filter(_ref5 => {
|
|
127
|
+
let {
|
|
128
|
+
dataField
|
|
129
|
+
} = _ref5;
|
|
130
|
+
return dataField;
|
|
131
|
+
}).map(_ref6 => {
|
|
132
|
+
let {
|
|
133
|
+
header,
|
|
134
|
+
downloadHeader
|
|
135
|
+
} = _ref6;
|
|
136
|
+
return downloadHeader || header;
|
|
137
|
+
});
|
|
138
|
+
fileContent = convertToCSV(jsonse, keysToInclude, headers);
|
|
139
|
+
fileType = 'text/csv';
|
|
140
|
+
}
|
|
141
|
+
const exportData = new Blob([fileContent], {
|
|
142
|
+
type: fileType
|
|
107
143
|
});
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
tempLink
|
|
111
|
-
tempLink.setAttribute('href', JsonURL);
|
|
144
|
+
const fileURL = window.URL.createObjectURL(exportData);
|
|
145
|
+
const tempLink = document.createElement('a');
|
|
146
|
+
tempLink.setAttribute('href', fileURL);
|
|
112
147
|
tempLink.setAttribute('download', createFileName(downloadFileName || ''));
|
|
113
148
|
document.body.appendChild(tempLink);
|
|
114
149
|
tempLink.click();
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bento-core/table",
|
|
3
|
-
"version": "1.0.0-c3dc.
|
|
3
|
+
"version": "1.0.0-c3dc.31",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"lint": "eslint src"
|
|
9
9
|
},
|
package/src/ExtendedView.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ThemeProvider,
|
|
4
|
-
Toolbar,
|
|
5
4
|
createTheme,
|
|
6
5
|
} from '@material-ui/core';
|
|
7
6
|
import CustomPagination from './pagination/CustomPagination';
|
|
@@ -39,45 +38,47 @@ const ExtendedView = ({
|
|
|
39
38
|
return (
|
|
40
39
|
<ThemeProvider theme={themeConfig}>
|
|
41
40
|
{(numSelected === 0 && (download || manageViewColumns)) && (
|
|
42
|
-
|
|
43
|
-
<DownloadButton
|
|
44
|
-
count={table.totalRowCount || 0}
|
|
45
|
-
queryVariables={queryVariables}
|
|
46
|
-
table={table}
|
|
47
|
-
buttonConfig={downloadButtonConfig}
|
|
48
|
-
/>
|
|
41
|
+
|
|
49
42
|
<ManageColumnView
|
|
50
43
|
table={table}
|
|
51
44
|
manageViewColumns={manageViewColumns}
|
|
52
45
|
onColumnViewChange={onColumnViewChange}
|
|
53
46
|
/>
|
|
54
|
-
|
|
47
|
+
|
|
55
48
|
)}
|
|
56
49
|
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
50
|
+
(pagination) && (
|
|
51
|
+
<div className="downloadArea" style={(table.paginationCustomStyle && table.paginationCustomStyle.topPagination) ? table.paginationCustomStyle.topPagination : downloadAreaStyle}>
|
|
52
|
+
{
|
|
53
|
+
(table.showSearchBox) && (
|
|
54
|
+
<table.SearchBox />
|
|
55
|
+
)
|
|
56
|
+
}
|
|
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
|
+
queryVariables={queryVariables}
|
|
67
|
+
table={table}
|
|
68
|
+
/>
|
|
69
|
+
{table.showDownloadIcon !== false
|
|
70
|
+
&& (
|
|
71
|
+
<DownloadButton
|
|
72
|
+
count={table.totalRowCount || 0}
|
|
73
|
+
queryVariables={queryVariables}
|
|
74
|
+
table={table}
|
|
75
|
+
buttonConfig={downloadButtonConfig}
|
|
76
|
+
/>
|
|
77
|
+
)}
|
|
78
|
+
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
81
82
|
</ThemeProvider>
|
|
82
83
|
);
|
|
83
84
|
};
|
package/src/TableView.js
CHANGED
|
@@ -10,9 +10,9 @@ import TableHeader from './header/CustomTblHeader';
|
|
|
10
10
|
import CustomPagination from './pagination/CustomPagination';
|
|
11
11
|
import CustomTableBody from './body/CustomTblBody';
|
|
12
12
|
import CustomToolbar from './toolbar/CustomToolbar';
|
|
13
|
+
import DownloadButton from './toolbar/DownloadButtonView';
|
|
13
14
|
import DisplayErrMsg from './errMsg/DisplayErrMsg';
|
|
14
15
|
import ExtendedView from './ExtendedView';
|
|
15
|
-
// import DownloadButton from './toolbar/DownloadButtonView';
|
|
16
16
|
|
|
17
17
|
const CustomTableContainer = (props) => {
|
|
18
18
|
const { children, customTheme } = props;
|
|
@@ -29,7 +29,6 @@ const CustomTableContainer = (props) => {
|
|
|
29
29
|
const downloadAreaStyle = {
|
|
30
30
|
display: 'flex',
|
|
31
31
|
borderTop: '1px solid #8A7F7C',
|
|
32
|
-
borderBottom: '1px solid #8A7F7C',
|
|
33
32
|
paddingRight: '41px',
|
|
34
33
|
};
|
|
35
34
|
|
|
@@ -95,7 +94,7 @@ const TableView = ({
|
|
|
95
94
|
table={table}
|
|
96
95
|
/>
|
|
97
96
|
)}
|
|
98
|
-
<div className="downloadArea" style={table.paginationAPIField === 'filesInList' ? cartDownloadAreaStyle : downloadAreaStyle}>
|
|
97
|
+
<div className="downloadArea" style={table.paginationAPIField === 'filesInList' ? cartDownloadAreaStyle : (table.paginationCustomStyle && table.paginationCustomStyle.bottomPagination) ? table.paginationCustomStyle.bottomPagination : downloadAreaStyle}>
|
|
99
98
|
<CustomPagination
|
|
100
99
|
customTheme={themeConfig.tblPgn}
|
|
101
100
|
rowsPerPageOptions={[10, 25, 50, 100]}
|
|
@@ -106,11 +105,15 @@ const TableView = ({
|
|
|
106
105
|
onPageChange={onPageChange}
|
|
107
106
|
onRowsPerPageChange={onRowsPerPageChange}
|
|
108
107
|
/>
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
{table.showDownloadIcon !== false
|
|
109
|
+
&& (
|
|
110
|
+
<DownloadButton
|
|
111
|
+
count={table.totalRowCount || 0}
|
|
112
|
+
queryVariables={queryVariables}
|
|
113
|
+
table={table}
|
|
114
|
+
buttonConfig={table.extendedViewConfig.downloadButtonConfig}
|
|
115
|
+
/>
|
|
116
|
+
)}
|
|
114
117
|
</div>
|
|
115
118
|
</>
|
|
116
119
|
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<svg width="23" height="21" viewBox="0 0 23 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_12066_12050)">
|
|
3
|
+
<path d="M19.0973 13.2173C16.943 13.2173 15.1948 14.9585 15.1948 17.1042C15.1948 19.2499 16.943 20.9912 19.0973 20.9912C21.2516 20.9912 22.9998 19.2499 22.9998 17.1042C22.9998 14.9585 21.2516 13.2173 19.0973 13.2173Z" fill="#006A8F"/>
|
|
4
|
+
<path d="M19.389 18.8806L21.5609 16.4447C21.7905 16.1897 21.6051 15.7939 21.2696 15.7939H16.9256C16.5813 15.7939 16.4047 16.1985 16.6343 16.4447L18.8062 18.8806C18.9652 19.0565 19.2389 19.0565 19.3978 18.8806H19.389Z" fill="white"/>
|
|
5
|
+
<g clip-path="url(#clip1_12066_12050)">
|
|
6
|
+
<path d="M5.995 10.579C6.49826 10.579 6.96621 10.4734 7.4165 10.3239C6.15393 9.06641 5.36813 7.31641 5.36813 5.39933C5.36813 4.19455 5.67715 3.06013 6.21573 2.07521C6.1451 2.07521 6.07446 2.05762 6.00383 2.05762C3.63761 2.05762 1.72168 3.96591 1.72168 6.32269C1.72168 8.67948 3.63761 10.5878 6.00383 10.5878L5.995 10.579Z" fill="#006A8F"/>
|
|
7
|
+
<path d="M16.1916 9.19803C18.3053 7.09283 18.3053 3.67963 16.1916 1.57443C14.078 -0.530773 10.6511 -0.530773 8.53751 1.57443C6.42388 3.67963 6.42388 7.09283 8.53751 9.19803C10.6511 11.3032 14.078 11.3032 16.1916 9.19803Z" fill="#006A8F"/>
|
|
8
|
+
<path d="M13.6409 17.1395C13.6409 14.6948 15.3272 12.6458 17.5963 12.0742C17.1637 11.7312 16.6869 11.4498 16.166 11.2388C15.0712 11.9511 13.7645 12.3732 12.3518 12.3732C10.9391 12.3732 9.64124 11.9511 8.5376 11.2388C6.3303 12.1445 4.77637 14.2991 4.77637 16.8229V17.6848C4.77637 18.3267 5.22666 18.8807 5.86236 19.0038C7.67234 19.3468 9.86197 19.6194 12.3518 19.6194C13.0052 19.6194 13.6232 19.593 14.2324 19.5579C13.8528 18.8368 13.6409 18.0189 13.6409 17.1483V17.1395Z" fill="#006A8F"/>
|
|
9
|
+
<path d="M2.63109 11.0981C1.07716 11.8896 0 13.4901 0 15.3544V16.0404C0 16.5504 0.361996 16.9901 0.85643 17.0868C1.56276 17.2187 2.34856 17.3419 3.19616 17.4298V16.823C3.19616 15.0378 3.83186 13.3758 4.90019 12.0567C4.07025 11.8984 3.29328 11.573 2.62227 11.1069L2.63109 11.0981Z" fill="#006A8F"/>
|
|
10
|
+
<path d="M15.1948 17.1043C15.1948 19.25 16.943 20.9912 19.0973 20.9912C21.2516 20.9912 22.9998 19.25 22.9998 17.1043C22.9998 14.9585 21.2516 13.2173 19.0973 13.2173C16.943 13.2173 15.1948 14.9585 15.1948 17.1043Z" fill="#006A8F"/>
|
|
11
|
+
<path d="M20.8808 16.8143L18.4351 14.651C18.1791 14.4224 17.7817 14.607 17.7817 14.9412L17.7817 19.2678C17.7817 19.6108 18.1879 19.7867 18.4351 19.558L20.8808 17.3947C21.0574 17.2364 21.0574 16.9638 20.8808 16.8055L20.8808 16.8143Z" fill="white"/>
|
|
12
|
+
</g>
|
|
13
|
+
</g>
|
|
14
|
+
<defs>
|
|
15
|
+
<clipPath id="clip0_12066_12050">
|
|
16
|
+
<rect width="23" height="21" fill="white"/>
|
|
17
|
+
</clipPath>
|
|
18
|
+
<clipPath id="clip1_12066_12050">
|
|
19
|
+
<rect width="23" height="21" fill="white"/>
|
|
20
|
+
</clipPath>
|
|
21
|
+
</defs>
|
|
22
|
+
</svg>
|
|
@@ -25,7 +25,11 @@ const CustomTableBody = ({
|
|
|
25
25
|
}) => {
|
|
26
26
|
const { columns } = table;
|
|
27
27
|
const displayColunms = columns.filter((col) => col.display);
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
const MuiTableRow = { ...defaultTheme().MuiTableRow, ...customTheme.MuiTableRow };
|
|
30
|
+
const updatedTheme = { overrides: { ...defaultTheme(), ...customTheme, MuiTableRow } };
|
|
31
|
+
|
|
32
|
+
const themeConfig = createTheme(updatedTheme);
|
|
29
33
|
|
|
30
34
|
return (
|
|
31
35
|
<ThemeProvider theme={themeConfig}>
|
|
@@ -50,6 +54,7 @@ const CustomTableBody = ({
|
|
|
50
54
|
<DisplayCell
|
|
51
55
|
column={column}
|
|
52
56
|
row={row}
|
|
57
|
+
themeConfig={themeConfig}
|
|
53
58
|
/>
|
|
54
59
|
);
|
|
55
60
|
})
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { cellTypes } from '../util/Types';
|
|
7
7
|
import CustomLinkView from './components/CustomLinkView';
|
|
8
8
|
import DataFormatView from './components/DataFormatView';
|
|
9
|
+
import CPIView from './components/CPIView';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Custom Column reneder
|
|
@@ -29,8 +30,12 @@ const CustomComponent = ({
|
|
|
29
30
|
const ViewCell = ({
|
|
30
31
|
column,
|
|
31
32
|
row,
|
|
33
|
+
themeConfig,
|
|
32
34
|
}) => {
|
|
33
35
|
const { cellType } = column;
|
|
36
|
+
function isNumeric(value) {
|
|
37
|
+
return /^-?\d+\.?\d*$/.test(value);
|
|
38
|
+
}
|
|
34
39
|
switch (cellType) {
|
|
35
40
|
case cellTypes.FORMAT_DATA:
|
|
36
41
|
return (
|
|
@@ -53,6 +58,22 @@ const ViewCell = ({
|
|
|
53
58
|
column={column}
|
|
54
59
|
/>
|
|
55
60
|
);
|
|
61
|
+
case cellTypes.COMMA:
|
|
62
|
+
return (
|
|
63
|
+
<Typography>
|
|
64
|
+
{isNumeric(row[column.dataField])
|
|
65
|
+
? Number(row[column.dataField]).toLocaleString()
|
|
66
|
+
: row[column.dataField]}
|
|
67
|
+
</Typography>
|
|
68
|
+
);
|
|
69
|
+
case cellTypes.CPI:
|
|
70
|
+
return (
|
|
71
|
+
<CPIView
|
|
72
|
+
row={row}
|
|
73
|
+
column={column}
|
|
74
|
+
themeConfig={themeConfig}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
56
77
|
default:
|
|
57
78
|
return (
|
|
58
79
|
<Typography>
|
|
@@ -65,11 +86,13 @@ const ViewCell = ({
|
|
|
65
86
|
const DisplayCell = ({
|
|
66
87
|
row,
|
|
67
88
|
column,
|
|
89
|
+
themeConfig,
|
|
68
90
|
}) => (
|
|
69
91
|
<TableCell className={column.dataField}>
|
|
70
92
|
<ViewCell
|
|
71
93
|
row={row}
|
|
72
94
|
column={column}
|
|
95
|
+
themeConfig={themeConfig}
|
|
73
96
|
/>
|
|
74
97
|
</TableCell>
|
|
75
98
|
);
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Modal,
|
|
5
|
+
Typography,
|
|
6
|
+
IconButton,
|
|
7
|
+
Paper,
|
|
8
|
+
Table,
|
|
9
|
+
TableContainer,
|
|
10
|
+
ThemeProvider,
|
|
11
|
+
TableHead,
|
|
12
|
+
TableRow,
|
|
13
|
+
TableCell,
|
|
14
|
+
TableBody,
|
|
15
|
+
} from '@material-ui/core';
|
|
16
|
+
// import CustomTableBody from '../../body/CustomTblBody';
|
|
17
|
+
import CloseIcon from '@material-ui/icons/Close';
|
|
18
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
19
|
+
import styles from './ModalStyle';
|
|
20
|
+
// import TableHeader from '../../header/CustomTblHeader';
|
|
21
|
+
import HeaderCell from '../../header/CustomCell';
|
|
22
|
+
|
|
23
|
+
const CustomTableContainer = (props) => {
|
|
24
|
+
const { children, themeConfig, className } = props;
|
|
25
|
+
const tableStyle = {
|
|
26
|
+
height: '510px',
|
|
27
|
+
overflowX: 'hidden',
|
|
28
|
+
};
|
|
29
|
+
return (
|
|
30
|
+
<ThemeProvider theme={themeConfig}>
|
|
31
|
+
<TableContainer className={className} id="tableContainer" component={Paper} style={tableStyle}>
|
|
32
|
+
{children}
|
|
33
|
+
</TableContainer>
|
|
34
|
+
</ThemeProvider>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const CPIModal = ({
|
|
39
|
+
classes,
|
|
40
|
+
open,
|
|
41
|
+
onClose,
|
|
42
|
+
row,
|
|
43
|
+
themeConfig,
|
|
44
|
+
}) => {
|
|
45
|
+
const [sortBy, setSortBy] = useState('associated_id');
|
|
46
|
+
const [sortOrder, setSortOrder] = useState('asc');
|
|
47
|
+
const [data, setData] = useState(() => {
|
|
48
|
+
const result = row.cpi_data;
|
|
49
|
+
return result;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const sortingData = (column, newOrder) => {
|
|
53
|
+
const sortedData = data.sort((a, b) => a[column].localeCompare(b[column]));
|
|
54
|
+
|
|
55
|
+
if (newOrder === 'desc') {
|
|
56
|
+
return sortedData.reverse();
|
|
57
|
+
}
|
|
58
|
+
return sortedData;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleSortByColumn = (column, order) => {
|
|
62
|
+
const newOrder = (order === 'asc' && sortBy === column) ? 'desc' : 'asc';
|
|
63
|
+
const newData = sortingData(column, newOrder);
|
|
64
|
+
setData(newData);
|
|
65
|
+
setSortBy(column);
|
|
66
|
+
setSortOrder(newOrder);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const modalBody = {
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
top: '5%',
|
|
72
|
+
left: '25%',
|
|
73
|
+
width: '840px',
|
|
74
|
+
height: '671px',
|
|
75
|
+
background: '#FFFFFF',
|
|
76
|
+
border: '1px solid #505050',
|
|
77
|
+
borderRadius: '40px',
|
|
78
|
+
overflow: 'hidden',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const header = {
|
|
82
|
+
display: 'flex',
|
|
83
|
+
justifyContent: 'center',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
height: '55px',
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const cell = {
|
|
89
|
+
paddingLeft: '3px',
|
|
90
|
+
paddingRight: '5px',
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const cellLast = {
|
|
94
|
+
paddingLeft: '3px',
|
|
95
|
+
paddingRight: '10px',
|
|
96
|
+
wordBreak: 'break-word',
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const footer = {
|
|
100
|
+
display: 'flex',
|
|
101
|
+
justifyContent: 'center',
|
|
102
|
+
alignItems: 'center',
|
|
103
|
+
height: '55px',
|
|
104
|
+
color: '#7D267E',
|
|
105
|
+
fontFamily: 'Nunito',
|
|
106
|
+
fontSize: '16px',
|
|
107
|
+
fontWeight: '400',
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const link = {
|
|
111
|
+
color: '#7D267E',
|
|
112
|
+
fontFamily: 'Nunito',
|
|
113
|
+
fontSize: '16px',
|
|
114
|
+
fontWeight: '700',
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const modalTitle = {
|
|
118
|
+
fontFamily: 'Poppins',
|
|
119
|
+
fontSize: '19px',
|
|
120
|
+
fontWeight: '400',
|
|
121
|
+
lineHeight: '21px',
|
|
122
|
+
letterSpacing: '0.02em',
|
|
123
|
+
textAlign: 'center',
|
|
124
|
+
color: '#000000',
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const closeButton = {
|
|
128
|
+
marginLeft: '769px',
|
|
129
|
+
position: 'absolute',
|
|
130
|
+
backgroundColor: 'transparent',
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const countContainer = {
|
|
134
|
+
display: 'flex',
|
|
135
|
+
justifyContent: 'left',
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
borderTop: '3px solid #939393',
|
|
138
|
+
borderBottom: '3px solid #939393',
|
|
139
|
+
height: '51px',
|
|
140
|
+
paddingLeft: '16px',
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const participantId = row.participant_id;
|
|
144
|
+
const displayColumns = [
|
|
145
|
+
{
|
|
146
|
+
dataField: 'associated_id',
|
|
147
|
+
header: 'Participant ID',
|
|
148
|
+
tooltipText: 'sort',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
dataField: 'repository_of_synonym_id',
|
|
152
|
+
header: 'Name',
|
|
153
|
+
tooltipText: 'sort',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
dataField: 'domain_description',
|
|
157
|
+
header: 'Description',
|
|
158
|
+
tooltipText: 'sort',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
dataField: 'domain_category',
|
|
162
|
+
header: 'Category',
|
|
163
|
+
tooltipText: 'sort',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
dataField: 'data_location',
|
|
167
|
+
header: 'Location',
|
|
168
|
+
tooltipText: 'sort',
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<Modal
|
|
174
|
+
open={open}
|
|
175
|
+
onClose={onClose}
|
|
176
|
+
aria-labelledby={`${row.id}-modal`}
|
|
177
|
+
>
|
|
178
|
+
<Box className={classes.modalBody} style={modalBody}>
|
|
179
|
+
<div className="header" style={header}>
|
|
180
|
+
<Typography id="modal-modal-title" className="modalTitle" style={modalTitle}>
|
|
181
|
+
{`Participant ID ${participantId} : CPI Mappings`}
|
|
182
|
+
</Typography>
|
|
183
|
+
<IconButton
|
|
184
|
+
aria-label="close"
|
|
185
|
+
onClick={onClose}
|
|
186
|
+
className="closeButton"
|
|
187
|
+
style={closeButton}
|
|
188
|
+
>
|
|
189
|
+
<CloseIcon fontSize="small" />
|
|
190
|
+
</IconButton>
|
|
191
|
+
</div>
|
|
192
|
+
<div className="container" style={countContainer}>
|
|
193
|
+
{`${data.length} mapped identifiers`}
|
|
194
|
+
</div>
|
|
195
|
+
<CustomTableContainer
|
|
196
|
+
className={classes.tableContainer}
|
|
197
|
+
themeConfig={themeConfig}
|
|
198
|
+
>
|
|
199
|
+
<Table>
|
|
200
|
+
<TableHead>
|
|
201
|
+
<TableRow>
|
|
202
|
+
{
|
|
203
|
+
displayColumns.map((column) => (
|
|
204
|
+
<HeaderCell
|
|
205
|
+
column={column}
|
|
206
|
+
sortBy={sortBy}
|
|
207
|
+
sortOrder={sortOrder}
|
|
208
|
+
toggleSort={() => handleSortByColumn(column.dataField, sortOrder)}
|
|
209
|
+
style={{ paddingLeft: '3px', paddingRight: '3px', fontWeight: '700' }}
|
|
210
|
+
/>
|
|
211
|
+
))
|
|
212
|
+
}
|
|
213
|
+
</TableRow>
|
|
214
|
+
</TableHead>
|
|
215
|
+
<TableBody>
|
|
216
|
+
{
|
|
217
|
+
data.map((currRow) => (
|
|
218
|
+
<TableRow>
|
|
219
|
+
{
|
|
220
|
+
displayColumns.map((column) => (
|
|
221
|
+
(
|
|
222
|
+
column.dataField !== 'data_location'
|
|
223
|
+
? <TableCell style={cell}>{currRow[column.dataField]}</TableCell>
|
|
224
|
+
: <TableCell style={cellLast}><a href={currRow[column.dataField]} target="_blank" rel="noopener noreferrer">{currRow[column.dataField]}</a></TableCell>
|
|
225
|
+
)
|
|
226
|
+
))
|
|
227
|
+
}
|
|
228
|
+
</TableRow>
|
|
229
|
+
))
|
|
230
|
+
}
|
|
231
|
+
</TableBody>
|
|
232
|
+
</Table>
|
|
233
|
+
</CustomTableContainer>
|
|
234
|
+
<div className="footer" style={footer}>
|
|
235
|
+
To learn more about CPI click
|
|
236
|
+
<a style={link} href="https://participantindex-docs.ccdi.cancer.gov/" target="_blank" rel="noopener noreferrer">here</a>
|
|
237
|
+
</div>
|
|
238
|
+
</Box>
|
|
239
|
+
</Modal>
|
|
240
|
+
);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export default withStyles(styles)(CPIModal);
|