Add CapacityDisplayTool for showing total seats count
This commit is contained in:
@@ -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 };
|
||||
Reference in New Issue
Block a user