task(B1): unique row/block ids for seating (fixes BUG-1)

This commit is contained in:
Agent Zero
2026-08-26 13:14:34 +02:00
parent b9eb69fc81
commit 1bbd653d34
+12 -2
View File
@@ -159,6 +159,13 @@ export const SEATING_TEMPLATES: SeatingTemplate[] = [
}, },
]; ];
let seqCounter = 0;
/** Eindeutige, kollisionsfreie ID mit Präfix (Zeit + Sequenz + Zufall). */
function nextUid(prefix: string): string {
seqCounter += 1;
return `${prefix}_${Date.now().toString(36)}_${seqCounter.toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
}
export class SeatingService { export class SeatingService {
private generateId(): string { private generateId(): string {
return `el_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`; return `el_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
@@ -189,6 +196,7 @@ export class SeatingService {
createSeatingRow(x: number, y: number, layerId: string, config: Partial<SeatingRowConfig> = {}): CADElement[] { createSeatingRow(x: number, y: number, layerId: string, config: Partial<SeatingRowConfig> = {}): CADElement[] {
const cfg = { ...DEFAULT_ROW, ...config }; const cfg = { ...DEFAULT_ROW, ...config };
const elements: CADElement[] = []; const elements: CADElement[] = [];
const rowId = nextUid('row');
const totalWidth = (cfg.count - 1) * cfg.spacing + cfg.chairWidth; const totalWidth = (cfg.count - 1) * cfg.spacing + cfg.chairWidth;
const startX = x - totalWidth / 2 + cfg.chairWidth / 2; const startX = x - totalWidth / 2 + cfg.chairWidth / 2;
@@ -217,7 +225,7 @@ export class SeatingService {
outlineColor: '#2a5a99', outlineColor: '#2a5a99',
seatType: 'standard', seatType: 'standard',
rowIndex: i, rowIndex: i,
rowId: `row_${Date.now()}`, rowId,
}, },
}); });
} }
@@ -233,9 +241,10 @@ export class SeatingService {
const startX = x - totalW / 2 + cfg.chairWidth / 2; const startX = x - totalW / 2 + cfg.chairWidth / 2;
const startY = y - totalH / 2 + cfg.chairHeight / 2; const startY = y - totalH / 2 + cfg.chairHeight / 2;
const rot = cfg.rotation * Math.PI / 180; const rot = cfg.rotation * Math.PI / 180;
const blockId = `block_${Date.now()}`; const blockId = nextUid('block');
for (let row = 0; row < cfg.rows; row++) { for (let row = 0; row < cfg.rows; row++) {
const rowId = nextUid('row');
const offset = cfg.rowOffset * (row % 2); const offset = cfg.rowOffset * (row % 2);
for (let col = 0; col < cfg.cols; col++) { for (let col = 0; col < cfg.cols; col++) {
const lx = startX + col * cfg.colSpacing + offset; const lx = startX + col * cfg.colSpacing + offset;
@@ -263,6 +272,7 @@ export class SeatingService {
rowIndex: row, rowIndex: row,
colIndex: col, colIndex: col,
blockId, blockId,
rowId,
}, },
}); });
} }