diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts index 33f599bfe..35704c6f4 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts @@ -27,7 +27,7 @@ import { diagramTitle, renderComboDiagram, } from "./M02_MasterTemplete_Labor_Diagram"; -import { openLaborInput, openQtyModal } from "./M02_MasterTemplete_Labor_Input"; +import { openLaborInput, openQtyModal, type GoArea } from "./M02_MasterTemplete_Labor_Input"; import { openLogicPicker } from "./M02_MasterTemplete_Labor_Pick"; import { logicTable, matTable } from "./M02_MasterTemplete_Labor_Rows"; import { tc } from "./M02_MasterTemplete_Labor_Text"; @@ -44,8 +44,8 @@ export interface LaborDetailOptions { readOnly: boolean; /** 저장 안 한 고침이 생기거나 사라짐 */ onChanged: (dirty: boolean) => void; - /** 「면적산출에서 잇기」 — 그 열 면적산출 상세로(없으면 단추 없음) */ - goArea: (() => void) | null; + /** 「면적산출에서 잇기」 — 그 열 면적산출 상세로(옮겨 가면 참 · 취소 = 거짓 · 없으면 단추 없음) */ + goArea: GoArea | null; } export interface LaborDetailHandle { diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts index 13afe0850..ce7aa9db1 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts @@ -17,6 +17,15 @@ import "./M02_MasterTemplete_Labor.css"; const fill = (text: string, value: string): string => text.replace("{value}", value); +/** 면적산출 상세로 감 — 옮겨 갔으면 참(물음에서 취소 = 거짓) */ +export type GoArea = () => Promise; + +/** 옮겨 갔을 때만 모달을 닫음 — 취소면 모달 · 넣던 값 그대로 */ +const leaveTo = + (go: GoArea, close: () => void): (() => void) => + () => + void go().then((moved) => moved && close()); + export interface QtySeat { /** 지금 수량 */ qty: LaborQty; @@ -116,8 +125,8 @@ export interface LaborInputOptions { memo: string | null; seat: QtySeat; readOnly: boolean; - /** 「면적산출에서 잇기」 — 모달을 닫고 면적산출 상세로(없으면 단추 없음) */ - goArea: (() => void) | null; + /** 「면적산출에서 잇기」 — 면적산출 상세로 감(옮겨 가면 참 · 「저장 안 한 고침」 물음에서 취소면 거짓 · 없으면 단추 없음) */ + goArea: GoArea | null; done: (next: LaborInputResult) => void; } @@ -165,15 +174,7 @@ export function openLaborInput(opt: LaborInputOptions): void { }) as HTMLInputElement; memo.value = opt.memo ?? ""; memo.readOnly = opt.readOnly; - const qty = qtyPart( - opt.seat, - opt.readOnly, - opt.goArea && - (() => { - close(); - opt.goArea?.(); - }), - ); + const qty = qtyPart(opt.seat, opt.readOnly, opt.goArea && leaveTo(opt.goArea, close)); const ok = (): void => { if (bad.size) return showToast(tc("In_Bad"), "error"); const 수량 = qty.read(); @@ -217,7 +218,7 @@ export function openQtyModal( title: string, seat: QtySeat, readOnly: boolean, - goArea: (() => void) | null, + goArea: GoArea | null, done: (qty: LaborQty) => void, ): void { openModal({ @@ -225,15 +226,7 @@ export function openQtyModal( closeLabel: tc("In_Close"), dialogClass: "m02-modal m02-labin", mount: (body, close) => { - const qty = qtyPart( - seat, - readOnly, - goArea && - (() => { - close(); - goArea(); - }), - ); + const qty = qtyPart(seat, readOnly, goArea && leaveTo(goArea, close)); const ok = (): void => { const 수량 = qty.read(); if (수량 === undefined) return showToast(tc("In_QtyNeed"), "error"); diff --git a/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts b/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts index 7637780c2..450fc31a7 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts @@ -370,7 +370,9 @@ export function createMain( readOnly, onChanged: (d) => (dirty = d && !readOnly), goArea: async () => { - if (await confirmLeave()) void open({ ...at, kind: "area" }); + if (!(await confirmLeave())) return false; // 취소 — 입력 모달 그대로 + void open({ ...at, kind: "area" }); + return true; }, }); return;