@bento-core/paginated-table 0.2.0
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/babel.config.json +20 -0
- package/dist/index.js +104 -0
- package/dist/table/ClientController.js +64 -0
- package/dist/table/ContextProvider.js +31 -0
- package/dist/table/PaginatedTable.js +190 -0
- package/dist/table/README.md +253 -0
- package/dist/table/ServerController.js +42 -0
- package/dist/table/TableService.js +103 -0
- package/dist/table/state/Actions.js +57 -0
- package/dist/table/state/Reducer.js +53 -0
- package/dist/wrapper/Wrapper.js +167 -0
- package/dist/wrapper/WrapperService.js +36 -0
- package/dist/wrapper/components/AddAllFiles/AddAllView.js +88 -0
- package/dist/wrapper/components/AddFiles.js +65 -0
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +68 -0
- package/dist/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +62 -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 +42 -0
- package/dist/wrapper/components/ButtonView.js +22 -0
- package/dist/wrapper/components/DownloadManifestBtn.js +71 -0
- package/dist/wrapper/components/ReduxAddFile.js +26 -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 +34 -0
- package/dist/wrapper/components/TooltipView.js +40 -0
- package/package.json +28 -0
- package/src/index.js +18 -0
- package/src/table/ClientController.js +64 -0
- package/src/table/ContextProvider.js +27 -0
- package/src/table/PaginatedTable.js +185 -0
- package/src/table/README.md +253 -0
- package/src/table/ServerController.js +40 -0
- package/src/table/TableService.js +80 -0
- package/src/table/state/Actions.js +50 -0
- package/src/table/state/Reducer.js +49 -0
- package/src/wrapper/Wrapper.js +163 -0
- package/src/wrapper/WrapperService.js +25 -0
- package/src/wrapper/components/AddAllFiles/AddAllView.js +88 -0
- package/src/wrapper/components/AddFiles.js +75 -0
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesController.js +69 -0
- package/src/wrapper/components/AddSelectedFiles/AddSelectedFilesView.js +65 -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 +56 -0
- package/src/wrapper/components/ButtonView.js +24 -0
- package/src/wrapper/components/DownloadManifestBtn.js +64 -0
- package/src/wrapper/components/ReduxAddFile.js +19 -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 +31 -0
- package/src/wrapper/components/TooltipView.js +35 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Container,
|
|
4
|
+
createTheme,
|
|
5
|
+
Link,
|
|
6
|
+
ThemeProvider,
|
|
7
|
+
} from '@material-ui/core';
|
|
8
|
+
import ButtonView from './components/ButtonView';
|
|
9
|
+
import TextFieldView from './components/TextFieldView';
|
|
10
|
+
|
|
11
|
+
export const types = {
|
|
12
|
+
BUTTON: 'BUTTON',
|
|
13
|
+
TABLE_DOWNLOAD: 'TABLE_DOWNLOAD',
|
|
14
|
+
TABLE_VIEW_COLUMN: 'TABLE_VIEW_COLUMN',
|
|
15
|
+
TEXT_INPUT: 'TEXT_INPUT',
|
|
16
|
+
CUSTOM_ELEM: 'CUSTEM_ELEM',
|
|
17
|
+
LINK: 'LINK',
|
|
18
|
+
ICON: 'ICON',
|
|
19
|
+
TEXT: 'TEXT',
|
|
20
|
+
CONTRAINER: 'CONTRAINER',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* configure Link based on configuration
|
|
25
|
+
* refer config table (wrapper component config)
|
|
26
|
+
*/
|
|
27
|
+
export const LinkComponent = (props) => {
|
|
28
|
+
const { url, clsName, title } = props;
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<Link href={url} className={clsName}>
|
|
32
|
+
{title}
|
|
33
|
+
</Link>
|
|
34
|
+
</>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const Img = ({ src, alt, clsName }) => <img src={src} alt={alt} className={clsName} />;
|
|
39
|
+
|
|
40
|
+
const Text = ({
|
|
41
|
+
text,
|
|
42
|
+
clsName,
|
|
43
|
+
tag,
|
|
44
|
+
Component,
|
|
45
|
+
}) => (
|
|
46
|
+
<span className={clsName} type={tag}>
|
|
47
|
+
{text}
|
|
48
|
+
{ Component && <Component /> }
|
|
49
|
+
</span>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param {*}
|
|
55
|
+
* @returns custom component based on configuration
|
|
56
|
+
*/
|
|
57
|
+
export const ViewComponent = (props) => {
|
|
58
|
+
const { type, customViewElem } = props;
|
|
59
|
+
switch (type) {
|
|
60
|
+
case types.BUTTON:
|
|
61
|
+
return (<ButtonView {...props} />);
|
|
62
|
+
case types.LINK:
|
|
63
|
+
return (<LinkComponent {...props} />);
|
|
64
|
+
case types.ICON:
|
|
65
|
+
return <Img {...props} />;
|
|
66
|
+
case types.TEXT:
|
|
67
|
+
return <Text {...props} />;
|
|
68
|
+
case types.TEXT_INPUT:
|
|
69
|
+
return <TextFieldView {...props} />;
|
|
70
|
+
case types.CUSTOM_ELEM:
|
|
71
|
+
return customViewElem();
|
|
72
|
+
default:
|
|
73
|
+
return <></>;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const defaultTheme = {
|
|
78
|
+
override: {
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* creates header and footer components of table
|
|
84
|
+
*/
|
|
85
|
+
const CustomLayout = (props) => {
|
|
86
|
+
const {
|
|
87
|
+
children,
|
|
88
|
+
configs,
|
|
89
|
+
customTheme = {},
|
|
90
|
+
} = props;
|
|
91
|
+
/**
|
|
92
|
+
* return when configuration is empty
|
|
93
|
+
*/
|
|
94
|
+
if (configs.length === 0) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* override default style configuration (please refer to class name table to override styles)
|
|
99
|
+
* 1. props -> {configs, customTheme, section, classes, selectedRows}
|
|
100
|
+
* 2. item -> Component cofiguration defined on cofiguration (refer config table)
|
|
101
|
+
* (attrs - title, eventHandler, clsName, tooltipCofig, conditional)
|
|
102
|
+
*/
|
|
103
|
+
const themeConfig = createTheme({ overrides: { ...defaultTheme, ...customTheme } });
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
{
|
|
107
|
+
configs.map((container) => {
|
|
108
|
+
/**
|
|
109
|
+
* return child/table component
|
|
110
|
+
*/
|
|
111
|
+
if (container.paginatedTable) {
|
|
112
|
+
return <> {children} </>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* return other wrapper components
|
|
116
|
+
*/
|
|
117
|
+
return (
|
|
118
|
+
<ThemeProvider theme={themeConfig}>
|
|
119
|
+
<Container
|
|
120
|
+
maxWidth={container.size}
|
|
121
|
+
className={container.clsName}
|
|
122
|
+
>
|
|
123
|
+
{container.items.map((item) => (
|
|
124
|
+
<ViewComponent
|
|
125
|
+
{...item}
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
))}
|
|
129
|
+
</Container>
|
|
130
|
+
</ThemeProvider>
|
|
131
|
+
)})
|
|
132
|
+
}
|
|
133
|
+
</>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const CustomWrapper = (props) => {
|
|
138
|
+
const {
|
|
139
|
+
children,
|
|
140
|
+
wrapConfig = [],
|
|
141
|
+
customTheme,
|
|
142
|
+
section,
|
|
143
|
+
classes,
|
|
144
|
+
activeFilters,
|
|
145
|
+
tblDispatch,
|
|
146
|
+
} = props;
|
|
147
|
+
return (
|
|
148
|
+
<>
|
|
149
|
+
<CustomLayout
|
|
150
|
+
configs={wrapConfig}
|
|
151
|
+
customTheme={customTheme}
|
|
152
|
+
section={section}
|
|
153
|
+
classes={classes}
|
|
154
|
+
activeFilters={activeFilters}
|
|
155
|
+
tblDispatch={tblDispatch}
|
|
156
|
+
>
|
|
157
|
+
{children}
|
|
158
|
+
</CustomLayout>
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export default CustomWrapper;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* query varibales to fetch all the selected files id
|
|
3
|
+
*/
|
|
4
|
+
export const getQueryVariables = (variables) => {
|
|
5
|
+
const queryVariables = { ...variables };
|
|
6
|
+
queryVariables.first = 100000;
|
|
7
|
+
return queryVariables;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getFilesID = ({
|
|
11
|
+
client,
|
|
12
|
+
variables,
|
|
13
|
+
query,
|
|
14
|
+
}) => {
|
|
15
|
+
const queryVariables = getQueryVariables(variables);
|
|
16
|
+
return async function getFileIDs() {
|
|
17
|
+
const fetchResult = await client
|
|
18
|
+
.query({
|
|
19
|
+
query,
|
|
20
|
+
variables: queryVariables,
|
|
21
|
+
})
|
|
22
|
+
.then((response) => response.data);
|
|
23
|
+
return fetchResult;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button } from '@material-ui/core';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { getFilesID } from '../../WrapperService';
|
|
5
|
+
import AddToCartDialogView from '../AddToCartDialog/AddToCartDialogView';
|
|
6
|
+
|
|
7
|
+
const AddAllFilesComponent = (props) => {
|
|
8
|
+
const {
|
|
9
|
+
title,
|
|
10
|
+
clsName,
|
|
11
|
+
section,
|
|
12
|
+
addFileQuery,
|
|
13
|
+
responseKeys,
|
|
14
|
+
activeFilters,
|
|
15
|
+
addFiles,
|
|
16
|
+
setAlterDisplay,
|
|
17
|
+
setOpenSnackbar,
|
|
18
|
+
client,
|
|
19
|
+
} = props;
|
|
20
|
+
/**
|
|
21
|
+
* conditionally display dialog view
|
|
22
|
+
*/
|
|
23
|
+
const [openAddDialog, setOpen] = useState(false);
|
|
24
|
+
const toggleOpen = () => setOpen(!openAddDialog);
|
|
25
|
+
const [addFilesId, setAddFilesId] = useState([]);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* verify and set file ids
|
|
29
|
+
*/
|
|
30
|
+
const addAllFiles = () => {
|
|
31
|
+
const fileIds = getFilesID({
|
|
32
|
+
client,
|
|
33
|
+
variables: activeFilters,
|
|
34
|
+
query: addFileQuery,
|
|
35
|
+
});
|
|
36
|
+
fileIds().then((response) => {
|
|
37
|
+
const data = response[responseKeys[0]];
|
|
38
|
+
if (data && data.length > 0) {
|
|
39
|
+
const isArray = Array.isArray(data[0][responseKeys[1]]);
|
|
40
|
+
const ids = data.reduce((acc, id) => {
|
|
41
|
+
if (id && id[responseKeys[1]]) {
|
|
42
|
+
// if object convert to array
|
|
43
|
+
const items = isArray ? id[responseKeys[1]] : [id[responseKeys[1]]];
|
|
44
|
+
acc.push(...items);
|
|
45
|
+
}
|
|
46
|
+
return acc;
|
|
47
|
+
}, []);
|
|
48
|
+
if (ids.length > 1000) {
|
|
49
|
+
setAlterDisplay(true);
|
|
50
|
+
} else {
|
|
51
|
+
setOpen(true);
|
|
52
|
+
setAddFilesId(ids);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
setOpen(true);
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* use wrapper service to add files to cart
|
|
63
|
+
*/
|
|
64
|
+
const addFilesToCart = () => {
|
|
65
|
+
addFiles(addFilesId);
|
|
66
|
+
toggleOpen();
|
|
67
|
+
setOpenSnackbar(true);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
<Button
|
|
73
|
+
onClick={addAllFiles}
|
|
74
|
+
className={clsx(clsName, `${clsName}_${section}`)}
|
|
75
|
+
disableRipple
|
|
76
|
+
>
|
|
77
|
+
{title}
|
|
78
|
+
</Button>
|
|
79
|
+
<AddToCartDialogView
|
|
80
|
+
open={openAddDialog}
|
|
81
|
+
onYesClick={addFilesToCart}
|
|
82
|
+
onNoClick={toggleOpen}
|
|
83
|
+
/>
|
|
84
|
+
</>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default AddAllFilesComponent;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useApolloClient } from '@apollo/client';
|
|
3
|
+
import AddAllFilesView from './AddAllFiles/AddAllView';
|
|
4
|
+
import AddSelectedFilesView from './AddSelectedFiles/AddSelectedFilesController';
|
|
5
|
+
import SnackbarView from './Snackbar/Snackbar';
|
|
6
|
+
import AlertView from './AddToCartDialog/AddToCartDialogAlertView';
|
|
7
|
+
|
|
8
|
+
export const btnTypes = {
|
|
9
|
+
ADD_ALL_FILES: 'ADD_ALL_FILES',
|
|
10
|
+
ADD_SELECTED_FILES: 'ADD_SELECTED_FILES',
|
|
11
|
+
DOWNLOAD_MANIFEST: 'DOWNLOAD_MANIFEST',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* customize button based on configuration
|
|
15
|
+
* refer config table (wrapper component config)
|
|
16
|
+
*/
|
|
17
|
+
const AddFilesView = (props) => {
|
|
18
|
+
const {
|
|
19
|
+
btnType,
|
|
20
|
+
count,
|
|
21
|
+
alertMessage,
|
|
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
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{
|
|
40
|
+
(btnTypes.ADD_SELECTED_FILES === btnType) && (
|
|
41
|
+
<AddSelectedFilesView
|
|
42
|
+
{...props}
|
|
43
|
+
client={client}
|
|
44
|
+
setAlterDisplay={setAlterDisplay}
|
|
45
|
+
setOpenSnackbar={setOpenSnackbar}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
{
|
|
50
|
+
(btnTypes.ADD_ALL_FILES === btnType) && (
|
|
51
|
+
<AddAllFilesView
|
|
52
|
+
{...props}
|
|
53
|
+
client={client}
|
|
54
|
+
setAlterDisplay={setAlterDisplay}
|
|
55
|
+
setOpenSnackbar={setOpenSnackbar}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
<SnackbarView
|
|
60
|
+
open={openSnackbar}
|
|
61
|
+
count={count}
|
|
62
|
+
onClose={() => setOpenSnackbar(false)}
|
|
63
|
+
/>
|
|
64
|
+
{(displayAlter) && (
|
|
65
|
+
<AlertView
|
|
66
|
+
alertMessage={alertMessage}
|
|
67
|
+
open={displayAlter}
|
|
68
|
+
onClose={() => setAlterDisplay(false)}
|
|
69
|
+
/>
|
|
70
|
+
)}
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default AddFilesView;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { onAddCartFiles } from '@bento-core/cart';
|
|
5
|
+
import {
|
|
6
|
+
TableContext,
|
|
7
|
+
onRowSeclect,
|
|
8
|
+
} from '@bento-core/paginated-table';
|
|
9
|
+
import AddSelectedFileComponent from './AddSelectedFilesView';
|
|
10
|
+
import { getFilesID } from '../../WrapperService';
|
|
11
|
+
|
|
12
|
+
const AddSelectedFilesController = (props) => {
|
|
13
|
+
const {
|
|
14
|
+
clsName,
|
|
15
|
+
section,
|
|
16
|
+
addFileQuery,
|
|
17
|
+
responseKeys,
|
|
18
|
+
dataKey,
|
|
19
|
+
addFiles,
|
|
20
|
+
setOpenSnackbar,
|
|
21
|
+
setAlterDisplay,
|
|
22
|
+
client,
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
const tableContext = useContext(TableContext);
|
|
26
|
+
const {
|
|
27
|
+
selectedRows = [],
|
|
28
|
+
dispatch,
|
|
29
|
+
} = tableContext.context;
|
|
30
|
+
const variables = {};
|
|
31
|
+
variables[dataKey] = selectedRows;
|
|
32
|
+
// add selected files id
|
|
33
|
+
const addSelectedFiles = () => {
|
|
34
|
+
const fileIds = getFilesID({
|
|
35
|
+
client,
|
|
36
|
+
variables,
|
|
37
|
+
fileIds: selectedRows,
|
|
38
|
+
query: addFileQuery,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
fileIds().then((response) => {
|
|
42
|
+
const ids = response[responseKeys[0]] || [];
|
|
43
|
+
if (ids.length >= 1000) {
|
|
44
|
+
setAlterDisplay(true);
|
|
45
|
+
} else {
|
|
46
|
+
addFiles(ids);
|
|
47
|
+
setOpenSnackbar(true);
|
|
48
|
+
dispatch(onRowSeclect([]));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
<AddSelectedFileComponent
|
|
56
|
+
{...props}
|
|
57
|
+
eventHandler={addSelectedFiles}
|
|
58
|
+
clsName={clsx(clsName, `${clsName}_${section}`)}
|
|
59
|
+
disabled={selectedRows.length === 0}
|
|
60
|
+
/>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
66
|
+
addFiles: (files) => { dispatch(onAddCartFiles(files)); },
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export default connect(null, mapDispatchToProps)(AddSelectedFilesController);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from '@material-ui/core';
|
|
3
|
+
import ToolTip from '@bento-core/tool-tip';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* customize tooltips based on tooltipContent
|
|
7
|
+
* defined on dashboardTabData (tooltipContent)
|
|
8
|
+
*/
|
|
9
|
+
export const ToolTipView = (props) => {
|
|
10
|
+
const {
|
|
11
|
+
section,
|
|
12
|
+
tooltipCofig,
|
|
13
|
+
classes,
|
|
14
|
+
} = props;
|
|
15
|
+
const {
|
|
16
|
+
icon,
|
|
17
|
+
src,
|
|
18
|
+
alt,
|
|
19
|
+
arrow = false,
|
|
20
|
+
tooltipText,
|
|
21
|
+
placement,
|
|
22
|
+
} = tooltipCofig;
|
|
23
|
+
return (
|
|
24
|
+
<ToolTip
|
|
25
|
+
placement={placement}
|
|
26
|
+
title={tooltipText || `${tooltipCofig[section]}`}
|
|
27
|
+
arrow={arrow}
|
|
28
|
+
classes={{
|
|
29
|
+
tooltip: classes.customTooltip,
|
|
30
|
+
arrow: classes.customArrow,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<img src={icon || src} alt={alt} />
|
|
34
|
+
</ToolTip>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const AddSelectedFileComponent = (props) => {
|
|
39
|
+
const {
|
|
40
|
+
eventHandler,
|
|
41
|
+
title,
|
|
42
|
+
clsName,
|
|
43
|
+
disabled,
|
|
44
|
+
tooltipCofig,
|
|
45
|
+
} = props;
|
|
46
|
+
|
|
47
|
+
const addFiles = () => {
|
|
48
|
+
eventHandler();
|
|
49
|
+
};
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Button
|
|
53
|
+
onClick={addFiles}
|
|
54
|
+
className={clsName}
|
|
55
|
+
disableRipple
|
|
56
|
+
disabled={disabled}
|
|
57
|
+
>
|
|
58
|
+
{title}
|
|
59
|
+
</Button>
|
|
60
|
+
{tooltipCofig && (<ToolTipView {...props} />)}
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default AddSelectedFileComponent;
|
|
@@ -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,56 @@
|
|
|
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
|
+
} = props;
|
|
16
|
+
|
|
17
|
+
if (cartWillFull) {
|
|
18
|
+
return (
|
|
19
|
+
<Alert
|
|
20
|
+
alertMessage={alertMessage}
|
|
21
|
+
open={open}
|
|
22
|
+
onClose={() => onNoClick()}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<Dialog
|
|
30
|
+
open={open}
|
|
31
|
+
aria-labelledby="alert-dialog-title"
|
|
32
|
+
aria-describedby="alert-dialog-description"
|
|
33
|
+
>
|
|
34
|
+
<DialogContent>
|
|
35
|
+
<DialogContentText id="alert-dialog-description">
|
|
36
|
+
Are you sure to add All Files
|
|
37
|
+
{' '}
|
|
38
|
+
{numberOfFilesSelected}
|
|
39
|
+
{' '}
|
|
40
|
+
to cart
|
|
41
|
+
</DialogContentText>
|
|
42
|
+
</DialogContent>
|
|
43
|
+
<DialogActions>
|
|
44
|
+
<Button className="yesBtn" onClick={() => onYesClick()}>
|
|
45
|
+
Yes
|
|
46
|
+
</Button>
|
|
47
|
+
<Button className="noBtn" onClick={() => onNoClick()}>
|
|
48
|
+
No
|
|
49
|
+
</Button>
|
|
50
|
+
</DialogActions>
|
|
51
|
+
</Dialog>
|
|
52
|
+
</>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default AddToCartDialogView;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { btnTypes } from './AddFiles';
|
|
3
|
+
import AddFileButtonView from './ReduxAddFile';
|
|
4
|
+
import DownloadManifestView from './DownloadManifestBtn';
|
|
5
|
+
|
|
6
|
+
const ButtonView = (props) => {
|
|
7
|
+
const {
|
|
8
|
+
btnType,
|
|
9
|
+
} = props;
|
|
10
|
+
|
|
11
|
+
if (btnTypes.DOWNLOAD_MANIFEST === btnType) {
|
|
12
|
+
return (
|
|
13
|
+
<DownloadManifestView {...props} />
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<AddFileButtonView {...props} />
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default ButtonView;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { Button } from '@material-ui/core';
|
|
3
|
+
import { useApolloClient } from '@apollo/client';
|
|
4
|
+
import {
|
|
5
|
+
downloadJson,
|
|
6
|
+
CartContext,
|
|
7
|
+
} from '@bento-core/cart';
|
|
8
|
+
import ToolTipView from './TooltipView';
|
|
9
|
+
|
|
10
|
+
const DownloadManifestView = (props) => {
|
|
11
|
+
const {
|
|
12
|
+
tooltipCofig,
|
|
13
|
+
clsName,
|
|
14
|
+
title,
|
|
15
|
+
} = props;
|
|
16
|
+
/**
|
|
17
|
+
* get cart state
|
|
18
|
+
*/
|
|
19
|
+
const cartContext = useContext(CartContext);
|
|
20
|
+
const {
|
|
21
|
+
cart,
|
|
22
|
+
} = cartContext.context;
|
|
23
|
+
|
|
24
|
+
const getQueryVeriables = (queryVariables) => {
|
|
25
|
+
const variables = { ...queryVariables };
|
|
26
|
+
variables.offset = 0;
|
|
27
|
+
variables.first = 10000;
|
|
28
|
+
return variables;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const client = useApolloClient();
|
|
32
|
+
async function fetchData({ queryVariables, table }) {
|
|
33
|
+
const fetchResult = await client
|
|
34
|
+
.query({
|
|
35
|
+
query: table.api,
|
|
36
|
+
variables: {
|
|
37
|
+
...getQueryVeriables(queryVariables),
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
.then((result) => result.data.filesInList);
|
|
41
|
+
return fetchResult;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function DocumentDownload() {
|
|
45
|
+
const { table, queryVariables } = cart;
|
|
46
|
+
const tableData = await fetchData({ queryVariables, table });
|
|
47
|
+
return downloadJson({ ...cart, tableData });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Button
|
|
53
|
+
className={clsName}
|
|
54
|
+
disableRipple
|
|
55
|
+
onClick={() => DocumentDownload()}
|
|
56
|
+
>
|
|
57
|
+
{title}
|
|
58
|
+
</Button>
|
|
59
|
+
{tooltipCofig && (<ToolTipView {...props} />)}
|
|
60
|
+
</>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default DownloadManifestView;
|