-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attribute table is now a full screen dialog:
- This is part of #595. - Upon clicking on the 'show attribute table' button, a full screen dialog is shown. I've experimented with different solutions, including non-fullscreen. I'm still open for another implementation in floating Window though, if someone would like to give it a go. - SimpleDialog is _outside_ LayerSwitcher component. I started out with having it inside, but eventually I figured that there could be reasons to call this from other parts of code than just LayerSwitcher. So it's placed in components, subscribes on global observer and renders directly in <App />. - I'll add a flag, on a per-layer-basis, that will control the visibility of the attribute table button. I'll call it 'showAttributeTableButton'. - We might like to make it a map setting too, we'll see. - Finally, added some Tooltips to LayerSwitcherItem.
- Loading branch information
Showing
5 changed files
with
195 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import * as React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import Dialog from "@mui/material/Dialog"; | ||
import AppBar from "@mui/material/AppBar"; | ||
import Toolbar from "@mui/material/Toolbar"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import Typography from "@mui/material/Typography"; | ||
import CloseIcon from "@mui/icons-material/Close"; | ||
import Slide from "@mui/material/Slide"; | ||
|
||
import { DataGrid, GridToolbar } from "@mui/x-data-grid"; | ||
SimpleDialog.propTypes = { | ||
globalObserver: PropTypes.object.isRequired, | ||
}; | ||
|
||
const Transition = React.forwardRef(function Transition(props, ref) { | ||
return <Slide direction="up" ref={ref} {...props} />; | ||
}); | ||
|
||
export default function SimpleDialog({ globalObserver }) { | ||
const [open, setOpen] = React.useState(false); | ||
const [content, setContent] = React.useState({ columns: [], rows: [] }); | ||
const [title, setTitle] = React.useState(""); | ||
|
||
React.useEffect(() => { | ||
globalObserver.subscribe( | ||
"core.showAttributeTable", | ||
({ title, content }) => { | ||
setTitle(title); | ||
setContent(content); | ||
setOpen(true); | ||
} | ||
); | ||
}, [globalObserver]); | ||
|
||
const handleClose = () => { | ||
setOpen(false); | ||
setTitle(""); | ||
setContent({ columns: [], rows: [] }); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
onClose={handleClose} | ||
open={open} | ||
fullScreen | ||
TransitionComponent={Transition} | ||
> | ||
<AppBar sx={{ position: "relative" }}> | ||
<Toolbar> | ||
<IconButton | ||
edge="start" | ||
color="inherit" | ||
onClick={handleClose} | ||
aria-label="close" | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
<Typography sx={{ ml: 2, flex: 1 }} variant="h6" component="div"> | ||
{title} | ||
</Typography> | ||
</Toolbar> | ||
</AppBar> | ||
<div style={{ height: "100%", width: "100%" }}> | ||
<DataGrid | ||
rows={content.rows} | ||
columns={content.columns} | ||
components={{ Toolbar: GridToolbar }} | ||
></DataGrid> | ||
</div> | ||
</Dialog> | ||
); | ||
} |
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