Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILEX-81 Add button to change the active ontology to the single term view #71

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 54 additions & 13 deletions src/components/SingleTermView/CustomMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Divider from '@mui/material/Divider';
import CreateNewFolderOutlinedIcon from '@mui/icons-material/CreateNewFolderOutlined';
import ForkRightOutlinedIcon from '@mui/icons-material/ForkRightOutlined';
import DeleteOutlineOutlinedIcon from '@mui/icons-material/DeleteOutlineOutlined';
import FolderCopyOutlinedIcon from '@mui/icons-material/FolderCopyOutlined';
import { vars } from '../../theme/variables';

const { gray100, gray200, gray600, error700 } = vars;
Expand All @@ -31,7 +32,7 @@ const menuStyles = {
},
},
dangerMenuItem: {
color: error700,
color: `${error700} !important`,
'&:hover': {
background: 'transparent',
},
Expand All @@ -43,37 +44,77 @@ const menuStyles = {
};

const CustomMenu = ({ open, anchorRef, setOpen }) => {
const handleAddToActiveOntology = () => {
console.log('Add term to active ontology');
setOpen(false);
};

const handleCreateFork = () => {
console.log('Create fork');
setOpen(false);
};

const handleAddToAnotherOntology = () => {
console.log('Add term to another ontology');
setOpen(false);
};

const handleRemoveFromActiveOntology = () => {
console.log('Remove from active ontology');
setOpen(false);
};

const menuOptions = [
{
icon: <CreateNewFolderOutlinedIcon fontSize="small" />,
name: "Add term to active ontology",
onClick: handleAddToActiveOntology
},
{
icon: <ForkRightOutlinedIcon fontSize="small" />,
name: "Create fork",
onClick: handleCreateFork
},
{
icon: <FolderCopyOutlinedIcon fontSize="small" />,
name: "Add term to another ontology",
onClick: handleAddToAnotherOntology
}
]

return (
<Menu
id="customized-menu"
open={open}
onClose={() => setOpen(false)}
onClose={() => setOpen(false)}
anchorEl={anchorRef.current}
keepMounted
elevation={0}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
horizontal: 'left',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
horizontal: 'left',
}}
sx={{
'& .MuiPaper-root': menuStyles.paper,
'& .MuiList-root': menuStyles.list,
}}
>
<MenuItem onClick={() => setOpen(false)} sx={menuStyles.menuItem}>
<CreateNewFolderOutlinedIcon fontSize="small" />
Add term to active ontology
</MenuItem>
<MenuItem onClick={() => setOpen(false)} sx={menuStyles.menuItem}>
<ForkRightOutlinedIcon fontSize="small" />
Create fork
</MenuItem>
{menuOptions.map((item, index) => (
<MenuItem
key={`${item.name}_${index}`}
onClick={item.onClick}
sx={menuStyles.menuItem}
>
{item.icon}
{item.name}
</MenuItem>
))}
<Divider sx={menuStyles.divider} />
<MenuItem onClick={() => setOpen(false)} sx={{ ...menuStyles.menuItem, ...menuStyles.dangerMenuItem }}>
<MenuItem onClick={handleRemoveFromActiveOntology} sx={{ ...menuStyles.menuItem, ...menuStyles.dangerMenuItem }}>
<DeleteOutlineOutlinedIcon fontSize="small" sx={{ color: error700 }} />
Remove from active ontology
</MenuItem>
Expand Down
1 change: 1 addition & 0 deletions src/components/SingleTermView/OntologySearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const OntologySearch = () => {
const onSetActive = (event) => {
event.stopPropagation();
event.preventDefault();
console.log("selected value: ", selectedValue)
setOpenList(false);
setSelectedValue({ ...selectedValue, selected: true });
};
Expand Down
6 changes: 5 additions & 1 deletion src/components/SingleTermView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const SingleTermView = () => {
<Box display="flex" flexDirection="column">
<Box p="1.5rem 5rem 0rem 5rem">
<Grid container>
<Grid item xs={12} lg={6}>
<Grid container xs={12} lg={12} direction="row" alignItems="center" justifyContent="space-between">
<Stack direction="row" spacing=".75rem">
<CustomBreadcrumbs breadcrumbItems={breadcrumbItems} />
<ForkRightIcon fontSize="medium" htmlColor={brand700} />
Expand All @@ -147,6 +147,10 @@ const SingleTermView = () => {
className="rounded not-merged"
/>
</Stack>
<Stack direction="row" alignItems="center" gap={1}>
<Typography variant="caption" sx={{ fontSize: '0.875rem', color: gray600 }}>Active Ontology:</Typography>
<OntologySearch />
</Stack>
</Grid>
<Grid container mt="1.75rem">
<Grid item xs={12} lg={2}>
Expand Down