From c9b89cdc1409718071e4fb2e93248bd90a5191e9 Mon Sep 17 00:00:00 2001 From: Leopoldadmin Date: Mon, 22 Jun 2026 21:04:20 +0000 Subject: [PATCH] Add CapacityDisplayTool for showing total seats count --- .../src/tools/drawing/CapacityDisplayTool.ts | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 frontend/src/tools/drawing/CapacityDisplayTool.ts diff --git a/frontend/src/tools/drawing/CapacityDisplayTool.ts b/frontend/src/tools/drawing/CapacityDisplayTool.ts new file mode 100644 index 0000000..4f15400 --- /dev/null +++ b/frontend/src/tools/drawing/CapacityDisplayTool.ts @@ -0,0 +1,66 @@ +import { Tool } from '../Tool'; +import { YjsDocument } from '../../crdt/YjsDocument'; + +class CapacityDisplayTool extends Tool { + constructor(yjsDoc: YjsDocument) { + super(yjsDoc); + this.name = 'CapacityDisplayTool'; + } + + onMouseDown(event: MouseEvent): void { + // This tool doesn't create elements on mouse click + // It displays capacity information based on selected elements or entire drawing + } + + onMouseMove(event: MouseEvent): void { + // No preview needed for this tool + } + + onMouseUp(event: MouseEvent): void { + // No action needed on mouse up + } + + onKeyUp(event: KeyboardEvent): void { + // Handle key up events + if (event.key === 'Escape') { + this.reset(); + } + } + + reset(): void { + // Reset any state if needed + } + + // Calculate capacity for selected tables + calculateSelectedCapacity(): number { + // In a real implementation, this would get selected tables from the canvas + // and calculate the total capacity based on table type and size + // For now, we'll return a placeholder value + return 0; + } + + // Calculate capacity for entire drawing + calculateTotalCapacity(): number { + // In a real implementation, this would iterate through all elements in the Yjs document + // and count chairs or calculate capacity based on tables + // For now, we'll return a placeholder value + return 0; + } + + // Display capacity information + displayCapacity(): void { + const totalCapacity = this.calculateTotalCapacity(); + const selectedCapacity = this.calculateSelectedCapacity(); + + // In a real implementation, this would update the UI to show capacity information + console.log(`Total capacity: ${totalCapacity} seats`); + if (selectedCapacity > 0) { + console.log(`Selected capacity: ${selectedCapacity} seats`); + } + + // In a real implementation, this would show a modal or update a panel in the UI + alert(`Total capacity: ${totalCapacity} seats${selectedCapacity > 0 ? `\nSelected capacity: ${selectedCapacity} seats` : ''}`); + } +} + +export { CapacityDisplayTool }; \ No newline at end of file