@bento-core/table 1.0.1-ccdihub.90 → 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.
Files changed (51) hide show
  1. package/dist/DefaultThemConfig.js +1 -1
  2. package/dist/ExtendedView.js +6 -4
  3. package/dist/TableView.js +11 -6
  4. package/dist/body/CustomTblBody.js +4 -2
  5. package/dist/body/DisplayBodyCell.js +8 -4
  6. package/dist/body/components/CPIModal.js +154 -7
  7. package/dist/body/components/CPIView.js +4 -2
  8. package/dist/body/components/assets/Cart_Icon.svg +3 -0
  9. package/dist/body/components/assets/Question_Icon.svg +4 -0
  10. package/dist/toolbar/DownloadButtonView.js +11 -7
  11. package/dist/toolbar/ManageColumnView.js +110 -28
  12. package/dist/toolbar/assets/Hidden_Column.svg +4 -0
  13. package/dist/toolbar/assets/View_Columns.svg +6 -0
  14. package/dist/wrapper/WrapperService.js +36 -0
  15. package/dist/wrapper/components/AddFiles.js +63 -0
  16. package/dist/wrapper/components/AddToCartDialog/AddToCartDialogAlertView.js +35 -0
  17. package/dist/wrapper/components/AddToCartDialog/AddToCartDialogController.js +36 -0
  18. package/dist/wrapper/components/AddToCartDialog/AddToCartDialogView.js +43 -0
  19. package/dist/wrapper/components/CPIFilesView/CPIFilesView.js +178 -0
  20. package/dist/wrapper/components/ReduxAddFile.js +27 -0
  21. package/dist/wrapper/components/Snackbar/Snackbar.js +40 -0
  22. package/dist/wrapper/components/Snackbar/SnackbarRedux.js +16 -0
  23. package/dist/wrapper/components/Snackbar/SuccessOutlined.js +17 -0
  24. package/dist/wrapper/components/TextFieldView.js +37 -0
  25. package/dist/wrapper/components/TooltipView.js +40 -0
  26. package/package.json +8 -2
  27. package/src/DefaultThemConfig.js +1 -1
  28. package/src/ExtendedView.js +7 -5
  29. package/src/TableView.js +10 -5
  30. package/src/body/CustomTblBody.js +2 -0
  31. package/src/body/DisplayBodyCell.js +4 -0
  32. package/src/body/components/CPIModal.js +163 -1
  33. package/src/body/components/CPIView.js +2 -0
  34. package/src/body/components/assets/Cart_Icon.svg +3 -0
  35. package/src/body/components/assets/Question_Icon.svg +4 -0
  36. package/src/toolbar/DownloadButtonView.js +8 -5
  37. package/src/toolbar/ManageColumnView.js +113 -26
  38. package/src/toolbar/assets/Hidden_Column.svg +4 -0
  39. package/src/toolbar/assets/View_Columns.svg +6 -0
  40. package/src/wrapper/WrapperService.js +25 -0
  41. package/src/wrapper/components/AddFiles.js +62 -0
  42. package/src/wrapper/components/AddToCartDialog/AddToCartDialogAlertView.js +37 -0
  43. package/src/wrapper/components/AddToCartDialog/AddToCartDialogController.js +32 -0
  44. package/src/wrapper/components/AddToCartDialog/AddToCartDialogView.js +57 -0
  45. package/src/wrapper/components/CPIFilesView/CPIFilesView.js +190 -0
  46. package/src/wrapper/components/ReduxAddFile.js +20 -0
  47. package/src/wrapper/components/Snackbar/Snackbar.js +43 -0
  48. package/src/wrapper/components/Snackbar/SnackbarRedux.js +11 -0
  49. package/src/wrapper/components/Snackbar/SuccessOutlined.js +10 -0
  50. package/src/wrapper/components/TextFieldView.js +32 -0
  51. package/src/wrapper/components/TooltipView.js +35 -0
@@ -0,0 +1,62 @@
1
+ import React, { useState } from 'react';
2
+ import { useApolloClient } from '@apollo/client';
3
+ import CPIFilesView from './CPIFilesView/CPIFilesView';
4
+ import SnackbarView from './Snackbar/Snackbar';
5
+ import AlertView from './AddToCartDialog/AddToCartDialogAlertView';
6
+
7
+ export const btnTypes = {
8
+ ADD_ALL_FILES: 'ADD_ALL_FILES',
9
+ ADD_SELECTED_FILES: 'ADD_SELECTED_FILES',
10
+ DOWNLOAD_MANIFEST: 'DOWNLOAD_MANIFEST',
11
+ };
12
+ /**
13
+ * customize button based on configuration
14
+ * refer config table (wrapper component config)
15
+ */
16
+ const AddFilesView = (props) => {
17
+ const {
18
+ count,
19
+ alertMessage,
20
+ cartFiles,
21
+ buttonStyle,
22
+ } = props;
23
+ /**
24
+ * snackbar state
25
+ */
26
+ const [openSnackbar, setOpenSnackbar] = useState(false);
27
+
28
+ /**
29
+ * conditionally display max file Alter/Error dialog view
30
+ */
31
+ const [displayAlter, setAlterDisplay] = useState(false);
32
+ /**
33
+ * acess bento app client via ApolloProvider
34
+ */
35
+ const client = useApolloClient();
36
+ return (
37
+ <>
38
+ <CPIFilesView
39
+ {...props}
40
+ client={client}
41
+ setAlterDisplay={setAlterDisplay}
42
+ setOpenSnackbar={setOpenSnackbar}
43
+ cartFiles={cartFiles}
44
+ buttonStyle={buttonStyle}
45
+ />
46
+ <SnackbarView
47
+ open={openSnackbar}
48
+ count={count}
49
+ onClose={() => setOpenSnackbar(false)}
50
+ />
51
+ {(displayAlter) && (
52
+ <AlertView
53
+ alertMessage={alertMessage}
54
+ open={displayAlter}
55
+ onClose={() => setAlterDisplay(false)}
56
+ />
57
+ )}
58
+ </>
59
+ );
60
+ };
61
+
62
+ export default AddFilesView;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import {
3
+ Dialog, DialogContent, DialogContentText,
4
+ } from '@material-ui/core';
5
+
6
+ function AddToCartDialogAlertView(props) {
7
+ const {
8
+ open,
9
+ onClose,
10
+ alertMessage,
11
+ } = props;
12
+ const closeAlertModelTimer = 4000;
13
+
14
+ const AlertDialog = (
15
+ <>
16
+ <Dialog
17
+ open={open}
18
+ aria-labelledby="alert-dialog-title"
19
+ aria-describedby="alert-dialog-description"
20
+ >
21
+ <DialogContent className="alter-content">
22
+ <DialogContentText id="alert-dialog-description">
23
+ {alertMessage}
24
+ </DialogContentText>
25
+ </DialogContent>
26
+ </Dialog>
27
+ </>
28
+ );
29
+
30
+ if (open) {
31
+ // close the Dialog after 3 seconds.
32
+ setTimeout(() => { onClose(); }, closeAlertModelTimer);
33
+ }
34
+ return AlertDialog;
35
+ }
36
+
37
+ export default AddToCartDialogAlertView;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import Dialog from './AddToCartDialogView';
3
+ import Alert from './AddToCartDialogAlertView';
4
+
5
+ const AddToCartDialogController = (props) => {
6
+ const [open, setOpen] = React.useState(false);
7
+
8
+ const handleClose = () => {
9
+ setOpen(false);
10
+ };
11
+
12
+ const {
13
+ cartWillFull = false,
14
+ numberOfFilesSelected,
15
+ onYesClick,
16
+ onNoClick,
17
+ } = props;
18
+
19
+ if (cartWillFull) {
20
+ return <Alert open={open} onClose={handleClose} />;
21
+ }
22
+ return (
23
+ <Dialog
24
+ open={open}
25
+ numberOfFilesSelected={numberOfFilesSelected}
26
+ onYesClick={onYesClick}
27
+ onNoClick={onNoClick}
28
+ />
29
+ );
30
+ };
31
+
32
+ export default AddToCartDialogController;
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import {
3
+ Dialog, DialogActions, DialogContent, DialogContentText, Button,
4
+ } from '@material-ui/core';
5
+ import Alert from './AddToCartDialogAlertView';
6
+
7
+ function AddToCartDialogView(props) {
8
+ const {
9
+ open,
10
+ numberOfFilesSelected,
11
+ onYesClick,
12
+ onNoClick,
13
+ cartWillFull = false,
14
+ alertMessage,
15
+ dialogText,
16
+ } = props;
17
+
18
+ if (cartWillFull) {
19
+ return (
20
+ <Alert
21
+ alertMessage={alertMessage}
22
+ open={open}
23
+ onClose={() => onNoClick()}
24
+ />
25
+ );
26
+ }
27
+
28
+ return (
29
+ <>
30
+ <Dialog
31
+ open={open}
32
+ aria-labelledby="alert-dialog-title"
33
+ aria-describedby="alert-dialog-description"
34
+ >
35
+ <DialogContent>
36
+ <DialogContentText id="alert-dialog-description">
37
+ {dialogText}
38
+ {' '}
39
+ {numberOfFilesSelected}
40
+ {' '}
41
+ to cart
42
+ </DialogContentText>
43
+ </DialogContent>
44
+ <DialogActions>
45
+ <Button className="yesBtn" onClick={() => onYesClick()}>
46
+ Yes
47
+ </Button>
48
+ <Button className="noBtn" onClick={() => onNoClick()}>
49
+ No
50
+ </Button>
51
+ </DialogActions>
52
+ </Dialog>
53
+ </>
54
+ );
55
+ }
56
+
57
+ export default AddToCartDialogView;
@@ -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;