From 68b9ee850b55d06a4578251b0a9f1cdfcc1975c5 Mon Sep 17 00:00:00 2001 From: Grovy311 Date: Sat, 26 Sep 2026 13:16:22 +0200 Subject: [PATCH] Search board info fields and confirm project device deletion The distribution-board search also matches board number and location as soon as the boards carry them (distribution-board info card of feature/print-view); the fields are optional in the filter, so the branch works with and without them. Deleting a project device now asks for confirmation like the other delete actions, since the row action is a small trash icon. Co-Authored-By: Claude Opus 5.5 --- src/app/projects/[projectId]/page.tsx | 7 ++++++- src/frontend/utils/overview-filters.ts | 12 +++++++++++- tests/overview-filters.test.ts | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/app/projects/[projectId]/page.tsx b/src/app/projects/[projectId]/page.tsx index f937804..fca0b4b 100644 --- a/src/app/projects/[projectId]/page.tsx +++ b/src/app/projects/[projectId]/page.tsx @@ -476,6 +476,11 @@ export default function ProjectDetailPage() { if (!projectId || !project) { return; } + const device = projectDevices.find((item) => item.id === projectDeviceId); + const deviceName = device?.displayName || device?.name || "Projektgerät"; + if (!window.confirm(`Projektgerät „${deviceName}“ wirklich löschen?`)) { + return; + } setIsSaving(true); setError(null); try { @@ -1053,7 +1058,7 @@ export default function ProjectDetailPage() { onChange={(query) => setBoardFilters((current) => ({ ...current, query })) } - placeholder="Verteilung oder Etage …" + placeholder="Name, Nr., Örtlichkeit oder Etage …" value={boardFilters.query} /> , + Board extends Pick & { + boardNumber?: string | null; + location?: string | null; + }, >( boards: readonly Board[], filters: DistributionBoardFilters, @@ -166,6 +174,8 @@ export function filterDistributionBoards< (board) => matchesQuery(query, [ board.name, + board.boardNumber, + board.location, board.floorId ? floorNameById.get(board.floorId) : undefined, ]) && matchesSelection( diff --git a/tests/overview-filters.test.ts b/tests/overview-filters.test.ts index 8c87345..84c5807 100644 --- a/tests/overview-filters.test.ts +++ b/tests/overview-filters.test.ts @@ -82,6 +82,29 @@ describe("overview filters: distribution boards", () => { ); }); + it("also searches board number and location when the boards carry them", () => { + const withInfo = [ + { ...boards[0]!, boardNumber: "UV 0.1", location: "Raum 003 Technik" }, + { ...boards[1]!, boardNumber: null, location: null }, + ]; + assert.deepEqual( + filterDistributionBoards( + withInfo, + { ...emptyDistributionBoardFilters, query: "uv 0.1" }, + floorNameById + ).map((entry) => entry.id), + [withInfo[0]!.id] + ); + assert.deepEqual( + filterDistributionBoards( + withInfo, + { ...emptyDistributionBoardFilters, query: "technik" }, + floorNameById + ).map((entry) => entry.id), + [withInfo[0]!.id] + ); + }); + it("searches board and floor names case-insensitively and ignores blank queries", () => { const byFloorName = filterDistributionBoards( boards,