authscape 1.0.468 → 1.0.469

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.
@@ -0,0 +1,116 @@
1
+ import React, {useEffect, useState, useRef} from 'react';
2
+ // import {apiService, authService, StripeConnect, ReactDraft, EditableDatagrid, FileUploader} from 'authscape';
3
+ import Button from '@mui/material/Button';
4
+ import { Box } from '@mui/system';
5
+ import LinkRoundedIcon from '@mui/icons-material/LinkRounded';
6
+ import Dialog from '@mui/material/Dialog';
7
+ import DialogActions from '@mui/material/DialogActions';
8
+ import DialogContent from '@mui/material/DialogContent';
9
+ import DialogContentText from '@mui/material/DialogContentText';
10
+ import DialogTitle from '@mui/material/DialogTitle';
11
+ import TextField from '@mui/material/TextField';
12
+ import InputLabel from '@mui/material/InputLabel';
13
+ import MenuItem from '@mui/material/MenuItem';
14
+ import FormControl from '@mui/material/FormControl';
15
+ import Select from '@mui/material/Select';
16
+
17
+ export default function MatchExistingMappedColumn({companyId, documentId, documentMappingId, fromName, toOptions, onResponse}) {
18
+
19
+ const [createNewOpen, setCreateNewOpen] = useState(false);
20
+
21
+ const [onlyAddRowIfFound, setOnlyAddRowIfFound] = useState(false);
22
+ const [rememberForNextTime, setRememberForNextTime] = useState(false);
23
+
24
+ const [selectedToColumn, setSelectedToColumn] = useState(null);
25
+
26
+ const handleClose = () => {
27
+ setCreateNewOpen(false);
28
+ }
29
+
30
+ const SelectedExistingColumns = ({toOptions}) => {
31
+
32
+ return (
33
+ <Box sx={{ minWidth: 120 }}>
34
+ <FormControl fullWidth>
35
+ <InputLabel id="demo-simple-select-label">Match to column</InputLabel>
36
+ <Select
37
+ labelId="demo-simple-select-label"
38
+ id="demo-simple-select"
39
+ value={selectedToColumn}
40
+ label="Age"
41
+ onChange={(event) => {
42
+ setSelectedToColumn(event.target.value);
43
+ }}>
44
+ {toOptions != null && toOptions.map((toOption) => {
45
+
46
+ let isRequiredMessage = "";
47
+ if (toOption.isRequired)
48
+ {
49
+ isRequiredMessage = " (Required)";
50
+ }
51
+
52
+ return (
53
+ <MenuItem value={toOption.name}>{toOption.visibleName} {isRequiredMessage}</MenuItem>
54
+ );
55
+ })}
56
+ </Select>
57
+ </FormControl>
58
+ </Box>
59
+ )
60
+ }
61
+
62
+
63
+ return (
64
+ <Box>
65
+ <Dialog
66
+ open={createNewOpen}
67
+ onClose={handleClose}
68
+ fullWidth={true}
69
+ aria-labelledby="alert-dialog-title"
70
+ aria-describedby="alert-dialog-description">
71
+ <DialogTitle id="alert-dialog-title">
72
+ {"Match existing column"}
73
+ </DialogTitle>
74
+ <DialogContent>
75
+ <DialogContentText id="alert-dialog-description">
76
+ ***Inform the user about what it means to match existing columns***
77
+ </DialogContentText>
78
+ <Box sx={{paddingTop:2}}>
79
+ <TextField id="outlined-basic" label="File Column Name" defaultValue={fromName} variant="outlined" disabled={true} fullWidth={true} />
80
+ </Box>
81
+ <Box sx={{paddingTop:2}}>
82
+ <SelectedExistingColumns toOptions={toOptions} />
83
+ </Box>
84
+
85
+ </DialogContent>
86
+ <DialogActions>
87
+ <Button onClick={handleClose}>Cancel</Button>
88
+ <Button onClick={async () => {
89
+
90
+ let response = await apiService().put("/DocumentMapping/AssignMapping", {
91
+ companyId: companyId,
92
+ documentId: documentId,
93
+ fileColumnName: fromName,
94
+ documentMappingId: documentMappingId,
95
+ matchedColumn: selectedToColumn,
96
+ onlyAddRowIfColumnFound: onlyAddRowIfFound,
97
+ rememberForNextTime: rememberForNextTime
98
+ });
99
+
100
+ if (response != null && response.status == 200)
101
+ {
102
+ onResponse();
103
+ handleClose();
104
+ }
105
+
106
+ }} autoFocus>
107
+ Match Existing
108
+ </Button>
109
+ </DialogActions>
110
+ </Dialog>
111
+ <Button startIcon={<LinkRoundedIcon />} size="small" sx={{paddingLeft:3}} onClick={() => {
112
+ setCreateNewOpen(true);
113
+ }}>Match Existing</Button>
114
+ </Box>
115
+ );
116
+ }
@@ -0,0 +1,132 @@
1
+ import React, {useState, useRef} from 'react';
2
+ import Card from '@mui/material/Card';
3
+ import CardContent from '@mui/material/CardContent';
4
+ import Button from '@mui/material/Button';
5
+ import { Box } from '@mui/system';
6
+ import Typography from '@mui/material/Typography';
7
+ import AddRoundedIcon from '@mui/icons-material/AddRounded';
8
+ import LinkRoundedIcon from '@mui/icons-material/LinkRounded';
9
+ import Dialog from '@mui/material/Dialog';
10
+ import DialogActions from '@mui/material/DialogActions';
11
+ import DialogContent from '@mui/material/DialogContent';
12
+ import DialogContentText from '@mui/material/DialogContentText';
13
+ import DialogTitle from '@mui/material/DialogTitle';
14
+ import TextField from '@mui/material/TextField';
15
+ import Grid from '@mui/material/Grid';
16
+ import LocalParkingRoundedIcon from '@mui/icons-material/LocalParkingRounded';
17
+ import TextFieldsRoundedIcon from '@mui/icons-material/TextFieldsRounded';
18
+ import IntegrationInstructionsRoundedIcon from '@mui/icons-material/IntegrationInstructionsRounded';
19
+ import ListAltRoundedIcon from '@mui/icons-material/ListAltRounded';
20
+ import CalendarMonthRoundedIcon from '@mui/icons-material/CalendarMonthRounded';
21
+ import CheckBoxRoundedIcon from '@mui/icons-material/CheckBoxRounded';
22
+ import InsertPhotoRoundedIcon from '@mui/icons-material/InsertPhotoRounded';
23
+ // import { apiService } from 'authscape';
24
+
25
+ export default function NewMappingColumn({name, companyId, documentType, documentId, documentMappingId, onResponse}) {
26
+
27
+ const newColumnNameRef = useRef(null);
28
+ const newColumnDescriptionRef = useRef(null);
29
+
30
+ const [createNewOpen, setCreateNewOpen] = useState(false);
31
+ const [selectedAttributeId, setSelectedAttributeId] = useState(null);
32
+
33
+ const handleClose = () => {
34
+ setCreateNewOpen(false);
35
+ }
36
+
37
+ const AttributeTypeComponent = ({id, icon, text}) => {
38
+
39
+ return (
40
+ <Grid item xs={3}>
41
+ <Card sx={{textAlign:"center", cursor:"pointer", backgroundColor: (selectedAttributeId == id ? "#e5e5e5": "none")}} onClick={() => {
42
+ setSelectedAttributeId(id);
43
+ }}>
44
+ <CardContent>
45
+ {icon}
46
+ <Typography variant="body2" color="text.secondary" sx={{paddingTop:1}}>
47
+ {text}
48
+ </Typography>
49
+ </CardContent>
50
+ </Card>
51
+ </Grid>
52
+ )
53
+ }
54
+
55
+ return (
56
+ <Box>
57
+ <Dialog
58
+ open={createNewOpen}
59
+ onClose={handleClose}
60
+ fullWidth={true}
61
+ aria-labelledby="alert-dialog-title"
62
+ aria-describedby="alert-dialog-description">
63
+ <DialogTitle id="alert-dialog-title">
64
+ {"Match to new column"}
65
+ </DialogTitle>
66
+ <DialogContent>
67
+ <DialogContentText id="alert-dialog-description">
68
+ inform the user about adding a new columna and what that means here...
69
+ </DialogContentText>
70
+ <Box sx={{paddingTop:2}}>
71
+ <TextField inputRef={newColumnNameRef} defaultValue={name} id="outlined-basic" label="Name" variant="outlined" fullWidth={true} />
72
+ </Box>
73
+ <Box sx={{paddingTop:2}}>
74
+ <TextField inputRef={newColumnDescriptionRef} id="outlined-basic" label="Description (optional)" variant="outlined" fullWidth={true} />
75
+ </Box>
76
+ <Box sx={{paddingTop:2}}>
77
+ <Box>
78
+ <Typography variant="body1" gutterBottom>
79
+ Select how this column will be formatted
80
+ </Typography>
81
+ </Box>
82
+ <Grid container spacing={2} sx={{paddingTop:2}}>
83
+
84
+ <AttributeTypeComponent id={0} icon={<TextFieldsRoundedIcon />} text={"text"} />
85
+ <AttributeTypeComponent id={1} icon={<LocalParkingRoundedIcon/>} text={"Paragraph"} />
86
+ <AttributeTypeComponent id={2} icon={<IntegrationInstructionsRoundedIcon/>} text={"HTML"} />
87
+ <AttributeTypeComponent id={3} icon={<Box>{123}</Box>} text={"Integer"} />
88
+ <AttributeTypeComponent id={4} icon={<Box>{10.23}</Box>} text={"Decimal"} />
89
+ <AttributeTypeComponent id={5} icon={<ListAltRoundedIcon/>} text={"Dropdown"} />
90
+ <AttributeTypeComponent id={6} icon={<CalendarMonthRoundedIcon/>} text={"Date"} />
91
+ <AttributeTypeComponent id={7} icon={<LinkRoundedIcon/>} text={"URL"} />
92
+ <AttributeTypeComponent id={8} icon={<CheckBoxRoundedIcon/>} text={"Boolean"} />
93
+ <AttributeTypeComponent id={9} icon={<InsertPhotoRoundedIcon/>} text={"Photo"} />
94
+
95
+ </Grid>
96
+
97
+ </Box>
98
+
99
+ </DialogContent>
100
+ <DialogActions>
101
+ <Button onClick={handleClose}>Cancel</Button>
102
+ <Button onClick={async () => {
103
+
104
+ let response = await apiService().post("/DocumentMapping/AddNewColumnAndMapping", {
105
+ companyId: companyId,
106
+ documentId: documentId,
107
+ documentMappingId: documentMappingId,
108
+ newColumn: newColumnNameRef.current.value,
109
+ description: newColumnDescriptionRef.current.value,
110
+ attributeFieldType: selectedAttributeId
111
+ });
112
+
113
+ if (response != null && response.status == 200)
114
+ {
115
+ handleClose();
116
+ onResponse();
117
+ }
118
+
119
+ }} autoFocus>
120
+ Create
121
+ </Button>
122
+ </DialogActions>
123
+ </Dialog>
124
+
125
+ {documentType != null && documentType == 1 &&
126
+ <Button startIcon={<AddRoundedIcon />} size="small" sx={{paddingLeft:3}} onClick={() => {
127
+ setCreateNewOpen(true);
128
+ }}>Create New Column</Button>
129
+ }
130
+ </Box>
131
+ );
132
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import {useSortable} from '@dnd-kit/sortable';
3
+ import {CSS} from '@dnd-kit/utilities';
4
+ import { ListItem, ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
5
+ import MenuIcon from '@mui/icons-material/Menu';
6
+
7
+ export function SortableColumn(props) {
8
+ const {
9
+ attributes,
10
+ listeners,
11
+ setNodeRef,
12
+ transform,
13
+ transition,
14
+ } = useSortable({id: props.id});
15
+
16
+ const style = {
17
+ transform: CSS.Transform.toString(transform),
18
+ transition,
19
+ };
20
+
21
+ return (
22
+ <div ref={setNodeRef} style={style} {...attributes} {...listeners}>
23
+ <ListItem disablePadding>
24
+ <ListItemButton>
25
+ <ListItemIcon>
26
+ <MenuIcon />
27
+ </ListItemIcon>
28
+ <ListItemText primary={props.id} />
29
+ </ListItemButton>
30
+ </ListItem>
31
+ </div>
32
+ );
33
+ }
@@ -0,0 +1,124 @@
1
+ import React, {useEffect, useState, useRef} from 'react';
2
+ // import { apiService, FileUploader} from 'authscape';
3
+ import Button from '@mui/material/Button';
4
+ import { Box } from '@mui/system';
5
+ import PublishRoundedIcon from '@mui/icons-material/PublishRounded';
6
+ import Menu from '@mui/material/Menu';
7
+ import MenuItem from '@mui/material/MenuItem';
8
+
9
+ export default function UploadMappedFile({loadedUser, url = null, companyId = null, locationId = null, userId = null}) {
10
+
11
+ const [documentComponentOptions, setDocumentComponentOptions] = useState(null);
12
+
13
+ const [selectedDocumentComponentId, setSelectedDocumentComponentId] = useState(null);
14
+ const [anchorEl, setAnchorEl] = useState(null);
15
+ const open = Boolean(anchorEl);
16
+ const handleClose = () => {
17
+ setAnchorEl(null);
18
+ };
19
+
20
+ const fileUploaderRef = useRef(null);
21
+
22
+
23
+ useEffect(() => {
24
+ if (selectedDocumentComponentId != null)
25
+ {
26
+
27
+ // trigger the file uploader, make sure param is filled in
28
+ fileUploaderRef.current.click();
29
+
30
+ }
31
+ }, [selectedDocumentComponentId])
32
+
33
+ useEffect(() => {
34
+
35
+ if (loadedUser)
36
+ {
37
+ const fetchData = async () => {
38
+
39
+ let _params = {};
40
+
41
+ if (companyId != null)
42
+ {
43
+ _params.companyId = companyId;
44
+ }
45
+
46
+ if (userId != null)
47
+ {
48
+ _params.userId = userId;
49
+ }
50
+
51
+ if (locationId != null)
52
+ {
53
+ _params.locationId = locationId;
54
+ }
55
+
56
+ let response = await apiService().post("/DocumentMapping/GetDocumentComponents", _params);
57
+ if (response != null && response.status == 200)
58
+ {
59
+ setDocumentComponentOptions(response.data.data);
60
+ }
61
+ }
62
+ fetchData();
63
+ }
64
+
65
+ }, [loadedUser])
66
+
67
+ return (
68
+ <Box>
69
+
70
+ <FileUploader refOveride={fileUploaderRef} params={{
71
+
72
+ documentComponentId: selectedDocumentComponentId,
73
+ companyId: companyId,
74
+ locationId: locationId,
75
+ userId: userId
76
+
77
+ }} url={url} multiple={false} variant='custom' onUploadCompleted={() => {
78
+
79
+ setSelectedDocumentComponentId(null); // we need an onUploadCancelled
80
+
81
+ }}>
82
+
83
+ </FileUploader>
84
+
85
+ <Button
86
+ id="demo-positioned-button"
87
+ aria-controls={open ? 'demo-positioned-menu' : undefined}
88
+ aria-haspopup="true"
89
+ aria-expanded={open ? 'true' : undefined}
90
+ startIcon={<PublishRoundedIcon />}
91
+ sx={{marginLeft:1}}
92
+ onClick={(event) => {
93
+ setAnchorEl(event.currentTarget);
94
+ }}>
95
+ Upload File(s)
96
+ </Button>
97
+
98
+ <Menu
99
+ id="basic-menu"
100
+ anchorEl={anchorEl}
101
+ open={open}
102
+ onClose={handleClose}
103
+ MenuListProps={{
104
+ 'aria-labelledby': 'basic-button',
105
+ }}>
106
+ {documentComponentOptions != null && documentComponentOptions.map((documentComponent) => {
107
+
108
+ return (
109
+ <MenuItem onClick={() => {
110
+
111
+ // assigns the param document component id
112
+ setSelectedDocumentComponentId(documentComponent.id);
113
+
114
+ // close the menu
115
+ handleClose();
116
+
117
+ }}>{documentComponent.name + " (" + documentComponent.documentTypeName + ")"}</MenuItem>
118
+ )
119
+ })}
120
+ </Menu>
121
+
122
+ </Box>
123
+ )
124
+ }