From b2474a993fd670403314a400d3b9bde3534cfc4a Mon Sep 17 00:00:00 2001 From: emekauja Date: Thu, 20 Oct 2022 01:26:11 +0100 Subject: [PATCH] #44 implement composition right click panel --- .../Sidebar/TreeView/InstanceTreeView.js | 137 +++++++++++------- .../views/Sidebar/TreeView/TreeViewItem.js | 3 +- 2 files changed, 88 insertions(+), 52 deletions(-) diff --git a/src/components/views/Sidebar/TreeView/InstanceTreeView.js b/src/components/views/Sidebar/TreeView/InstanceTreeView.js index e347977e..08212619 100644 --- a/src/components/views/Sidebar/TreeView/InstanceTreeView.js +++ b/src/components/views/Sidebar/TreeView/InstanceTreeView.js @@ -1,20 +1,28 @@ -import React, { useCallback, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import TreeView from '@mui/lab/TreeView'; import StyledTreeItem from './TreeViewItem'; import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import ArrowRightIcon from '@mui/icons-material/ArrowRight'; import { FileIcon, ShapeArrowToolIcon, CircleIcon, CloseIcon } from './Icons'; -import { Box, IconButton, Popover, Typography } from '@mui/material'; +import { + Accordion, + AccordionDetails, + AccordionSummary, + Box, + IconButton, + Popover, + Stack, + Typography, +} from '@mui/material'; import vars from '../../../../assets/styles/variables'; import { makeStyles } from '@mui/styles'; +import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; export const GRAPH_SOURCE = 'GRAPH'; export const TREE_SOURCE = 'TREE'; const { - textWhite, popperBG, listSelectedTextColor, - dropdownBg, cardBG, nodeSecLabelColor, dropdownBorderColor, @@ -56,12 +64,12 @@ const useStyles = makeStyles(() => ({ }, block: { display: 'flex', + flex: 1, flexDirection: 'column', alignItems: 'flex-start', background: cardBG, - padding: '0.5rem', borderRadius: '0.5rem', - // width: 'calc((100% - 0.125rem) / 3)', + textOverflow: 'ellipsis', '& label': { display: 'block', @@ -70,32 +78,26 @@ const useStyles = makeStyles(() => ({ lineHeight: '0.625rem', letterSpacing: '-0.005rem', color: nodeSecLabelColor, - textTransform: 'uppercase', }, - }, - blockWrapper: { - display: 'flex', - gap: '0 0.0625rem', - flexWrap: 'wrap', - - '& .block': { - display: 'flex', - flexDirection: 'column', - alignItems: 'flex-start', - background: cardBG, - padding: '0.5rem', - - // width: 'calc((100% - 0.125rem) / 3)', + '& .text': { + maxWidth: 'calc(16.25rem - 3rem)', + whiteSpace: 'nowrap', }, - }, - function: { - '& .MuiTypography-root': { - marginTop: '0.25rem', - wordBreak: 'break-all', - fontWeight: 600, - '& strong': {}, + '& .function': { + maxWidth: 'calc(16.25rem - 2rem)', + whiteSpace: 'nowrap', + + '& .MuiTypography-root': { + marginTop: '0.25rem', + wordBreak: 'break-all', + fontWeight: 500, + '& strong': { + fontWeight: 400, + }, + }, }, }, + textColor: { color: functionTextColor, }, @@ -107,14 +109,21 @@ const useStyles = makeStyles(() => ({ height: '1rem', borderRadius: '1.25rem', margin: '0.25rem auto', - // background: ${nodeGreenBorderColor} + }, + accordion: { + background: cardBG, + boxShadow: 'none', + borderRadius: '0.5rem !important', + }, + paddingXS: { + padding: '0.5rem', }, })); const popperPaperProps = { style: { width: '16.25rem', - height: '17.5rem', + height: '18.4rem', padding: '0.5rem', background: popperBG, boxShadow: @@ -177,24 +186,21 @@ const InstancesTreeView = (props) => { if (e.target.className == 'MuiTreeItem-label') setSelectedNodes(nodes_ids); } - function onRightClick(event, nodeId) { + function onRightClick(event, node) { event.preventDefault(); event.stopPropagation(); - - setRight({ - mouseX: event.clientX - 360, - mouseY: event.clientY - 8, - }); - - console.log(nodeId, event, 'rightClick'); + if (node.type === 'COMPOSITION') { + setRight({ + mouseX: event.clientX - 360, + mouseY: event.clientY - 8, + }); + } } function onClose() { setRight(initialRightClickStateCreator()); } - console.log(selectedNodeId, nodes, datasets, 'selectedNodes'); - // Initialize state in this hook useEffect(() => { // Populate tree items state with datasets @@ -241,15 +247,18 @@ const InstancesTreeView = (props) => { onNodeSelect={onNodeSelect} onShowPanel={onRightClick} hidden={hidden} + type={treeItemData?.type} /> ); }); }; const functionValues = (label, value) => ( - + {label} - {value} + + {value} + ); @@ -278,9 +287,7 @@ const InstancesTreeView = (props) => { { - - {functionValues('Context', '12')} - {functionValues('Size', '8.90')} - {functionValues('Prefs', '44')} - + + + } + aria-controls="panel1a-content" + id={'panel1a-header' + id} + sx={{ + paddingLeft: '0.5rem', + paddingRight: '0.75rem', + '& .MuiAccordionSummary-content': { + marginY: '0.5rem', + }, + }} + > + + Function type + + CombinationFunction + + + + + CombinationFunction Detailing + + + + {functionValues('ID', 'Composition 2')} + + Function - + function @@ -330,7 +361,11 @@ const InstancesTreeView = (props) => { (gain=1.0, bias=-4) - + + {functionValues('Pertinencity', '12')} + {functionValues('Prosistensy', '8.90')} + + ); diff --git a/src/components/views/Sidebar/TreeView/TreeViewItem.js b/src/components/views/Sidebar/TreeView/TreeViewItem.js index d811d178..a6bc4ef5 100644 --- a/src/components/views/Sidebar/TreeView/TreeViewItem.js +++ b/src/components/views/Sidebar/TreeView/TreeViewItem.js @@ -66,6 +66,7 @@ const StyledTreeItem = (props) => { onNodeSelect, onShowPanel, hidden, + type, ...other } = props; @@ -103,7 +104,7 @@ const StyledTreeItem = (props) => { ) : null} } - onContextMenu={(e) => onShowPanel(e, other.nodeId)} + onContextMenu={(e) => onShowPanel(e, { id: other.nodeId, type })} {...other} /> );