-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mw: rebase resolve, og: condensed menu based on new record dialogue f…
…or managing custom layers
- Loading branch information
1 parent
eea781d
commit 3d8a391
Showing
8 changed files
with
198 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
import { | ||
Box, | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogTitle, | ||
FormControl, | ||
InputLabel, | ||
MenuItem, | ||
Select, | ||
TextField, | ||
Theme | ||
} from '@mui/material'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import { set } from 'lodash'; | ||
import React, { useState } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { TOGGLE_CUSTOMIZE_LAYERS } from 'state/actions'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
formContainer: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'start', | ||
alignItems: 'center', | ||
gap: 10, | ||
paddingBlock: 10, | ||
paddingInline: 8 | ||
}, | ||
select: { | ||
minWidth: 200, | ||
maxWidth: 400, | ||
width: 'auto' | ||
}, | ||
syncSuccessful: { | ||
color: 'green' | ||
}, | ||
dialogActionsBox: { | ||
display: 'flex', | ||
justifyContent: 'space-between' | ||
} | ||
})); | ||
|
||
const CustomizeLayerMenu = (props) => { | ||
const dispatch = useDispatch(); | ||
|
||
const classes = useStyles(); | ||
const history = useHistory(); | ||
|
||
const accessRoles = useSelector((state: any) => state.Auth.accessRoles); | ||
const dialogueOpen = useSelector((state: any) => state.Map.customizeLayersToggle); | ||
|
||
//menu options | ||
const newLayerTypeOptions = ['Draw', 'Upload KML/KMZ', 'WMS Link', 'WFS Link']; | ||
const [optionVal, setOptionVal] = useState('Draw'); | ||
const [subMenuType, setSubMenuType] = useState('Init'); | ||
const [newLayerName, setNewLayerName] = useState(''); | ||
|
||
|
||
// two of each type | ||
const customLayers = [{ id: 1, type: 'Drawn', label: 'banana', data: '' }, {id: 2, type: 'Drawn', label: 'apple', data: ''}, {id: 3, type: 'WMS', label: 'orange', data: ''}, {id: 4, type: 'WMS', label: 'grape', data: ''}, {id: 5, type: 'WFS', label: 'pear', data: ''}, {id: 6, type: 'WFS', label: 'peach', data: ''}]; | ||
|
||
const cleanup = () => { | ||
setSubMenuType('Init'); | ||
setOptionVal('Draw'); | ||
}; | ||
|
||
return ( | ||
<Dialog open={dialogueOpen}> | ||
<DialogTitle>Add or remove a custom layer</DialogTitle> | ||
|
||
<Box className={classes.formContainer}> | ||
{ | ||
{ | ||
New: ( | ||
<FormControl> | ||
<InputLabel>New Layer type</InputLabel> | ||
<Select | ||
className={classes.select} | ||
value={optionVal} | ||
onChange={(e) => setOptionVal(e.target.value)} | ||
label="Choose new Layer type"> | ||
{newLayerTypeOptions.map((option) => ( | ||
<MenuItem disabled={['WMS Link', 'WFS Link'].includes(option)} key={Math.random()} value={option}> | ||
{option} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
<TextField | ||
className={classes.select} | ||
value={newLayerName} | ||
onChange={(e) => setNewLayerName(e.target.value)} | ||
label="Name your new layer"> | ||
</TextField> | ||
|
||
</FormControl> | ||
), | ||
Remove: ( | ||
<FormControl> | ||
<InputLabel>Remove Layer</InputLabel> | ||
<Select | ||
className={classes.select} | ||
value={optionVal} | ||
onChange={(e) => setOptionVal(e.target.value)} | ||
label="Choose Layer to remove"> | ||
{customLayers.map((option) => ( | ||
<MenuItem key={Math.random()} value={option.id}> | ||
{option.label + ' - ' + option.type} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
), | ||
Init: <></> | ||
}[subMenuType] | ||
} | ||
</Box> | ||
|
||
<DialogActions className={classes.dialogActionsBox}> | ||
{ | ||
{ | ||
Init: ( | ||
<> | ||
<Button | ||
onClick={() => { | ||
setSubMenuType('New'); | ||
}}> | ||
Add new | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
setSubMenuType('Remove'); | ||
}}> | ||
Remove existing | ||
</Button> | ||
</> | ||
), | ||
New: ( | ||
<> | ||
<Button onClick={() => {}}>Create</Button> | ||
<Button onClick={() => { | ||
setSubMenuType('Init'); | ||
}}>Back</Button> | ||
</> | ||
), | ||
Remove: ( | ||
<> | ||
<Button onClick={() => {}}>Remove</Button> | ||
<Button onClick={() => { | ||
setSubMenuType('Init'); | ||
}}>Back</Button> | ||
</> | ||
) | ||
}[subMenuType] | ||
} | ||
<Button | ||
onClick={() => { | ||
dispatch({ type: TOGGLE_CUSTOMIZE_LAYERS }); | ||
cleanup(); | ||
}}>Exit</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
|
||
|
||
|
||
export default CustomizeLayerMenu; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters