aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/components/AddAttributeDialog.jsx
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-04-06 09:22:10 -0700
committerAnton Tananaev <anton@traccar.org>2024-04-06 09:22:10 -0700
commitf418231b6b2f5e030a0d2dcc390c314602b1f740 (patch)
tree10326adf3792bc2697e06bb5f2b8ef2a8f7e55fe /modern/src/settings/components/AddAttributeDialog.jsx
parentb392a4af78e01c8e0f50aad5468e9583675b24be (diff)
downloadtrackermap-web-f418231b6b2f5e030a0d2dcc390c314602b1f740.tar.gz
trackermap-web-f418231b6b2f5e030a0d2dcc390c314602b1f740.tar.bz2
trackermap-web-f418231b6b2f5e030a0d2dcc390c314602b1f740.zip
Move modern to the top
Diffstat (limited to 'modern/src/settings/components/AddAttributeDialog.jsx')
-rw-r--r--modern/src/settings/components/AddAttributeDialog.jsx104
1 files changed, 0 insertions, 104 deletions
diff --git a/modern/src/settings/components/AddAttributeDialog.jsx b/modern/src/settings/components/AddAttributeDialog.jsx
deleted file mode 100644
index 86ff64ea..00000000
--- a/modern/src/settings/components/AddAttributeDialog.jsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import React, { useState } from 'react';
-import {
- Button, Dialog, DialogActions, DialogContent, FormControl, InputLabel, MenuItem, Select, TextField, Autocomplete,
-} from '@mui/material';
-
-import { createFilterOptions } from '@mui/material/useAutocomplete';
-import { makeStyles } from '@mui/styles';
-import { useTranslation } from '../../common/components/LocalizationProvider';
-
-const useStyles = makeStyles((theme) => ({
- details: {
- display: 'flex',
- flexDirection: 'column',
- gap: theme.spacing(2),
- paddingBottom: theme.spacing(1),
- paddingTop: theme.spacing(3),
- },
-}));
-
-const AddAttributeDialog = ({ open, onResult, definitions }) => {
- const classes = useStyles();
- const t = useTranslation();
-
- const filter = createFilterOptions({
- stringify: (option) => option.name,
- });
-
- const options = Object.entries(definitions).map(([key, value]) => ({
- key,
- name: value.name,
- type: value.type,
- }));
-
- const [key, setKey] = useState();
- const [type, setType] = useState('string');
-
- return (
- <Dialog open={open} fullWidth maxWidth="xs">
- <DialogContent className={classes.details}>
- <Autocomplete
- onChange={(_, option) => {
- setKey(option && typeof option === 'object' ? option.key : option);
- if (option && option.type) {
- setType(option.type);
- }
- }}
- filterOptions={(options, params) => {
- const filtered = filter(options, params);
- if (params.inputValue) {
- filtered.push({
- key: params.inputValue,
- name: params.inputValue,
- });
- }
- return filtered;
- }}
- options={options}
- getOptionLabel={(option) => (option && typeof option === 'object' ? option.name : option)}
- renderOption={(props, option) => (
- <li {...props}>
- {option.name}
- </li>
- )}
- renderInput={(params) => (
- <TextField {...params} label={t('sharedAttribute')} />
- )}
- freeSolo
- />
- <FormControl
- fullWidth
- disabled={key in definitions}
- >
- <InputLabel>{t('sharedType')}</InputLabel>
- <Select
- label={t('sharedType')}
- value={type}
- onChange={(e) => setType(e.target.value)}
- >
- <MenuItem value="string">{t('sharedTypeString')}</MenuItem>
- <MenuItem value="number">{t('sharedTypeNumber')}</MenuItem>
- <MenuItem value="boolean">{t('sharedTypeBoolean')}</MenuItem>
- </Select>
- </FormControl>
- </DialogContent>
- <DialogActions>
- <Button
- color="primary"
- disabled={!key}
- onClick={() => onResult({ key, type })}
- >
- {t('sharedAdd')}
- </Button>
- <Button
- autoFocus
- onClick={() => onResult(null)}
- >
- {t('sharedCancel')}
- </Button>
- </DialogActions>
- </Dialog>
- );
-};
-
-export default AddAttributeDialog;