@bento-core/table 1.0.1-ccdihub.9 → 1.0.1-ccdihub.91
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/DefaultThemConfig.js +1 -1
- package/dist/ExtendedView.js +25 -14
- package/dist/TableView.js +79 -7
- package/dist/body/CustomTblBody.js +5 -2
- package/dist/body/DisplayBodyCell.js +17 -3
- package/dist/body/components/CPIModal.js +363 -0
- package/dist/body/components/CPIView.js +117 -0
- package/dist/body/components/ModalStyle.js +121 -0
- package/dist/body/components/assets/CPI_icon.svg +22 -0
- package/dist/body/components/assets/Cart_Icon.svg +3 -0
- package/dist/body/components/assets/Question_Icon.svg +4 -0
- package/dist/header/ActionHeaderCell.js +2 -1
- package/dist/header/CustomCell.js +11 -3
- package/dist/header/CustomTblHeader.js +4 -1
- package/dist/header/components/CheckBoxView.js +3 -2
- package/dist/index.js +6 -0
- package/dist/pagination/CustomPagination.js +11 -2
- package/dist/toolbar/DownloadButtonView.js +173 -7
- package/dist/toolbar/ManageColumnView.js +115 -25
- package/dist/toolbar/assets/Hidden_Column.svg +4 -0
- package/dist/toolbar/assets/View_Columns.svg +6 -0
- package/dist/util/Dataformat.js +41 -1
- package/dist/util/Types.js +22 -2
- package/dist/util/downloadTable.js +196 -0
- package/dist/wrapper/WrapperService.js +36 -0
- package/dist/wrapper/components/AddFiles.js +63 -0
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogAlertView.js +35 -0
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogController.js +36 -0
- package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +43 -0
- package/dist/wrapper/components/CPIFilesView/CPIFilesView.js +178 -0
- package/dist/wrapper/components/ReduxAddFile.js +27 -0
- package/dist/wrapper/components/Snackbar/Snackbar.js +40 -0
- package/dist/wrapper/components/Snackbar/SnackbarRedux.js +16 -0
- package/dist/wrapper/components/Snackbar/SuccessOutlined.js +17 -0
- package/dist/wrapper/components/TextFieldView.js +37 -0
- package/dist/wrapper/components/TooltipView.js +40 -0
- package/package.json +11 -1
- package/src/DefaultThemConfig.js +1 -1
- package/src/ExtendedView.js +36 -21
- package/src/TableView.js +124 -52
- package/src/body/CustomTblBody.js +3 -0
- package/src/body/DisplayBodyCell.js +16 -0
- package/src/body/components/CPIModal.js +414 -0
- package/src/body/components/CPIView.js +135 -0
- package/src/body/components/ModalStyle.js +115 -0
- package/src/body/components/assets/CPI_icon.svg +22 -0
- package/src/body/components/assets/Cart_Icon.svg +3 -0
- package/src/body/components/assets/Question_Icon.svg +4 -0
- package/src/header/ActionHeaderCell.js +1 -1
- package/src/header/CustomCell.js +13 -0
- package/src/header/CustomTblHeader.js +1 -0
- package/src/header/components/CheckBoxView.js +2 -1
- package/src/index.js +1 -0
- package/src/pagination/CustomPagination.js +4 -1
- package/src/toolbar/DownloadButtonView.js +181 -10
- package/src/toolbar/ManageColumnView.js +114 -27
- package/src/toolbar/assets/Hidden_Column.svg +4 -0
- package/src/toolbar/assets/View_Columns.svg +6 -0
- package/src/util/Dataformat.js +25 -0
- package/src/util/Types.js +15 -0
- package/src/util/downloadTable.js +138 -0
- package/src/wrapper/WrapperService.js +25 -0
- package/src/wrapper/components/AddFiles.js +62 -0
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogAlertView.js +37 -0
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogController.js +32 -0
- package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +57 -0
- package/src/wrapper/components/CPIFilesView/CPIFilesView.js +190 -0
- package/src/wrapper/components/ReduxAddFile.js +20 -0
- package/src/wrapper/components/Snackbar/Snackbar.js +43 -0
- package/src/wrapper/components/Snackbar/SnackbarRedux.js +11 -0
- package/src/wrapper/components/Snackbar/SuccessOutlined.js +10 -0
- package/src/wrapper/components/TextFieldView.js +32 -0
- package/src/wrapper/components/TooltipView.js +35 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import ToolTip from '@bento-core/tool-tip';
|
|
3
|
+
import { Button } from '@material-ui/core';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import gql from 'graphql-tag';
|
|
6
|
+
import { getFilesID } from '../../WrapperService';
|
|
7
|
+
import AddToCartDialogView from '../AddToCartDialog/AddToCartDialogView';
|
|
8
|
+
|
|
9
|
+
const customTooltip = {
|
|
10
|
+
border: '#03A383 1px solid',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const customArrow = {
|
|
14
|
+
'&::before': {
|
|
15
|
+
border: '#03A383 1px solid',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const iconStyle = {
|
|
20
|
+
paddingRight: '20px',
|
|
21
|
+
paddingBottom: '20px',
|
|
22
|
+
paddingLeft: '5px',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const ToolTipView = (props) => {
|
|
26
|
+
const {
|
|
27
|
+
section,
|
|
28
|
+
tooltipCofig,
|
|
29
|
+
} = props;
|
|
30
|
+
const {
|
|
31
|
+
icon,
|
|
32
|
+
src,
|
|
33
|
+
alt,
|
|
34
|
+
arrow = false,
|
|
35
|
+
tooltipText,
|
|
36
|
+
} = tooltipCofig;
|
|
37
|
+
return (
|
|
38
|
+
<ToolTip
|
|
39
|
+
placement="top"
|
|
40
|
+
title={tooltipText || `${tooltipCofig[section]}`}
|
|
41
|
+
arrow={arrow}
|
|
42
|
+
classes={{
|
|
43
|
+
tooltip: customTooltip,
|
|
44
|
+
arrow: customArrow,
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<img src={icon || src} alt={alt} style={iconStyle} />
|
|
48
|
+
</ToolTip>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// const checkDuplicate = (cartFiles, ids) => {
|
|
53
|
+
// const newIds = [];
|
|
54
|
+
// for (let i = 0; i < ids.length; i += 1) {
|
|
55
|
+
// if (!cartFiles.includes(ids[i])) {
|
|
56
|
+
// newIds.push(ids[i]);
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
// return newIds;
|
|
60
|
+
// };
|
|
61
|
+
|
|
62
|
+
const checkDuplicate = (cartFiles, ids) => (ids.filter((id) => !cartFiles[id]));
|
|
63
|
+
|
|
64
|
+
const addFileQuery = gql`
|
|
65
|
+
query search (
|
|
66
|
+
$participant_ids: [String],
|
|
67
|
+
){
|
|
68
|
+
fileIDsFromList (
|
|
69
|
+
participant_ids: $participant_ids,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const CPIFilesComponent = (props) => {
|
|
75
|
+
const {
|
|
76
|
+
title,
|
|
77
|
+
btnType,
|
|
78
|
+
clsName,
|
|
79
|
+
section,
|
|
80
|
+
addFiles,
|
|
81
|
+
setAlterDisplay,
|
|
82
|
+
setOpenSnackbar,
|
|
83
|
+
client,
|
|
84
|
+
tooltipCofig,
|
|
85
|
+
cartFiles,
|
|
86
|
+
participantIds,
|
|
87
|
+
buttonStyle,
|
|
88
|
+
rowID,
|
|
89
|
+
} = props;
|
|
90
|
+
/**
|
|
91
|
+
* conditionally display dialog view
|
|
92
|
+
*/
|
|
93
|
+
const [openAddDialog, setOpen] = useState(false);
|
|
94
|
+
const toggleOpen = () => setOpen(!openAddDialog);
|
|
95
|
+
const [addFilesId, setAddFilesId] = useState([]);
|
|
96
|
+
// const [isDataloading, setIsDataloading] = useState(false);
|
|
97
|
+
const responseKeys = ['fileIDsFromList'];
|
|
98
|
+
|
|
99
|
+
const cartFilesDict = {};
|
|
100
|
+
cartFiles.forEach((file) => { cartFilesDict[file] = true; });
|
|
101
|
+
|
|
102
|
+
// const backdropCls = {
|
|
103
|
+
// width: '100%',
|
|
104
|
+
// zIndex: 99999,
|
|
105
|
+
// background: 'rgba(0, 0, 0, 0.1)',
|
|
106
|
+
// };
|
|
107
|
+
/**
|
|
108
|
+
* verify and set file ids
|
|
109
|
+
*/
|
|
110
|
+
const addAllFiles = () => {
|
|
111
|
+
let toAdd = [];
|
|
112
|
+
if (btnType === 'ADD_ALL_FILES') {
|
|
113
|
+
participantIds.forEach((e) => {
|
|
114
|
+
if (e.data_type === 'internal' && e.p_id) {
|
|
115
|
+
toAdd = toAdd.concat(e.p_id);
|
|
116
|
+
}
|
|
117
|
+
toAdd = toAdd.concat(rowID);
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
toAdd = participantIds.concat(rowID);
|
|
121
|
+
}
|
|
122
|
+
const fileIds = getFilesID({
|
|
123
|
+
client,
|
|
124
|
+
variables: { participant_ids: toAdd },
|
|
125
|
+
query: addFileQuery,
|
|
126
|
+
});
|
|
127
|
+
const upperLimit = 200000;
|
|
128
|
+
const cartCount = cartFiles.length;
|
|
129
|
+
if (cartCount < upperLimit) {
|
|
130
|
+
fileIds().then((response) => {
|
|
131
|
+
const idsInitial = response[responseKeys[0]] || [];
|
|
132
|
+
const ids = [...new Set(idsInitial)];
|
|
133
|
+
const fileCount = ids.length;
|
|
134
|
+
if (fileCount <= upperLimit && cartCount < upperLimit) {
|
|
135
|
+
if (cartCount + ids.length <= upperLimit) {
|
|
136
|
+
setOpen(true);
|
|
137
|
+
setAddFilesId(ids);
|
|
138
|
+
} else {
|
|
139
|
+
const newIds = checkDuplicate(cartFiles, ids);
|
|
140
|
+
if (cartCount + newIds.length <= upperLimit) {
|
|
141
|
+
setOpen(true);
|
|
142
|
+
setAddFilesId(newIds);
|
|
143
|
+
} else {
|
|
144
|
+
setAlterDisplay(true);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
setAlterDisplay(true);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
setAlterDisplay(true);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* use wrapper service to add files to cart
|
|
158
|
+
*/
|
|
159
|
+
const addFilesToCart = () => {
|
|
160
|
+
addFiles(addFilesId);
|
|
161
|
+
toggleOpen();
|
|
162
|
+
setOpenSnackbar(true);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<>
|
|
167
|
+
<Button
|
|
168
|
+
onClick={addAllFiles}
|
|
169
|
+
className={clsx(clsName, `${clsName}_${section}`)}
|
|
170
|
+
disableRipple
|
|
171
|
+
style={buttonStyle}
|
|
172
|
+
disabled={btnType === 'ADD_SELECTED_FILES' && participantIds.length === 0}
|
|
173
|
+
>
|
|
174
|
+
{title}
|
|
175
|
+
</Button>
|
|
176
|
+
{tooltipCofig && (<ToolTipView {...props} />)}
|
|
177
|
+
<AddToCartDialogView
|
|
178
|
+
open={openAddDialog}
|
|
179
|
+
onYesClick={addFilesToCart}
|
|
180
|
+
onNoClick={toggleOpen}
|
|
181
|
+
dialogText={btnType === 'ADD_SELECTED_FILES' ? 'Are you sure to add selected files' : 'Are you sure to add All Files'}
|
|
182
|
+
/>
|
|
183
|
+
{/* <Backdrop className={backdropCls} style={backdropCls} open={isDataloading}>
|
|
184
|
+
<CircularProgress color="inherit" />
|
|
185
|
+
</Backdrop> */}
|
|
186
|
+
</>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export default CPIFilesComponent;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { onAddCartFiles } from '@bento-core/cart';
|
|
4
|
+
import AddFiles from './AddFiles';
|
|
5
|
+
|
|
6
|
+
const AddFilesRedux = (props) => <AddFiles {...props} />;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* create query variable with actie filters
|
|
10
|
+
*/
|
|
11
|
+
const mapStateToProps = (state) => ({
|
|
12
|
+
count: state.cartReducer && state.cartReducer.count,
|
|
13
|
+
cartFiles: state.cartReducer && state.cartReducer.filesId,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
17
|
+
addFiles: (files) => { dispatch(onAddCartFiles(files)); },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export default connect(mapStateToProps, mapDispatchToProps)(AddFilesRedux);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Snackbar } from '@material-ui/core';
|
|
3
|
+
import SuccessOutlinedIcon from './SuccessOutlined';
|
|
4
|
+
|
|
5
|
+
const SnackbarView = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
count,
|
|
8
|
+
open,
|
|
9
|
+
onClose,
|
|
10
|
+
} = props;
|
|
11
|
+
|
|
12
|
+
if (open) {
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
onClose();
|
|
15
|
+
}, 3000);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<Snackbar
|
|
21
|
+
className="snackBar"
|
|
22
|
+
open={open}
|
|
23
|
+
autoHideDuration={3000}
|
|
24
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
25
|
+
message={(
|
|
26
|
+
<div className="snackBarMessage">
|
|
27
|
+
<span className="snackBarMessageIcon">
|
|
28
|
+
<SuccessOutlinedIcon />
|
|
29
|
+
{' '}
|
|
30
|
+
</span>
|
|
31
|
+
<span className="snackBarText">
|
|
32
|
+
{count}
|
|
33
|
+
{' '}
|
|
34
|
+
File(s) successfully added to your cart
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
)}
|
|
38
|
+
/>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default SnackbarView;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import SnackbarView from './Snackbar';
|
|
4
|
+
|
|
5
|
+
const ReduxSnackbar = ((props) => <SnackbarView {...props} />);
|
|
6
|
+
|
|
7
|
+
const mapStateToProps = (state) => ({
|
|
8
|
+
count: state.cartReducer.count,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export default connect(mapStateToProps, null)(ReduxSnackbar);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createSvgIcon } from '@bento-core/util';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @ignore - internal component.
|
|
6
|
+
*/
|
|
7
|
+
export default createSvgIcon(
|
|
8
|
+
<path d="M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z" />,
|
|
9
|
+
'SuccessOutlined',
|
|
10
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
CartContext,
|
|
4
|
+
onCommentChange,
|
|
5
|
+
} from '@bento-core/cart';
|
|
6
|
+
|
|
7
|
+
const TextFieldView = ({
|
|
8
|
+
clsName,
|
|
9
|
+
placeholder,
|
|
10
|
+
}) => {
|
|
11
|
+
const [text, setText] = useState('');
|
|
12
|
+
const cartContext = useContext(CartContext);
|
|
13
|
+
const { context } = cartContext;
|
|
14
|
+
const {
|
|
15
|
+
dispatch,
|
|
16
|
+
} = context;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
dispatch(onCommentChange(text));
|
|
19
|
+
}, [text]);
|
|
20
|
+
return (
|
|
21
|
+
<textarea
|
|
22
|
+
onChange={(e) => {
|
|
23
|
+
setText(`${e.target.value}`);
|
|
24
|
+
}}
|
|
25
|
+
className={clsName}
|
|
26
|
+
placeholder={placeholder}
|
|
27
|
+
id="multiline-user-coments"
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default TextFieldView;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ToolTip from '@bento-core/tool-tip';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* customize tooltips based on tooltipContent
|
|
6
|
+
* defined on dashboardTabData (tooltipContent)
|
|
7
|
+
*/
|
|
8
|
+
const ToolTipView = (props) => {
|
|
9
|
+
const {
|
|
10
|
+
section,
|
|
11
|
+
tooltipCofig,
|
|
12
|
+
classes,
|
|
13
|
+
} = props;
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
icon,
|
|
17
|
+
alt,
|
|
18
|
+
arrow = false,
|
|
19
|
+
clsName,
|
|
20
|
+
} = tooltipCofig;
|
|
21
|
+
return (
|
|
22
|
+
<ToolTip
|
|
23
|
+
title={tooltipCofig[section]}
|
|
24
|
+
arrow={arrow}
|
|
25
|
+
classes={{
|
|
26
|
+
tooltip: classes.customTooltip,
|
|
27
|
+
arrow: classes.customArrow,
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
{icon && (<img src={icon} alt={alt} className={clsName} />)}
|
|
31
|
+
</ToolTip>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default ToolTipView;
|