diff --git a/src/pages/Devices/EditVirtuals/EditMatrix/M.tsx b/src/pages/Devices/EditVirtuals/EditMatrix/M.tsx index 456a0406..f2b46fee 100644 --- a/src/pages/Devices/EditVirtuals/EditMatrix/M.tsx +++ b/src/pages/Devices/EditVirtuals/EditMatrix/M.tsx @@ -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) { @@ -437,6 +449,8 @@ const EditMatrix: FC<{ virtual: any }> = ({ virtual }) => { m={m} setOpen={setOpen} setMove={setMove} + clearPixel={clearPixel} + clearPixelGroup={clearPixelGroup} /> { const contextMenuOpen = Boolean(anchorEl) return ( @@ -59,7 +63,14 @@ const MContextMenu = ({ > Move Group - Clear + { + clearPixel() + closeContextMenu(e) + }}>Clear Pixel + { + clearPixelGroup(m[currentCell[1]][currentCell[0]].group || '0-0') + closeContextMenu(e) + }}>Clear Group ) }