Skip to content

Commit

Permalink
clear Pixel & PixelGroup from contextMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Aug 15, 2024
1 parent 3cc9403 commit 1f9c77f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/pages/Devices/EditVirtuals/EditMatrix/M.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ const EditMatrix: FC<{ virtual: any }> = ({ virtual }) => {
closeClear()
}

const clearPixelGroup = (group: string | number) => {
const updatedM = clone(m)
m.forEach((row, rowIndex) => {
row.forEach((cell, colIndex) => {
if (cell.group === group) {
updatedM[rowIndex][colIndex] = { deviceId: '', pixel: 0, group: 0 }
}
})
})
setM(updatedM)
}

const handleDragEnd = (event: DragEndEvent) => {
// console.log(parent, event)
if (event.over && event.over.id) {
Expand Down Expand Up @@ -437,6 +449,8 @@ const EditMatrix: FC<{ virtual: any }> = ({ virtual }) => {
m={m}
setOpen={setOpen}
setMove={setMove}
clearPixel={clearPixel}
clearPixelGroup={clearPixelGroup}
/>
<AssignPixelDialog
open={open}
Expand Down
15 changes: 13 additions & 2 deletions src/pages/Devices/EditVirtuals/EditMatrix/MContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const MContextMenu = ({
setMove,
currentCell,
m,
setDnd
setDnd,
clearPixel,
clearPixelGroup
}: {
anchorEl: any
closeContextMenu: any
Expand All @@ -18,6 +20,8 @@ const MContextMenu = ({
currentCell: [number, number]
m: any
setDnd: any
clearPixel: any
clearPixelGroup: any
}) => {
const contextMenuOpen = Boolean(anchorEl)
return (
Expand Down Expand Up @@ -59,7 +63,14 @@ const MContextMenu = ({
>
Move Group
</MenuItem>
<MenuItem onClick={closeContextMenu}>Clear</MenuItem>
<MenuItem onClick={(e) => {
clearPixel()
closeContextMenu(e)
}}>Clear Pixel</MenuItem>
<MenuItem onClick={(e) => {
clearPixelGroup(m[currentCell[1]][currentCell[0]].group || '0-0')
closeContextMenu(e)
}}>Clear Group</MenuItem>
</Menu>
)
}
Expand Down

0 comments on commit 1f9c77f

Please sign in to comment.