diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor.css b/M02_MasterTemplete/M02_MasterTemplete_Labor.css index 7f212df44..bf59b0c4f 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor.css +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor.css @@ -90,6 +90,14 @@ white-space: nowrap; } +/* 순서 칸 2행(51-14) — 위 [위로] [아래로] / 아래 [옵션]·[수정] [삭제] · 줄 사이도 단추 묶음 간격 */ +.m02-labrow__tools { + display: inline-flex; + flex-direction: column; + align-items: flex-start; + gap: var(--btn-group-gap); +} + /* 옵션 값 줄(44-6) — 이름 ~ 합계에 걸친 한 줄 말줄임(max-width 0 = 표 폭을 안 늘림) · 위 줄과 한 덩이 */ .m02-labrow .m02-labrow__optrow td { padding-top: 0; @@ -179,6 +187,11 @@ color: var(--color-primary); } +/* 참조 줄 모달(51-14) — 일위조합 [수정] = 사전조합 상세 */ +.m02-labref { + width: min(72rem, calc(100vw - 32px)); +} + /* 입력 모달 */ .m02-labin { width: min(40rem, calc(100vw - 32px)); diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Api.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Api.ts index d4c4bf6c6..c896cb70a 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Api.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Api.ts @@ -233,7 +233,7 @@ export interface LibraryRow { 이름: string; 제목?: string | null; 단위?: string | null; - /** 51-12 — 승격 = 원 로직 것 · 사전조합 = 고른 것 */ + /** 단가승격 = 원 로직 것 · 사전조합 = 사용자가 고름(51-12) */ 구분?: string | null; 상세구분?: string | null; } diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Calc.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Calc.ts index 0e8ee2a49..54e3b3e2e 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Calc.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Calc.ts @@ -36,11 +36,13 @@ export interface CalcLine { 결과?: unknown; /** 그 로직 재료 · 노무 · 경비 줄(M01 시험계산 표와 같은 모양 · 50-4) */ 줄?: LogicLine[]; - /** 참조 줄 — 가리킨 문서 이름 · 단가승격의 원 로직 키 · 사전조합 안 줄(한 층 · 50-3 ④) */ + /** 참조 줄 — 가리킨 문서 이름 · 단가승격의 원 로직 키 · 사전조합 안 줄(한 층 · 50-3 ④ · + * 참조 줄 = `참조` · 로직 줄(51-11) = `로직`) */ 이름?: string | null; 원로직?: string | null; 안?: { - 참조: LaborRef; + 참조?: LaborRef; + 로직?: string; 수량: number; 이름?: string | null; 단위?: string | null; diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts index 31e8cd9b9..236f211c6 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Detail.ts @@ -3,7 +3,7 @@ * 일위대가 상세(39-3) — 구조물 열마다 하나(`labor/<열>.json`) · UI_Main 종류 `labor` 가 이 부품을 붙임 * (양식 길 읽기 · [저장] · [다시 읽기]는 UI_Main). 차례 = 정보(단위 · 본뜬) → 담은 로직 → 자재목록 → 다이어그램. * · 담은 로직 줄 누름 = 고름(하이라이트 · 다시 그려도 유지 · 47-5) + 그 줄 바로 아래 하위 행(51-2 · `Labor_Rows`) · - * 같은 줄 다시 누르면 닫힘 · [옵션] = 입력 모달(`Labor_Input`) · + * 같은 줄 다시 누르면 닫힘 · [옵션] = 입력 모달(`Labor_Input`) · 참조 줄 [옵션] · [수정] = 서고 원본 모달(51-14 · `Labor_RefEdit`) · * [확인] = 화면 캐시만 · 저장은 [저장] * · 금액 = 서버 calc(기준 ③ · 최신 응답만 · 저장 안 함) · 고칠 때마다 뒤에서 다시 셈 * · 같은 로직 두 번 · 같은 자재 두 번 막음 · 빈 일위대가도 저장 됨 @@ -56,6 +56,7 @@ import { } from "./M02_MasterTemplete_Labor_Diagram"; import { openLaborInput, type GoArea } from "./M02_MasterTemplete_Labor_Input"; import { openQtyModal } from "./M02_MasterTemplete_Labor_QtyModal"; +import { openRefEdit } from "./M02_MasterTemplete_Labor_RefEdit"; import { openLogicPicker } from "./M02_MasterTemplete_Labor_Pick"; import { logicTable, matTable, qtyShort } from "./M02_MasterTemplete_Labor_Rows"; import { tc } from "./M02_MasterTemplete_Labor_Text"; @@ -183,12 +184,13 @@ export function mountLaborDetail( ? { open: pick, option: openRow, + ref: openRef, qty: openQty, ...(opt.card ? {} : { move }), remove: removeRow, alias: setAlias, } - : { open: pick, option: openRow }, + : { open: pick, option: openRow, ref: openRef }, ), ); const draw = (): void => { @@ -356,6 +358,19 @@ export function mountLaborDetail( }); } + /** 참조 줄 [옵션] · [수정](51-14) — 서고 원본 모달 · 자기 층 서고만 고침(위 층 = 읽기만 · 서버도 막음) · + * 닫으면 다시 셈(원본이 바뀌었을 수 있음) */ + function openRef(i: number): void { + const ref = cur.담은로직[i].참조; + if (!ref) return; + void openRefEdit({ + ref, + title: `${ref.키} ${lineOf(lineId({ 참조: ref }) ?? "")?.이름 ?? ""}`.trim(), + readOnly: !edit || ref.층 !== opt.layer, + closed: () => alive && recalc(), + }); + } + /** 수량산출 칸 누름 — 로직 줄 */ function openQty(i: number): void { const row = cur.담은로직[i]; diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts index 019b3541a..f60fe5c0d 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Input.ts @@ -19,14 +19,19 @@ const fill = (text: string, value: string): string => text.replace("{value}", va /** 면적산출 상세로 감 — 옮겨 갔으면 참(물음에서 취소 = 거짓) */ export type GoArea = () => Promise; -function footer(readOnly: boolean, ok: () => void, close: () => void): HTMLElement { +function footer( + readOnly: boolean, + ok: () => void, + close: () => void, + okLabel = tc("In_Ok"), +): HTMLElement { return el("div", { className: "m02-labin__foot", children: readOnly ? [createButton({ label: tc("In_Close"), variant: "ghost", onClick: close })] : [ createButton({ label: tc("In_Cancel"), variant: "ghost", onClick: close }), - createButton({ label: tc("In_Ok"), variant: "filled", onClick: ok }), + createButton({ label: okLabel, variant: "filled", onClick: ok }), ], }); } @@ -45,6 +50,10 @@ export interface LaborInputOptions { memo: string | null; readOnly: boolean; done: (next: LaborInputResult) => void; + /** 머리 한 줄 알림(51-14 · 서고 원본 고침) */ + notice?: string; + /** 확인 단추 글(기본 「확인」) */ + okLabel?: string; } /** 담은 로직 줄 입력 모달 */ @@ -100,6 +109,15 @@ export function openLaborInput(opt: LaborInputOptions): void { el("div", { className: "m02-inputval", children: [ + ...(opt.notice + ? [ + el("p", { + className: "m02-labin__muted", + text: opt.notice, + attrs: { "data-labor-notice": "" }, + }), + ] + : []), ...(lost.length ? [ el("p", { @@ -120,7 +138,7 @@ export function openLaborInput(opt: LaborInputOptions): void { }), ], }), - footer(opt.readOnly, ok, close), + footer(opt.readOnly, ok, close, opt.okLabel), ); }, }); diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts index af891ca02..ebf61477e 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Pick.ts @@ -82,7 +82,6 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra (!detail.select.value || x.상세구분 === detail.select.value) && (!q || `${x.키} ${x.이름}`.toLowerCase().includes(q)), ); - // 서고 줄도 구분 · 상세구분으로 거름(51-12) const libFound = libRows.filter( (x) => (!sub.select.value || x.row.구분 === sub.select.value) && @@ -114,7 +113,9 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra key: x.row.이름, tag: tc(x.kind), name: x.row.제목 || x.row.이름, - sub: `${x.row.이름} · ${x.row.구분 ?? ""} ${x.row.상세구분 ?? ""}`.trim(), + sub: [x.row.이름, `${x.row.구분 ?? ""} ${x.row.상세구분 ?? ""}`.trim()] + .filter(Boolean) + .join(" · "), unit: x.row.단위 ?? "", onPick: () => { close(); @@ -146,6 +147,7 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"); } loading = false; + drawSubs(); find(); }; const drawLayers = (): void => @@ -162,10 +164,28 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra }), ), ); - sub.select.addEventListener("change", () => { - const d = subs.find((s) => s.name === sub.select.value)?.details ?? []; - detail.setOptions(opts(d), ""); + /** 구분 → 상세구분 — 로직 구분에 서고 줄(승격 · 조합) 것을 더함 · 같은 값은 한 칸 */ + const subMap = (): Map> => { + const m = new Map(subs.map((s) => [s.name, new Set(s.details)])); + for (const { row } of libRows) { + if (!row.구분) continue; + if (!m.has(row.구분)) m.set(row.구분, new Set()); + if (row.상세구분) m.get(row.구분)!.add(row.상세구분); + } + return m; + }; + const drawDetails = (keep: string): void => { + const d = [...(subMap().get(sub.select.value) ?? [])]; + detail.setOptions(opts(d), d.includes(keep) ? keep : ""); detail.select.disabled = d.length === 0; + }; + const drawSubs = (): void => { + const keep = detail.select.value; + sub.setOptions(opts([...subMap().keys()]), sub.select.value); + drawDetails(keep); + }; + sub.select.addEventListener("change", () => { + drawDetails(""); find(); }); detail.select.addEventListener("change", find); @@ -206,8 +226,8 @@ export function openLogicPicker(done: (logic: LogicSummary) => void, lib?: Libra .then(([s, l]) => { subs.push(...s); all = l; + drawSubs(); find(); - sub.setOptions(opts(s.map((x) => x.name)), ""); }) .catch((error) => showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"), diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_RefEdit.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_RefEdit.ts new file mode 100644 index 000000000..4ecb9e78f --- /dev/null +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_RefEdit.ts @@ -0,0 +1,134 @@ +/* ============================================================================= + * M02_MasterTemplete_Labor_RefEdit.ts + * 일위대가 참조 줄 모달(51-14) — 서고 원본(50-3)을 그 자리에서 고침 · [저장] = 서고 저장 길(`saveTemplate`) · + * 그 문서를 쓰는 모든 구조물에 따라감(머리 한 줄 알림) · 그 층을 못 고치면 읽기만. + * · 단가승격 [옵션] = 승격 문서 로직 한 줄의 넣을 값 모달(`Labor_Input`) + * · 일위조합 [수정] = 사전조합 상세(서고 모드 표 · 안 줄 [옵션] · 수량 · 위로 · 아래로 · 삭제 · 추가) + * 닫으면(저장 · 취소 모두) `closed` — 부르는 쪽이 구조물 일위대가 표를 다시 셈. + * ========================================================================== */ + +import { createButton, el, showConfirmDialog, showToast } from "@ui/ui_template_elements"; +import { openModal } from "@ui/ui_template_modal"; +import { readTemplate, saveTemplate, type Layer } from "./M02_MasterTemplete_Api_Fetch"; +import { fetchLogicInputs, type LaborRow } from "./M02_MasterTemplete_Labor_Api"; +import type { LaborRef } from "./M02_MasterTemplete_Labor_Calc"; +import { openLaborInput } from "./M02_MasterTemplete_Labor_Input"; +import { tc } from "./M02_MasterTemplete_Labor_Text"; +import { keepKnown } from "./M02_Labor_Values_Model"; + +export interface RefEditOptions { + ref: LaborRef; + /** 「SP-000001 메쌓기」 */ + title: string; + readOnly: boolean; + closed: () => void; +} + +const fail = (error: unknown, key: "Load_Failed" | "Lib_SaveFailed"): void => + showToast(error instanceof Error ? error.message : tc(key), "error"); + +export async function openRefEdit(opt: RefEditOptions): Promise { + const kind = opt.ref.키.startsWith("SP-") ? "promote" : "precombo"; + const layer = opt.ref.층 as Layer; + let doc: { 담은로직?: LaborRow[] }; + let 판: string; + try { + const got = await readTemplate(layer, kind, opt.ref.키, null); + doc = got.문서 as typeof doc; + 판 = got.판 ?? ""; + } catch (error) { + return fail(error, "Load_Failed"); + } + const save = (body: unknown): Promise => + saveTemplate(layer, kind, opt.ref.키, null, 판, body).then(() => + showToast(tc("Saved"), "success"), + ); + const notice = opt.readOnly ? `${tc("Ref_Shared")} · ${tc("Ref_ReadOnly")}` : tc("Ref_Shared"); + + if (kind === "promote") { + const row = doc.담은로직?.[0]; + if (!row) return fail(null, "Load_Failed"); + const logic = row.로직 + ? ((await fetchLogicInputs([row.로직]).catch(() => null))?.로직[0] ?? null) + : null; + return openLaborInput({ + title: opt.title, + logic, + values: row.입력값, + memo: row.메모, + readOnly: opt.readOnly, + notice, + okLabel: tc("Save"), + done: (next) => { + row.입력값 = logic ? keepKnown(logic.입력, next.입력값).kept : next.입력값; + row.메모 = next.메모; + void save(doc) + .catch((error) => fail(error, "Lib_SaveFailed")) + .finally(opt.closed); + }, + }); + } + + // 사전조합 — 상세와 같은 부품(서로 부르므로 늦게 받음) + const { mountLaborDetail } = await import("./M02_MasterTemplete_Labor_Detail"); + let dirty = false; + let handle: ReturnType | null = null; + const finish = (): void => { + handle?.destroy(); + opt.closed(); + }; + openModal({ + title: opt.title, + closeLabel: tc("In_Close"), + dialogClass: "m02-modal m02-labref", + beforeClose: async () => { + if (dirty && !(await showConfirmDialog(tc("Ref_Discard")))) return false; + finish(); + return true; + }, + mount: (body, close) => { + const host = el("div", { attrs: { "data-labor-ref": opt.ref.키 } }); + handle = mountLaborDetail(host, doc, { + layer, + column: opt.ref.키, + readOnly: opt.readOnly, + onChanged: (d) => (dirty = d && !opt.readOnly), + goArea: null, + mode: "precombo", + }); + const cancel = createButton({ + label: tc(opt.readOnly ? "In_Close" : "In_Cancel"), + variant: "ghost", + onClick: async () => { + if (dirty && !(await showConfirmDialog(tc("Ref_Discard")))) return; + close(); + finish(); + }, + }); + const ok = createButton({ + label: tc("Save"), + variant: "filled", + onClick: () => + void save(handle?.getDoc()).then( + () => { + close(); + finish(); + }, + (error) => fail(error, "Lib_SaveFailed"), + ), + }); + body.append( + el("p", { + className: "m02-labin__muted", + text: notice, + attrs: { "data-labor-notice": "" }, + }), + host, + el("div", { + className: "m02-labin__foot", + children: opt.readOnly ? [cancel] : [cancel, ok], + }), + ); + }, + }); +} diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Rows.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Rows.ts index 94b8ed902..bcdd9122b 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Rows.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Rows.ts @@ -6,7 +6,8 @@ * 옵션 값(「지역 서울 · 규격 25mm」)은 줄 아래 이름 ~ 합계에 걸친 한 줄 · 맨 아래 합계 줄(전체 합계 강조). * 자재목록 = 코드 · 이름 · 규격 · 수량산출 · 단위 · 가격 다섯(기준 칸 강조) · 기준단가 / 반영 금액(43-3). * 금액은 calc 답(없으면 「…」). - * 줄 누름 · 줄 단추(위로 · 아래로 · 옵션 · 삭제 · 묶음 `ui-btn-group`)는 `on` 이 있을 때만(보기 갈래 = 없음) · + * 줄 누름 · 줄 단추는 `on` 이 있을 때만(보기 갈래 = 없음) — 순서 칸 2행(51-14 · 위 [위로] [아래로] / 아래 [옵션] 또는 [수정] · [삭제] · + * 묶음 `ui-btn-group` · 순서 없는 카드 갈래 = 아래 줄만) · 단가승격 줄 = [옵션] · 일위조합 줄 = [수정](`ref` · 서고 원본) · * 상세는 줄 누름 = 고름(`selected` 줄 하이라이트 · 그 줄 바로 아래 하위 행 · 51-2 · 화살표 없음 51-7) · 넣을 값 모달은 [옵션](47-5). * ========================================================================== */ @@ -174,6 +175,8 @@ export interface RowHandlers { open: (i: number) => void; /** [옵션] 단추(47-5 · 넣을 값 모달) — 없으면 단추 없음 */ option?: (i: number) => void; + /** 참조 줄 단추(51-14) — 단가승격 [옵션] · 일위조합 [수정] = 서고 원본 모달 · 없으면 단추 없음 */ + ref?: (i: number) => void; /** 수량산출 칸 누름(손 입력 · 엑셀에서 고르기) — 없으면 줄 누름과 같음 */ qty?: (i: number) => void; move?: (i: number, d: number) => void; @@ -229,17 +232,22 @@ export interface LogicTableData { } /** 고른 줄 하위 행(51-2 · 같은 표 · 같은 칸) — 단가산출 · 단가승격 = 그 로직 재료 · 노무 · 경비 줄 · - * 사전조합 = 안 줄 · 금액 칸 = 위 기준(위 줄 기준과 같은 바탕) / 아래 반영(× 위 줄 수량 ÷ 배) · + * 일위조합 = 세부 항목 한 층(51-13 · 참조 줄 · 로직 줄 · 안을 다시 펼치지 않음 · 금액 = 안 줄 기준 × 안 줄 수량) · + * 금액 칸 = 위 기준(위 줄 기준과 같은 바탕) / 아래 반영(× 위 줄 수량 ÷ 배) · * 하위 합 = 위 줄 금액 · 줄이 없으면 빈 한 줄(「…」 · 까닭 · 「—」) */ function subRows(line: LaborCalcLine | undefined, wait: boolean, tools: boolean): HTMLElement[] { const times = line?.수량 === null || line?.수량 === undefined ? null : line.수량 / (line.배 || 1); const items = line?.안 - ? line.안.map((x) => ({ - name: `${x.참조.키} ${x.이름 ?? ""}${x.까닭 ? ` · ${x.까닭}` : ""}`.trim(), - qty: x.수량, - unit: x.단위 ?? "", - cost: x.기준 ? Object.fromEntries(COSTS.map((c) => [c, x.기준![c] * x.수량])) : null, - })) + ? line.안.map((x) => { + const key = x.참조?.키 ?? x.로직 ?? ""; + const label = x.이름 && x.이름 !== key ? `${key} ${x.이름}` : key; // 로직 줄 이름 없으면 키만 + return { + name: `${label}${x.까닭 ? ` · ${x.까닭}` : ""}`, + qty: x.수량, + unit: x.단위 ?? "", + cost: x.기준 ? Object.fromEntries(COSTS.map((c) => [c, x.기준![c] * x.수량])) : null, + }; + }) : (line?.줄 ?? []).map((x) => ({ name: x.출처 ? `${x.이름} (${x.출처.replace(/[A-Z]{2}\d{6}\./g, "")})` : x.이름, qty: x.수량, @@ -285,9 +293,11 @@ function subRows(line: LaborCalcLine | undefined, wait: boolean, tools: boolean) /** 담은 로직 표 — 보기 갈래는 `on` 없이 */ export function logicTable(data: LogicTableData, on?: RowHandlers): HTMLElement { const wait = !data.calc && !data.fail; - const { move, remove, option } = on ?? {}; + const { move, remove, option, ref } = on ?? {}; // 옵션 · 삭제만(구조물 조합 카드 · 43-4)이어도 끝 칸 — 순서 단추는 `move` 가 있을 때만 - const tools = !!(move || remove || option); + const tools = !!(move || remove || option || ref); + const group = (children: HTMLElement[]): HTMLElement => + el("div", { className: "ui-btn-group", children }); const lineOf = (key: string): LaborCalcLine | undefined => data.calc?.줄.find((l) => lineId(l) === key); const trs = data.rows.flatMap((row, i) => { @@ -357,13 +367,31 @@ export function logicTable(data: LogicTableData, on?: RowHandlers): HTMLElement className: "m02-labrow__move", children: [ el("div", { - className: "ui-btn-group", + className: "m02-labrow__tools", children: [ ...(move - ? [small(tc("Up"), () => move(i, -1)), small(tc("Down"), () => move(i, 1))] + ? [ + group([ + small(tc("Up"), () => move(i, -1)), + small(tc("Down"), () => move(i, 1)), + ]), + ] : []), - ...(option && !row.참조 ? [small(tc("Labor_Option"), () => option(i))] : []), - ...(remove ? [small(tc("Remove"), () => remove(i), "danger")] : []), + group([ + ...(row.참조 + ? ref + ? [ + small( + tc(row.참조.키.startsWith("SP-") ? "Labor_Option" : "Labor_Edit"), + () => ref(i), + ), + ] + : [] + : option + ? [small(tc("Labor_Option"), () => option(i))] + : []), + ...(remove ? [small(tc("Remove"), () => remove(i), "danger")] : []), + ]), ], }), ], diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Text.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Text.ts index 9ac8e5424..64eebefb1 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Text.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Text.ts @@ -35,6 +35,14 @@ const TEXT = { Down: ["아래로", "Down"], Remove: ["삭제", "Delete"], Labor_Option: ["옵션", "Options"], + Labor_Edit: ["수정", "Edit"], + Ref_Shared: [ + "서고 원본을 고침 — 이 문서를 쓰는 모든 구조물에 따라감", + "Edits the library original — every structure using it follows", + ], + Ref_ReadOnly: ["이 층은 고칠 수 없음 — 읽기만", "Read-only layer"], + Lib_SaveFailed: ["저장 못 함", "Save failed"], + Ref_Discard: ["저장 안 한 고침을 버리고 닫음?", "Discard unsaved edits?"], Labor_Source: ["원문", "Source"], Labor_SourceHint: [ "단가산출 로직 줄을 고르면 그 원문이 보임", diff --git a/resources/master_template/precombo/SC-000001.json b/resources/master_template/precombo/SC-000001.json index c24f868cc..cb35b6b86 100644 --- a/resources/master_template/precombo/SC-000001.json +++ b/resources/master_template/precombo/SC-000001.json @@ -3,6 +3,23 @@ "키": "SC-000001", "이름": "테스트 사전조합", "단위": null, - "담은로직": [], + "담은로직": [ + { + "로직": "GF000297", + "입력값": {}, + "수량": { + "손": 1 + }, + "메모": null + }, + { + "로직": "GF000289", + "입력값": {}, + "수량": { + "손": 1 + }, + "메모": null + } + ], "본뜬": null } diff --git a/resources/tester/test_m02_card_shell.py b/resources/tester/test_m02_card_shell.py index 8882439d8..6b03b170e 100644 --- a/resources/tester/test_m02_card_shell.py +++ b/resources/tester/test_m02_card_shell.py @@ -86,7 +86,9 @@ def test_일위대가_카드는_상세_카드_갈래(): assert "...(opt.card || lib ? [] : [dgBox])," in detail assert "opt.card ? null : addMat" in detail # 49-6 — 카드엔 [자재 추가] 없음 · 상세는 그대로 rows = _text("M02_MasterTemplete_Labor_Rows.ts") - assert "const tools = !!(move || remove || option);" in rows and "compactTable" not in rows + assert ( + "const tools = !!(move || remove || option || ref);" in rows and "compactTable" not in rows + ) assert "compact" not in _text("M02_MasterTemplete_Labor_View.ts").split("*/", 1)[1] @@ -127,7 +129,9 @@ def test_일위대가_줄_고름과_옵션_단추(): 단추 위로 · 아래로 · 옵션 · 삭제(빨강) · 묶음 간격 = 공용 `ui-btn-group`.""" detail = _text("M02_MasterTemplete_Labor_Detail.ts") assert "open: pick," in detail and "option: openRow," in detail - assert "{ open: pick, option: openRow }" in detail # 읽기만도 고름 · [옵션] = 보기 모달 + assert ( + "{ open: pick, option: openRow, ref: openRef }" in detail + ) # 읽기만도 고름 · [옵션] = 보기 모달 assert "selected: picked" in detail rows = _text("M02_MasterTemplete_Labor_Rows.ts") up, down = rows.index('small(tc("Up")'), rows.index('small(tc("Down")') @@ -141,3 +145,18 @@ def test_일위대가_줄_고름과_옵션_단추(): assert t in text css = (ROOT / "ui_template" / "ui_template_general_layout.css").read_text(encoding="utf-8") assert ".ui-btn-group {" in css and "gap: var(--btn-group-gap);" in css + + +def test_순서칸_2행_참조줄_옵션_수정(): + """51-14 — 순서 칸 2행(위 [위로] [아래로] / 아래 [옵션]·[수정] [삭제]) · 단가승격 [옵션] · 일위조합 [수정] = + 서고 원본 모달(저장 = 서고 저장 길 · 자기 층만 고침) · 닫으면 다시 셈.""" + rows = _text("M02_MasterTemplete_Labor_Rows.ts") + assert 'className: "m02-labrow__tools"' in rows + assert '"SP-") ? "Labor_Option" : "Labor_Edit"' in rows + detail = _text("M02_MasterTemplete_Labor_Detail.ts") + assert "readOnly: !edit || ref.층 !== opt.layer," in detail + assert "closed: () => alive && recalc()," in detail + ref = _text("M02_MasterTemplete_Labor_RefEdit.ts") + assert "saveTemplate(layer, kind, opt.ref.키, null, 판, body)" in ref + assert 'mode: "precombo",' in ref and "showConfirmDialog" in ref + assert 'Labor_Edit: ["수정"' in _text("M02_MasterTemplete_Labor_Text.ts") diff --git a/resources/tester/ui_checks/51-12_고르기_구분.js b/resources/tester/ui_checks/51-12_고르기_구분.js new file mode 100644 index 000000000..9361d5031 --- /dev/null +++ b/resources/tester/ui_checks/51-12_고르기_구분.js @@ -0,0 +1,97 @@ +/* 51-12 — 로직 고르기 창 구분 · 상세구분 거름에 단가승격 · 사전조합 줄도 들어감 + * 시작 화면: M02 마스터 템플릿 · 마스터 층(#/m02-master-template?open=구조물조합&root=master) · 시스템 관리자 · item1 있음 + * 부르는 법: orca eval --expression "$(tr ' +' ' ' < 이 파일)" (async 식 · JSON 글을 돌려줌) + * 하는 일: item1 → 일위대가 [수정] → [로직 추가] → 서고 줄마다 구분 · 상세구분으로 걸러 봄 → 창 닫음(저장 안 함) + * 기대 수치: + * - libRows ≥ 2(SP-000001 · SC-000001 포함) + * - lib[키].sub = 한 구분(빈 값 아님) · lib[키].detail = 한 상세구분 · lib[키].subText 에 둘이 다 보임 + * - lib[키].withLogic = true(같은 구분 칸에 단가산출 줄도 함께 — 같은 값은 한 칸) + * - subDup = 0(구분 칸 겹침 없음) + */ +(async () => { + const w = (ms) => new Promise((r) => setTimeout(r, ms)); + const until = async (fn, ms = 8000) => { + for (let t = 0; t < ms; t += 150) { + const v = fn(); + if (v) return v; + await w(150); + } + return null; + }; + const out = {}; + const node = await until(() => document.querySelector('[data-node="i|item1"]')); + if (!node) return JSON.stringify({ error: "item1 없음" }); + node.click(); + const card = await until(() => + [...document.querySelectorAll(".m02-struct__card")].find((c) => + c.querySelector("table.m02-labrow tbody tr[data-labor-logic]"), + ), + ); + if (!card) return JSON.stringify({ error: "일위대가 카드 없음" }); + [...card.querySelectorAll(".m02-struct__card-tools button")] + .find((b) => b.innerText.trim() === "수정") + ?.click(); + const table = () => + [...document.querySelectorAll("table.m02-labrow")].find( + (t) => !t.closest(".m02-struct__card") && t.querySelector("tr[data-labor-logic]"), + ); + await until(() => table() && !/…/.test(table().querySelector("tbody").innerText), 12000); + const host = table().closest("[data-labor]"); + [...host.querySelectorAll(".m01-logic__section-head button")] + .find((b) => b.innerText.trim() === "로직 추가") + .click(); + const dlg = await until(() => document.querySelector(".m01-logic__pick")); + const rows = () => [...dlg.querySelectorAll(".ui-find__row")]; + const isLib = (r) => r.querySelector(".ui-find__tag")?.innerText.trim() !== "단가산출"; + await until(() => rows().some(isLib) && rows().some((r) => !isLib(r)), 20000); + await w(500); + const [subSel, detailSel] = dlg.querySelectorAll(".ui-find__filters select"); + const set = async (sel, v) => { + sel.value = v; + sel.dispatchEvent(new Event("change", { bubbles: true })); + await w(120); + }; + const libKeys = rows() + .filter(isLib) + .map((r) => r.dataset.pick); + out.libRows = libKeys.length; + const subVals = [...subSel.options].map((o) => o.value).filter(Boolean); + out.subDup = subVals.length - new Set(subVals).size; + const lib = {}; + for (const k of libKeys) + lib[k] = { + subText: rows() + .find((r) => r.dataset.pick === k) + ?.querySelector(".ui-find__sub")?.innerText, + sub: [], + detail: [], + withLogic: false, + }; + for (const s of subVals) { + await set(subSel, s); + const shown = rows(); + const hasLogic = shown.some((r) => !isLib(r)); + for (const r of shown.filter(isLib)) { + if (!lib[r.dataset.pick]) continue; + lib[r.dataset.pick].sub.push(s); + lib[r.dataset.pick].withLogic ||= hasLogic; + } + for (const d of [...detailSel.options].map((o) => o.value).filter(Boolean)) { + await set(detailSel, d); + for (const r of rows().filter(isLib)) lib[r.dataset.pick]?.detail.push(d); + } + await set(detailSel, ""); + } + await set(subSel, ""); + out.lib = lib; + [...dlg.querySelectorAll("button")].find((b) => b.innerText.trim() === "닫기")?.click(); + out.closed = !document.querySelector(".m01-logic__pick"); + document.querySelector('[data-node="i|item1"]')?.click(); + await w(800); + const ask = [...document.querySelectorAll(".ui-modal button, dialog button")].find((x) => + /확인|버림|떠나기/.test(x.innerText), + ); + ask?.click(); + return JSON.stringify(out); +})(); diff --git a/resources/tester/ui_checks/51-13_일위조합_하위행.js b/resources/tester/ui_checks/51-13_일위조합_하위행.js new file mode 100644 index 000000000..c40dc1b7b --- /dev/null +++ b/resources/tester/ui_checks/51-13_일위조합_하위행.js @@ -0,0 +1,132 @@ +/* 51-13 — 일위대가 표 구분 「일위조합」 줄 누름 = 하위 행 = 그 조합 세부 항목 한 층(참조 줄 · 로직 줄 51-11) — 카드 · 상세 두 곳 + * 시작 화면: M02 마스터 템플릿 · 마스터 층(#/m02-master-template?open=구조물조합&root=master) · 시스템 관리자 · + * 나무에 item3(단가승격 SP-000001 · 일위조합 SC-000001 줄이 있음) + * 부르는 법: orca eval --expression "$(cat 이 파일)" (async 식 · JSON 글을 돌려줌) + * 쓰기 없음 — item3 calc 답만 바꿔 끼움(fetch · 끝에 되돌림): SC 줄 「안」 = [SP-000001 × 2 · 첫 단가산출 로직 줄 × 1.5] + * (안 줄 기준 = 같은 답의 그 줄 기준 · SC 기준 = 안 기준 × 수량 합 · SC 수량 손 3 · 반영 = 기준 × 3 · 서고 저장 없음) + * 기대 수치(카드 · 상세 같음): + * - sc.subs = sc.inner(2) · sc.cells = [head] · sc.next = true + * - sc.base ≈ sc.subBase(위 줄 기준 = 하위 합 · 반올림 차 ≤ 2) · sc.applied ≈ sc.subApplied ≈ sc.base × 3 + * - sc.names[0] 「SP-000001 …」 · sc.names[1] 「<로직 키>」(로직 줄 · 깨지지 않음) + * - sc.qty = ["2", "1.5"](안 줄 수량) · sp.subs ≥ 1(단가승격 하위 행 그대로) + */ +(async () => { + const w = (ms) => new Promise((r) => setTimeout(r, ms)); + const until = async (fn, ms = 8000) => { + for (let t = 0; t < ms; t += 150) { + const v = fn(); + if (v) return v; + await w(150); + } + return null; + }; + const SC = "참조|system||SC-000001"; + const SP = "참조|system||SP-000001"; + const KEYS = ["노무비", "재료비", "경비", "계"]; + const real = window.fetch; + let inner = 0; + window.fetch = async (input, init) => { + const res = await real(input, init); + const url = typeof input === "string" ? input : input.url; + if (!/\/labor\/item3\/calc/.test(url) || !res.ok) return res; + const j = await res.clone().json(); + const sc = j.줄.find((l) => l.참조?.키 === "SC-000001"); + const sp = j.줄.find((l) => l.참조?.키 === "SP-000001"); + const lg = j.줄.find((l) => !l.참조 && l.기준); + if (sc && sp?.기준 && lg) { + sc.안 = [ + { 참조: sp.참조, 수량: 2, 이름: sp.이름, 단위: sp.분모, 기준: sp.기준, 까닭: null }, + { 로직: lg.로직, 수량: 1.5, 이름: lg.로직, 단위: null, 기준: lg.기준, 까닭: null }, + ]; + sc.기준 = Object.fromEntries(KEYS.map((k) => [k, sp.기준[k] * 2 + lg.기준[k] * 1.5])); + Object.assign(sc, { 수량: 3, 수량출처: "손" }); // 위 줄 수량 3 — 반영 = 기준 × 3 + sc.반영 = Object.fromEntries(KEYS.map((k) => [k, sc.기준[k] * 3])); + inner = sc.안.length; + } + return new Response(JSON.stringify(j), { status: 200, headers: res.headers }); + }; + const n = (s) => Number(String(s ?? "").replace(/[^0-9.-]/g, "")) || 0; + const total = (tr, part) => { + const tds = tr.querySelectorAll(".m02-labrow__money"); + return n(tds[tds.length - 1].querySelector(part).innerText); + }; + const settled = (get) => + until(() => { + const t = get(); + return t && !/…/.test(t.querySelector("tbody").innerText) ? t : null; + }, 10000); + const open = async (get, key) => { + get().querySelector(`tr[data-labor-logic="${key}"] .m02-labrow__name`).click(); + await w(300); + const tb = get(); + const tr = tb.querySelector(`tr[data-labor-logic="${key}"]`); + const subs = [...tb.querySelectorAll("tbody tr[data-labor-sub]")]; + let at = tr.nextElementSibling; + if (at?.hasAttribute("data-labor-opt")) at = at.nextElementSibling; + return { tb, tr, subs, next: at === subs[0] }; + }; + const measure = async (get) => { + const t = await settled(get); + const head = t.querySelectorAll("thead th").length; + const sp = await open(get, SP); + const { tr, subs, next } = await open(get, SC); + const out = { + head, + sp: { subs: sp.subs.length }, + sc: { + inner, + subs: subs.length, + next, + cells: [ + ...new Set(subs.map((s) => [...s.children].reduce((a, c) => a + (c.colSpan || 1), 0))), + ], + base: total(tr, ".m02-labrow__base"), + subBase: Math.round(subs.reduce((a, s) => a + total(s, ".m02-labrow__base"), 0)), + applied: total(tr, ".m02-labrow__applied"), + subApplied: Math.round(subs.reduce((a, s) => a + total(s, ".m02-labrow__applied"), 0)), + names: subs.map((s) => s.querySelector(".m02-labrow__subname").innerText), + qty: subs.map((s) => s.querySelector(".m02-labrow__qty").innerText), + units: subs.map((s) => s.querySelector(".m02-labrow__unit").innerText), + }, + }; + await open(get, SC); // 같은 줄 다시 = 닫힘 + return out; + }; + try { + const node = await until(() => document.querySelector('[data-node="i|item3"]')); + if (!node) return JSON.stringify({ error: "item3 없음 — 폴더를 펼쳐 둘 것" }); + document.querySelector('[data-node="i|item1"]')?.click(); // 다시 읽게 다른 항목 거침 + await w(1500); + node.click(); + const card = await until(() => + [...document.querySelectorAll(".m02-struct__card")].find((c) => + c.querySelector(`table.m02-labrow tbody tr[data-labor-logic="${SC}"]`), + ), + ); + if (!card) return JSON.stringify({ error: "일위조합 줄 카드 없음" }); + await w(1500); + const out = { card: await measure(() => card.querySelector("table.m02-labrow")) }; + const edit = [...card.querySelectorAll(".m02-struct__card-tools button")].find( + (b) => b.innerText.trim() === "수정", + ); + if (!edit) return JSON.stringify({ ...out, error: "일위대가 [수정] 없음" }); + edit.click(); + const detail = () => + [...document.querySelectorAll("table.m02-labrow")].find( + (t) => !t.closest(".m02-struct__card") && t.querySelector(`tr[data-labor-logic="${SC}"]`), + ); + if (!(await until(detail))) return JSON.stringify({ ...out, error: "상세 표 없음" }); + await w(2000); + out.detail = await measure(detail); + document.querySelector('[data-node="i|item3"]')?.click(); + await w(800); + [...document.querySelectorAll(".ui-modal button, dialog button")] + .find((b) => /확인|버림|떠나기/.test(b.innerText)) + ?.click(); + await w(1200); + out.back = !!document.querySelector(".m02-struct__card table.m02-labrow"); + return JSON.stringify(out); + } finally { + window.fetch = real; + } +})(); diff --git a/resources/tester/ui_checks/51-14_순서칸_2행_옵션수정.js b/resources/tester/ui_checks/51-14_순서칸_2행_옵션수정.js new file mode 100644 index 000000000..19f94dc3a --- /dev/null +++ b/resources/tester/ui_checks/51-14_순서칸_2행_옵션수정.js @@ -0,0 +1,159 @@ +/* 51-14 — 일위대가 표 순서 칸 2행(위 [위로] [아래로] / 아래 [옵션]·[수정] [삭제]) · 단가승격 [옵션] · 일위조합 [수정] 모달 + * 시작 화면: M02 마스터 템플릿 · 마스터 층(#/m02-master-template?open=구조물조합&root=master) · 시스템 관리자 · + * 나무에 item3(단가승격 SP-000001 · 일위조합 SC-000001 줄이 있음) + * 부르는 법: orca eval --expression "$(cat 이 파일)" (async 식 · JSON 글을 돌려줌) + * 쓰기 없음 — 모달은 모두 [취소]로 닫음 · PUT 수 = 0 확인(서고 저장 안 함) + * 기대 수치: + * - card.sp / card.sc: groups 1 · labels [옵션, 삭제] / [수정, 삭제] + * - detail.sp / detail.sc: groups 2 · top [위로, 아래로] · bottom [옵션, 삭제] / [수정, 삭제] · danger = 삭제 + * - promote: notice 있음 · foot [취소, 저장] · closed = true + * - combo: notice 있음 · add [로직 추가] · foot [취소, 저장] — 모달 안 [로직 추가]로 단가산출 한 줄 넣음(화면만) · + * added.groups 2 · top [위로, 아래로] · bottom [옵션, 삭제] · [취소] = 버림 물음(asked) → 확인 · closed = true · recalc ≥ 1 + * - puts = 0 + */ +(async () => { + const w = (ms) => new Promise((r) => setTimeout(r, ms)); + const until = async (fn, ms = 8000) => { + for (let t = 0; t < ms; t += 150) { + const v = fn(); + if (v) return v; + await w(150); + } + return null; + }; + const SC = "참조|system||SC-000001"; + const SP = "참조|system||SP-000001"; + const real = window.fetch; + let puts = 0; + let calcs = 0; + window.fetch = (input, init) => { + const url = typeof input === "string" ? input : input.url; + if ((init?.method ?? "GET").toUpperCase() === "PUT") puts++; + if (/\/labor\/item3\/calc/.test(url)) calcs++; + return real(input, init); + }; + const txt = (b) => b.innerText.trim(); + const tools = (tb, key) => { + const cell = tb.querySelector(`tr[data-labor-logic="${key}"] .m02-labrow__move`); + const groups = [...cell.querySelectorAll(".m02-labrow__tools > .ui-btn-group")]; + const btn = (g) => [...g.querySelectorAll("button")]; + const last = groups.at(-1) ? btn(groups.at(-1)).at(-1) : null; + return { + groups: groups.length, + top: groups.length > 1 ? btn(groups[0]).map(txt) : [], + bottom: groups.length ? btn(groups.at(-1)).map(txt) : [], + danger: last ? last.className : "", + _btn: (label) => groups.flatMap(btn).find((b) => txt(b) === label), + }; + }; + const clean = (t) => { + delete t._btn; + return t; + }; + const modal = () => [...document.querySelectorAll(".ui-modal")].at(-1) ?? null; + const foot = (m) => [...m.querySelectorAll(".m02-labin__foot button")].map(txt); + const cancel = async (m) => { + [...m.querySelectorAll(".m02-labin__foot button")].find((b) => txt(b) === "취소").click(); + await w(600); + return !document.body.contains(m); + }; + try { + const node = await until(() => document.querySelector('[data-node="i|item3"]')); + if (!node) return JSON.stringify({ error: "item3 없음 — 폴더를 펼쳐 둘 것" }); + document.querySelector('[data-node="i|item1"]')?.click(); // 다시 읽게 다른 항목 거침 + await w(1500); + node.click(); + const card = await until(() => + [...document.querySelectorAll(".m02-struct__card")].find((c) => + c.querySelector(`table.m02-labrow tbody tr[data-labor-logic="${SC}"]`), + ), + ); + if (!card) return JSON.stringify({ error: "일위조합 줄 카드 없음" }); + await w(1500); + const ct = card.querySelector("table.m02-labrow"); + const out = { card: { sp: clean(tools(ct, SP)), sc: clean(tools(ct, SC)) } }; + const edit = [...card.querySelectorAll(".m02-struct__card-tools button")].find( + (b) => txt(b) === "수정", + ); + if (!edit) return JSON.stringify({ ...out, error: "일위대가 [수정] 없음" }); + edit.click(); + const detail = () => + [...document.querySelectorAll("table.m02-labrow")].find( + (t) => + !t.closest(".m02-struct__card, .ui-modal") && + t.querySelector(`tr[data-labor-logic="${SC}"]`), + ); + if (!(await until(detail))) return JSON.stringify({ ...out, error: "상세 표 없음" }); + await w(2000); + const sp = tools(detail(), SP); + const sc = tools(detail(), SC); + out.detail = { sp: clean({ ...sp }), sc: clean({ ...sc }) }; + + // 단가승격 [옵션] — 넣을 값 모달 · 알림 한 줄 · [취소] + sp._btn("옵션").click(); + const pm = await until(() => modal()?.querySelector(".m02-inputval") && modal()); + out.promote = pm + ? { + title: pm.querySelector(".ui-modal__top h3").innerText, + notice: !!pm.querySelector("[data-labor-notice]"), + inputs: pm.querySelectorAll("[data-labor-input]").length, + foot: foot(pm), + closed: await cancel(pm), + } + : { error: "승격 모달 없음" }; + + // 일위조합 [수정] — 사전조합 상세 모달 · [취소] · 닫으면 다시 셈 + tools(detail(), SC)._btn("수정").click(); + const cm = await until(() => document.querySelector(".m02-labref")); + if (!cm) return JSON.stringify({ ...out, error: "일위조합 모달 없음", puts }); + await w(1000); + out.combo = { + title: cm.querySelector(".ui-modal__top h3").innerText, + notice: !!cm.querySelector("[data-labor-notice]"), + rows0: cm.querySelectorAll("table.m02-labrow tbody tr[data-labor-logic]").length, + add: [...cm.querySelectorAll(".m01-logic__section-head button")].map(txt), + foot: foot(cm), + }; + // 모달 안 [로직 추가] → 단가산출 첫 줄(화면 캐시만) + [...cm.querySelectorAll(".m01-logic__section-head button")] + .find((b) => txt(b) === "로직 추가") + .click(); + const pick = await until( + () => + [...document.querySelectorAll(".m01-logic__pick .ui-find__row")].find( + (r) => r.querySelector(".ui-find__tag")?.innerText.trim() === "단가산출", + ), + 30000, // 로직 목록 1천여 줄 + ); + if (!pick) return JSON.stringify({ ...out, error: "고르기 줄 없음", puts }); + pick.click(); + const added = await until(() => + cm.querySelector("table.m02-labrow tbody tr[data-labor-logic]"), + ); + if (added) { + const key = added.getAttribute("data-labor-logic"); + out.combo.added = clean(tools(cm.querySelector("table.m02-labrow"), key)); + } + const before = calcs; + [...cm.querySelectorAll(".m02-labin__foot button")].find((b) => txt(b) === "취소").click(); + const ask = await until(() => document.querySelector(".ui-confirm")); + out.combo.asked = !!ask; + [...(ask?.querySelectorAll("button") ?? [])].find((b) => txt(b) === "확인")?.click(); + await w(600); + out.combo.closed = !document.body.contains(cm); + await w(1200); + out.combo.recalc = calcs - before; + out.puts = puts; + + document.querySelector('[data-node="i|item3"]')?.click(); + await w(800); + [...document.querySelectorAll(".ui-modal button, dialog button")] + .find((b) => /확인|버림|떠나기/.test(b.innerText)) + ?.click(); + await w(1200); + out.back = !!document.querySelector(".m02-struct__card table.m02-labrow"); + return JSON.stringify(out); + } finally { + window.fetch = real; + } +})();