fix(M02): 보낸 표 놓기 전 탭을 바꾸면 그 장에 다시 놓기 · 저장 뒤 지금 장 미저장 표시 지움(82-3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NPJGtfXo6GMbcpiboQC4uK
This commit is contained in:
2026-10-08 13:05:17 +09:00
co-authored by Claude Opus 5.5
parent 4e18bca4e4
commit 52cd7e46cb
2 changed files with 55 additions and 12 deletions
@@ -92,7 +92,12 @@ export interface DrawingTemplateHandle {
placeTable: (entity: Record<string, unknown>, link: string) => void;
updateTable: (link: string, cells: unknown[][]) => Promise<number>;
/** 다른 장을 같은 CAD 에 실음(82-1) — 백업 칸 · 도각 도번도 그 장 것으로 */
loadSheet: (drawing: DrawingTemplateDoc, sheet: string, frameNumber?: string) => void;
loadSheet: (
drawing: DrawingTemplateDoc,
sheet: string,
frameNumber?: string,
after?: () => void,
) => Promise<void>;
destroy: () => void;
}
@@ -249,7 +254,8 @@ export function mountDrawingTemplate(
onHostSave: hostSave,
});
let loadSeq = 0;
const load = async (drawing: DrawingTemplateDoc): Promise<void> => {
/** `after` = 싣기를 보낸 바로 뒤(이 싣기가 마지막일 때만) — 표 놓기를 「열린 뒤」로 미룰 때 */
const load = async (drawing: DrawingTemplateDoc, after?: () => void): Promise<void> => {
const mine = ++loadSeq;
cad.beginLoading();
const frame = options.frame ? await fetchFrame(frameNumber) : null;
@@ -279,6 +285,7 @@ export function mountDrawingTemplate(
originMarker: options.originMarker === true,
},
);
after?.();
};
const actions = document.createElement("div");
@@ -346,11 +353,11 @@ export function mountDrawingTemplate(
getDoc,
placeTable: cad.placeTable,
updateTable: cad.updateTable,
loadSheet: (drawing, sheet, number) => {
loadSheet: (drawing, sheet, number, after) => {
recoveryScope = recoveryScopeOf(options, sheet);
frameNumber = number ?? "";
base = drawing;
void load(drawing);
return load(drawing, after);
},
destroy: () => {
areaModal?.close();
@@ -417,6 +424,13 @@ export function mountStructureSheets(
const more = doc.더한장 ?? [];
let cadDirty = false;
let listDirty = false;
/** 아직 안 놓은 보낸 표(82-3) — 놓기 전에 탭을 바꾸면 그 장에 다시 걺(놓을 장 = 지금 탭) */
let placing: { entity: Record<string, unknown>; link: string } | null = null;
const placed = (got: DrawingTemplateDoc, link: string): boolean =>
got.entities.some((e) => {
const style = (e as { shapeData?: { style?: Record<string, unknown> } }).shapeData?.style;
return e.type === "Table" && style?.연결 === link;
});
const report = (): void => options.onChanged?.(cadDirty || listDirty || tabs.anyDirty());
const numberOf = (id: string): string =>
sheetNumber(
@@ -426,13 +440,19 @@ export function mountStructureSheets(
const tabs: CadTabs<DrawingTemplateDoc> = createCadTabs<DrawingTemplateDoc>({
features: readOnly ? {} : { add: true, rename: true, remove: true, reorder: true },
capture: async () => ({ drawing: await drawing.getDoc(), dirty: cadDirty }),
show: (tab) => {
capture: async () => {
const got = await drawing.getDoc();
if (placing && placed(got, placing.link)) placing = null;
return { drawing: got, dirty: cadDirty };
},
show: async (tab) => {
cadDirty = false;
drawing.loadSheet(
// 놓기는 싣기를 보낸 바로 뒤 — cad_host 가 「열린 뒤」로 미룸(먼저 보내면 싣기가 도구를 끔)
await drawing.loadSheet(
tab.drawing ?? { entities: [], layers: [BLANK_LAYER] },
tab.id === FIRST_TAB ? "" : tab.id,
numberOf(tab.id),
() => placing && drawing.placeTable(placing.entity, placing.link),
);
report();
},
@@ -491,6 +511,7 @@ export function mountStructureSheets(
도면: tab.drawing ?? { format: 6, entities: [], layers: [{ ...BLANK_LAYER }] },
}));
listDirty = false;
cadDirty = false; // 받기(requestSave)가 CAD 미저장도 내림 — 다음 고침이 다시 알림
tabs.markClean(undefined, true);
return {
도면: first?.drawing ?? doc.도면,
@@ -501,7 +522,10 @@ export function mountStructureSheets(
const id = tabs.active()?.id ?? FIRST_TAB;
return id === FIRST_TAB ? "" : id;
},
placeTable: drawing.placeTable,
placeTable: (entity, link) => {
placing = { entity, link };
drawing.placeTable(entity, link);
},
// 실린 장은 CAD · 안 실린 장은 받아 둔 편집본에서(82-3)
updateTable: async (link, cells) => {
const now = tabs.active();