From 1f9c77f6444175a1a81afaf4e4b9f224c4c44681 Mon Sep 17 00:00:00 2001 From: YeonV Date: Thu, 15 Aug 2024 12:01:14 +0200 Subject: [PATCH] clear Pixel & PixelGroup from contextMenu --- src/pages/Devices/EditVirtuals/EditMatrix/M.tsx | 14 ++++++++++++++ .../EditVirtuals/EditMatrix/MContextMenu.tsx | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) 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 ) }