task(B1): unique row/block ids for seating (fixes BUG-1)
This commit is contained in:
@@ -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 {
|
||||
private generateId(): string {
|
||||
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[] {
|
||||
const cfg = { ...DEFAULT_ROW, ...config };
|
||||
const elements: CADElement[] = [];
|
||||
const rowId = nextUid('row');
|
||||
const totalWidth = (cfg.count - 1) * cfg.spacing + cfg.chairWidth;
|
||||
const startX = x - totalWidth / 2 + cfg.chairWidth / 2;
|
||||
|
||||
@@ -217,7 +225,7 @@ export class SeatingService {
|
||||
outlineColor: '#2a5a99',
|
||||
seatType: 'standard',
|
||||
rowIndex: i,
|
||||
rowId: `row_${Date.now()}`,
|
||||
rowId,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -233,9 +241,10 @@ export class SeatingService {
|
||||
const startX = x - totalW / 2 + cfg.chairWidth / 2;
|
||||
const startY = y - totalH / 2 + cfg.chairHeight / 2;
|
||||
const rot = cfg.rotation * Math.PI / 180;
|
||||
const blockId = `block_${Date.now()}`;
|
||||
const blockId = nextUid('block');
|
||||
|
||||
for (let row = 0; row < cfg.rows; row++) {
|
||||
const rowId = nextUid('row');
|
||||
const offset = cfg.rowOffset * (row % 2);
|
||||
for (let col = 0; col < cfg.cols; col++) {
|
||||
const lx = startX + col * cfg.colSpacing + offset;
|
||||
@@ -263,6 +272,7 @@ export class SeatingService {
|
||||
rowIndex: row,
|
||||
colIndex: col,
|
||||
blockId,
|
||||
rowId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user