diff --git a/B07_DesignDetail/openwebcad/src/entities/TableEntity.ts b/B07_DesignDetail/openwebcad/src/entities/TableEntity.ts index 5662184dd..33767ed58 100644 --- a/B07_DesignDetail/openwebcad/src/entities/TableEntity.ts +++ b/B07_DesignDetail/openwebcad/src/entities/TableEntity.ts @@ -351,9 +351,11 @@ export class TableEntity implements Entity { data.cells, data.style ); - table.id = jsonEntity.id; - table.lineColor = jsonEntity.lineColor; - table.lineWidth = jsonEntity.lineWidth; + // 서버가 만든 표(면적산출 → 도면 · M02 41장)는 id · 선 색 · 굵기가 없을 수 있다 — 비면 새 표의 + // 기본값(선 색 = 자동색 `#fff` · 바탕 따라 흰/검정)으로 채운다. 놓기 · [업데이트] · 다시 열기가 모두 여기를 지난다. + table.id = jsonEntity.id || table.id; + table.lineColor = jsonEntity.lineColor || table.lineColor; + table.lineWidth = jsonEntity.lineWidth ?? table.lineWidth; table.lineDash = jsonEntity.lineDash; return table; } diff --git a/B07_DesignDetail/openwebcad/src/integration/aislo-table-bridge.test.ts b/B07_DesignDetail/openwebcad/src/integration/aislo-table-bridge.test.ts index f11cab527..741cf8246 100644 --- a/B07_DesignDetail/openwebcad/src/integration/aislo-table-bridge.test.ts +++ b/B07_DesignDetail/openwebcad/src/integration/aislo-table-bridge.test.ts @@ -77,6 +77,28 @@ describe('표 놓기(PLACETABLE)', () => { }); }); +describe('선 색 없는 표(서버 표 변환 답 · 43-6)', () => { + it('id · 선 색 · 굵기가 없으면 기본값(자동색 #fff · 1 · 새 id)으로 채워 놓고 저장 JSON 에도 남음', async () => { + const json = await table('T8').toJson(); + if (!json) throw new Error('표 JSON 없음'); + const { id: _id, lineColor: _color, lineWidth: _width, layerId: _layer, ...bare } = json; + await handleTableMessage( + { type: AISLO_PLACE_TABLE_MESSAGE, entity: bare as typeof json, link: 'T8' }, + vi.fn() + ); + const pending = getPendingTable(); + expect(pending?.lineColor).toBe('#fff'); + expect(pending?.lineWidth).toBe(1); + const placed = tableAt(pending as TableEntity, new Point(0, 0), layer.id); + placed.lineColor = pending?.lineColor ?? ''; + const saved = await placed.toJson(); + expect(saved?.lineColor).toBe('#fff'); + const back = await TableEntity.fromJson(bare as typeof json); + expect(back.id).toBeTruthy(); + expect(back.lineColor).toBe('#fff'); + }); +}); + describe('표 칸 갈기(update-table)', () => { it('연결이 같은 표의 칸만 갈고 자리 · 크기는 그대로 · 되돌리기 한 걸음', () => { const linked = table('T1');