Speisekammer — Drag & Drop zwischen Kategorien (Parität mit Einkaufsliste) #177
Labels
No labels
priority/could
priority/must
priority/should
priority/wont
status/blocked
status/claimed
status/done-migrated
type/bug
type/feature
type/infra
type/tech-debt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
robert/todo#177
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Story: Speisekammer — Drag & Drop zwischen Kategorien
As a Nutzer der Speisekammer,
I want to ein Produkt per Drag & Drop in eine andere Kategorie ziehen können, nicht nur innerhalb derselben umsortieren,
so that ich falsch einsortierte Produkte genauso einfach korrigieren kann wie auf der Einkaufsliste.
Kontext (verifiziert im Code):
ShoppingListPage.tsxhat das bereits: ein einziger, seitenweiterDndContext, jede Kategorie ist überDroppableCategorySection.tsx(geteilt mitTodoList.tsx) ein echtes Drop-Target auch wenn leer,handleDragEndnutztresolveCrossCategoryMoveTarget(ReactUi/src/utils/reorder.ts) um Kategorie-Wechsel zu erkennen und ruftmoveShoppingProduct(...)mit der neuen Ziel-Kategorie auf.PantryPage.tsxhat das nicht:renderCategorySectionerzeugt pro Kategorie einen eigenen, isoliertenDndContext(key={categoryId}),handleDragEnd(categoryId, categoryProducts)ruftmovePantryProductimmer mit derselben, fest zugeordnetencategoryIdauf. Ein Drag kann technisch keineDndContext-Grenze überschreiten — Kategorie-Wechsel per Drag ist heute unmöglich.MovePantryProductCommandHandler.csunterstützt Kategorie-Wechsel schon vollständig (eigener Kommentar: "handles both same-category reorder and cross-category move in one command", inkl. korrekter Neu-Sortierung beider betroffener Kategorien) — das ist eine reine Frontend-Lücke, kein Backend-Change nötig.Acceptance criteria:
PantryPage.tsxwird auf denselben Aufbau wieShoppingListPage.tsxumgestellt: ein seitenweiterDndContext, Kategorien alsDroppableCategorySection(Wiederverwendung der bestehenden Komponente), Kategorie-Wechsel-Erkennung überresolveCrossCategoryMoveTarget.renderCategorySection(uncategorized, -1)) verhält sich konsistent mit dem entsprechenden Sonderfall auf der Einkaufsliste.Out of scope for this story:
MovePantryProductCommand) — bereits vollständig, siehe Kontext oben.Claiming this for the current go-loop cycle. Plan: switch PantryPage.tsx from its current per-category DndContext (renderCategorySection, one DndContext per category, blocking cross-category drag) to a single page-wide DndContext with DroppableCategorySection (shared with ShoppingListPage.tsx), using resolveCrossCategoryMoveTarget the same way ShoppingListPage already does. Backend (MovePantryProductCommandHandler) already supports cross-category moves, so this is frontend-only.
Done. Switched
PantryPage.tsxfrom a per-categoryDndContext(which made a drag physically unable to leave its own category, since dnd-kit collision detection cannot cross aDndContextboundary) to a single page-wideDndContext, usingDroppableCategorySection+resolveCrossCategoryMoveTarget- the exact same shared piecesShoppingListPage.tsxalready uses (#106). Backend (MovePantryProductCommandHandler) already fully supported cross-category moves, so this was frontend-only.Covered ACs:
movePantryProductcall, just resolved via the shared helper now instead of a bespoke index lookup).categoryId -1) stays non-draggable and non-droppable, consistent with the shopping-list special case.Tests: the shared cross-category resolution logic (
resolveCrossCategoryMoveTarget) is already exhaustively covered byreorder.test.ts(shared with Shopping/Todo), so no new drag-simulation test was added here - same precedentShoppingListPage.test.tsxdocuments for its own Sort-mode tests. All 20 existingPantryPage.test.tsxtests still pass unchanged, confirming the refactor didn't alter any other page behavior. Full frontend suite (1211 tests) green,npm run build/tsc -bclean. No backend changes.Commit:
f47078f5.