Revize 80e18558
Přidáno uživatelem Václav Honzík před asi 2 roky(ů)
frontend/src/features/TrackingTool/Import/AddFromCoordinatesDialog.tsx | ||
---|---|---|
1 |
import { DialogContent, DialogTitle, Grid, TextField } from '@mui/material' |
|
2 |
import { FunctionComponent, useState } from 'react' |
|
1 |
import { |
|
2 |
Button, |
|
3 |
DialogContent, |
|
4 |
DialogTitle, |
|
5 |
Grid, |
|
6 |
IconButton, |
|
7 |
Paper, |
|
8 |
Stack, |
|
9 |
TextField, |
|
10 |
Typography, |
|
11 |
} from '@mui/material' |
|
12 |
import { Fragment, FunctionComponent, useState } from 'react' |
|
3 | 13 |
import ButtonOpenableDialog from '../../Reusables/ButtonOpenableDialog' |
4 | 14 |
import * as yup from 'yup' |
5 | 15 |
import { useDispatch } from 'react-redux' |
... | ... | |
8 | 18 |
import generateUuid from '../../../utils/id/uuidGenerator' |
9 | 19 |
import { useFormik } from 'formik' |
10 | 20 |
import ContextMenuDialogProps from './contextMenuDialogProps' |
21 |
import ThemeWrapper from '../../Theme/ThemeWrapper' |
|
22 |
import CloseIcon from '@mui/icons-material/Close' |
|
11 | 23 |
|
12 | 24 |
interface AddCatalogItemFromCoords { |
13 | 25 |
latitude: number |
... | ... | |
52 | 64 |
}, |
53 | 65 |
}) |
54 | 66 |
|
67 |
const onClose = () => { |
|
68 |
formik.resetForm() |
|
69 |
closeContextMenu() |
|
70 |
setOpen(false) |
|
71 |
} |
|
72 |
|
|
55 | 73 |
return ( |
56 | 74 |
<ButtonOpenableDialog |
57 | 75 |
buttonText="Create Location" |
58 | 76 |
buttonColor="primary" |
59 | 77 |
buttonVariant="text" |
60 |
onCloseCallback={closeContextMenu}
|
|
78 |
onCloseCallback={onClose}
|
|
61 | 79 |
maxWidth="xs" |
62 | 80 |
open={open} |
63 | 81 |
setOpen={setOpen} |
64 | 82 |
size="small" |
65 | 83 |
> |
66 |
<DialogTitle>Add New Location From Coordinates</DialogTitle> |
|
67 |
<DialogContent> |
|
68 |
<form onSubmit={formik.handleSubmit}> |
|
69 |
<Grid container spacing={1} sx={{ mt: 1, mb: 1 }}> |
|
70 |
<Grid item xs={12} md={6}> |
|
71 |
<TextField |
|
72 |
fullWidth |
|
73 |
label="Latitude" |
|
74 |
name="latitude" |
|
75 |
type="number" |
|
76 |
variant="outlined" |
|
77 |
value={formik.values.latitude} |
|
78 |
onChange={formik.handleChange} |
|
79 |
error={ |
|
80 |
Boolean(formik.errors.latitude) && |
|
81 |
formik.touched.latitude |
|
82 |
} |
|
83 |
helperText={ |
|
84 |
formik.errors.latitude && |
|
85 |
formik.touched.latitude |
|
86 |
} |
|
87 |
/> |
|
88 |
</Grid> |
|
89 |
<Grid item xs={12} md={6}> |
|
90 |
<TextField |
|
91 |
fullWidth |
|
92 |
label="Longitude" |
|
93 |
name="longitude" |
|
94 |
type="number" |
|
95 |
variant="outlined" |
|
96 |
value={formik.values.longitude} |
|
97 |
onChange={formik.handleChange} |
|
98 |
error={ |
|
99 |
Boolean(formik.errors.longitude) && |
|
100 |
formik.touched.longitude |
|
101 |
} |
|
102 |
helperText={ |
|
103 |
formik.errors.longitude && |
|
104 |
formik.touched.longitude |
|
105 |
} |
|
106 |
/> |
|
107 |
</Grid> |
|
108 |
</Grid> |
|
109 |
<TextField |
|
110 |
fullWidth |
|
111 |
label="Name" |
|
112 |
name="name" |
|
113 |
variant="outlined" |
|
114 |
value={formik.values.name} |
|
115 |
onChange={formik.handleChange} |
|
116 |
error={ |
|
117 |
Boolean(formik.errors.name) && formik.touched.name |
|
118 |
} |
|
119 |
helperText={formik.errors.name && formik.touched.name} |
|
120 |
/> |
|
121 |
</form> |
|
122 |
</DialogContent> |
|
84 |
<ThemeWrapper> |
|
85 |
<Paper> |
|
86 |
<DialogTitle> |
|
87 |
<Stack |
|
88 |
direction="row" |
|
89 |
justifyContent="space-between" |
|
90 |
alignItems="center" |
|
91 |
spacing={1} |
|
92 |
> |
|
93 |
<Fragment> |
|
94 |
Add New Location From Coordinates |
|
95 |
</Fragment> |
|
96 |
<IconButton onClick={onClose}> |
|
97 |
<CloseIcon /> |
|
98 |
</IconButton> |
|
99 |
</Stack> |
|
100 |
</DialogTitle> |
|
101 |
<DialogContent> |
|
102 |
<form onSubmit={formik.handleSubmit}> |
|
103 |
<Grid |
|
104 |
container |
|
105 |
sx={{ mt: 1 }} |
|
106 |
// spacing={1} |
|
107 |
justifyContent="space-around" |
|
108 |
alignItems="center" |
|
109 |
> |
|
110 |
<Grid item xs={6} md={9}> |
|
111 |
<TextField |
|
112 |
fullWidth |
|
113 |
label="Name" |
|
114 |
size="small" |
|
115 |
name="name" |
|
116 |
variant="outlined" |
|
117 |
value={formik.values.name} |
|
118 |
onChange={formik.handleChange} |
|
119 |
error={ |
|
120 |
Boolean(formik.errors.name) && |
|
121 |
formik.touched.name |
|
122 |
} |
|
123 |
helperText={ |
|
124 |
formik.errors.name && |
|
125 |
formik.touched.name |
|
126 |
} |
|
127 |
/> |
|
128 |
</Grid> |
|
129 |
<Grid |
|
130 |
item |
|
131 |
container |
|
132 |
xs={6} |
|
133 |
md={3} |
|
134 |
justifyContent="flex-end" |
|
135 |
> |
|
136 |
<Button variant="contained" type="submit" color="primary"> |
|
137 |
Import |
|
138 |
</Button> |
|
139 |
</Grid> |
|
140 |
</Grid> |
|
141 |
<Grid container spacing={1} sx={{ mt: 1, mb: 1 }}> |
|
142 |
<Grid item xs={12} md={6}> |
|
143 |
<TextField |
|
144 |
fullWidth |
|
145 |
label="Latitude" |
|
146 |
name="latitude" |
|
147 |
type="number" |
|
148 |
size="small" |
|
149 |
variant="outlined" |
|
150 |
value={formik.values.latitude} |
|
151 |
onChange={formik.handleChange} |
|
152 |
error={ |
|
153 |
Boolean(formik.errors.latitude) && |
|
154 |
formik.touched.latitude |
|
155 |
} |
|
156 |
helperText={ |
|
157 |
formik.errors.latitude && |
|
158 |
formik.touched.latitude |
|
159 |
} |
|
160 |
/> |
|
161 |
</Grid> |
|
162 |
<Grid item xs={12} md={6}> |
|
163 |
<TextField |
|
164 |
fullWidth |
|
165 |
label="Longitude" |
|
166 |
name="longitude" |
|
167 |
type="number" |
|
168 |
variant="outlined" |
|
169 |
size="small" |
|
170 |
value={formik.values.longitude} |
|
171 |
onChange={formik.handleChange} |
|
172 |
error={ |
|
173 |
Boolean(formik.errors.longitude) && |
|
174 |
formik.touched.longitude |
|
175 |
} |
|
176 |
helperText={ |
|
177 |
formik.errors.longitude && |
|
178 |
formik.touched.longitude |
|
179 |
} |
|
180 |
/> |
|
181 |
</Grid> |
|
182 |
</Grid> |
|
183 |
</form> |
|
184 |
</DialogContent> |
|
185 |
</Paper> |
|
186 |
</ThemeWrapper> |
|
123 | 187 |
</ButtonOpenableDialog> |
124 | 188 |
) |
125 | 189 |
} |
Také k dispozici: Unified diff
import dialogs more fleshed out
re #9741