From 85664226353ac382df43fec9ba497f4de950f7b9 Mon Sep 17 00:00:00 2001 From: Victor Frunze Date: Mon, 2 Dec 2024 10:58:52 +0200 Subject: [PATCH] MWB-888: add project selector --- .../app/mobile-nav/mobile-nav-section.js | 3 +- .../src/layouts/app/mobile-nav/mobile-nav.js | 14 +-- .../src/layouts/app/project-switch2/index.js | 1 + .../app/project-switch2/project-switch.js | 112 ++++++++++++++++++ .../layouts/app/vertical-layout/side-nav.js | 2 +- 5 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 mapping_workbench/frontend/src/layouts/app/project-switch2/index.js create mode 100644 mapping_workbench/frontend/src/layouts/app/project-switch2/project-switch.js diff --git a/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav-section.js b/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav-section.js index 993915e4f..505adc355 100644 --- a/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav-section.js +++ b/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav-section.js @@ -76,7 +76,8 @@ export const MobileNavSection = (props) => { sx={{ listStyle: 'none', m: 0, - p: 0 + p: 0, + px:2 }} {...other}> {subheader && ( diff --git a/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav.js b/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav.js index e3744998c..484ccf011 100644 --- a/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav.js +++ b/mapping_workbench/frontend/src/layouts/app/mobile-nav/mobile-nav.js @@ -1,3 +1,4 @@ +import Divider from '@mui/material/Divider'; import {useMemo} from 'react'; import PropTypes from 'prop-types'; @@ -13,7 +14,7 @@ import {Scrollbar} from 'src/components/scrollbar'; import {usePathname} from 'src/hooks/use-pathname'; import {paths} from 'src/paths'; import {MobileNavSection} from './mobile-nav-section'; -import {ProjectSwitch} from "../project-switch"; +import {ProjectSwitch} from "../project-switch2"; import {useProjects} from "../../../hooks/use-projects"; import {VersionLabel} from "../version-label"; @@ -145,20 +146,15 @@ export const MobileNav = (props) => { @@ -171,7 +167,6 @@ export const MobileNav = (props) => { spacing={2} sx={{ flexGrow: 1, - px: 2 }} > { }}> + {overview.map((section, index) => ( { + const [anchorEl, setAnchorEl] = useState(null); + const projectsStore = useContext(ProjectsContext) + const [searchInputValue, setSearchInputValue] = useState('') + const router = useRouter(); + const theme = useTheme() + + + const handleProjectSelect = (value) => { + if (value) + projectsStore.handleSessionProjectChange(value) + else + router.push(paths.app.projects.create) + } + + const handleClick = (event) => { + setAnchorEl(event.currentTarget); + }; + + const handleClose = () => { + setAnchorEl(null); + }; + + return ( + + + + + + setSearchInputValue(event.target.value)} + startAdornment={( + + + + )}> + + + {projectsStore.items?.filter(project => project.title.toLowerCase() + .includes(searchInputValue.toLowerCase())) + .map(project => ( + handleProjectSelect(project._id)} + > + + {project.title} + + ))} + + + handleProjectSelect()} + sx={{color: theme.palette.primary.main, mb: 2}} + id='create_project_button'> + + + Create Project + + + + + + + ) + ; +}; \ No newline at end of file diff --git a/mapping_workbench/frontend/src/layouts/app/vertical-layout/side-nav.js b/mapping_workbench/frontend/src/layouts/app/vertical-layout/side-nav.js index 9ca123d1d..3c9365e5e 100644 --- a/mapping_workbench/frontend/src/layouts/app/vertical-layout/side-nav.js +++ b/mapping_workbench/frontend/src/layouts/app/vertical-layout/side-nav.js @@ -12,7 +12,7 @@ import {Scrollbar} from 'src/components/scrollbar'; import {usePathname} from 'src/hooks/use-pathname'; import {paths} from 'src/paths'; import {SideNavSection} from './side-nav-section'; -import {ProjectSwitch} from "../project-switch"; +import {ProjectSwitch} from "../project-switch2"; import {AppTitle} from "../../../components/app-title"; import {useProjects} from "../../../hooks/use-projects"; import {VersionLabel} from "../version-label";