/* ============================================================================= * formula_doc_renew.ts * M01 자동 따라옴 알림(PLAN 836-2 · 요구 854) — M02 단가산출(프로젝트 층 밖)을 열 때 * M01 에서 바뀐 항목에 얹힌 내 고침을 지우고 다시 복사한 것을 한 번 보임(서버 `M02_Sk_AutoRenew.notes`) * 표 = 항목 · M01 전 → 후 · 지워진 내 고침 · [확인] = 저장(다시 안 뜸) · [나중에] = 다음에 열면 또 뜸 * 고침 없는 항목은 조용히 따라옴(알림 없음) * ========================================================================== */ import { askConfirm, el } from "@ui/ui_template_elements"; import { createTable } from "@ui/ui_template_table"; import { ft } from "./formula_doc_text"; /** 서버 알림 한 줄 — 갈래 = 문서(바탕 수식) · 부름(굳힌 부른 문서) · 기계(기계 덮음) */ export interface RenewNote { 키: string; 이름?: string; 갈래?: string; M01?: string[]; 내고침?: string[]; } /** 칸 안 여러 줄 — 줄마다 한 덩이 */ const lines = (xs: string[] | undefined): HTMLElement => el("div", { children: (xs ?? []).map((t) => el("div", { text: t })) }); /** 알림 창 — 확인이면 true(부르는 쪽이 저장) */ export function askRenew(notes: RenewNote[]): Promise { const table = createTable( [ { label: ft("Renew_Item"), width: "28%" }, { label: ft("Renew_M01") }, { label: ft("Renew_Mine") }, ], notes.map((n) => [lines([n.이름 || n.키, n.키]), lines(n.M01), lines(n.내고침)]), { density: "data" }, ); table.dataset.renewNotes = String(notes.length); return askConfirm({ title: ft("Renew_Title"), message: ft("Renew_Ask"), okLabel: ft("Renew_Ok"), cancelLabel: ft("Renew_Later"), detail: table, }); }