refactor(856-3): 일위대가 단가산출 줄 누름 = 줄 쌓기 한 길 — 프로젝트 사본은 굳힌 SK 문서 보기만 · M01 로직 줄 창 걷음

- 프로젝트 사본(구조물 고르기 카드 · B08 카드) 단가산출 줄 누름 = 사본 참조사본의 굳힌 SK 문서째 줄 쌓기 보기만(memory · 고침 칸 잠김 · 저장 없음 · 층 파일 읽기 0) · 사본에 없으면 알림
- 셈 주입 원본 층 카드 = 그 층 SK 줄 쌓기 읽기만(옛 「프로젝트 사본 줄」 안내 대신)
- M01 로직을 바로 담은 줄(저장본 0) = 창 없이 안내 한 줄 · 프로젝트 · 셈 주입 표(늘 보기만)의 [로직 추가] M01 바로 담기 갈래 지움(서버 from-logic 은 project 층 안 받음 · 서버 고침 0)
- Labor_RowModal = 자재 모달만 · Labor_LogicMats 고침 손잡이 · setLogicMark · 안 쓰는 글 키 지움
- 시험: 856-0 가짜 DOM 에 사본 보기 · 원본 층 읽기만 · 로직 줄 안내 덧 · 소스 글자 시험(175 · 222-1 · 742-1 · 806-1 둘 · logic_mats) 지움 · 811-1 · mat_marks 는 글자 줄만 지우고 700 줄 · 날 단추 · 서버 ↔ 화면 허용 값 짝 남김

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 05:32:35 +09:00
co-authored by Claude Opus 5.5
parent 605ca0cbed
commit 482ef981c0
20 changed files with 146 additions and 374 deletions
@@ -1,134 +1,20 @@
/* =============================================================================
* M02_MasterTemplete_Labor_RowModal.ts
* 일위대가표 줄 누름 모달(PLAN 723-2 · 요구서_내역16 2장 4 · 5 · 856-1) — 일위대가표에서 빠진 줄 동작을 모달 안으로.
* · 로직 줄(단가산출 문서 없음) · 셈 주입 줄(프로젝트 사본) = 머리(이름 · 「1 ㎡ 당」 · 옵션 값 · 메모) + 안내 한 줄
* (856-1 — 옛 단가산출 상세 몸 · [적용] 걷음 · 고침 = 단가산출 줄 쌓기 · 856-3 에서 줄 쌓기 보기로) ·
* 로직 자재(바꾸기 · 기본 · 세 칸 · `Labor_LogicMats`)
* · 사용자 자재 줄 = 자재 모달(세 칸 · `Labor_MatTable` 한 줄)
* 일위대가표 사용자 자재 줄 누름 모달(PLAN 723-2 · 요구서_내역16 2장 4 · 5) — 세 칸(`Labor_MatTable` 한 줄) · 가격 다섯 보기.
* · 고침 = 그 줄 화면 캐시(저장은 [저장]) · 금액은 표가 다시 셈 → `watch` 로 받아 다시 그림
* · 단가산출(SK) 줄 = `Labor_SkEdit`(프로젝트 사본 = 보기만) · M01 로직 줄 창은 걷음(856-3)
* ========================================================================== */
import { createBanner } from "@ui/ui_template_banner";
import { el, showToast } from "@ui/ui_template_elements";
import { el } from "@ui/ui_template_elements";
import { openModal } from "@ui/ui_template_modal";
import { createText } from "@ui/ui_template_text";
import type { ItemLogic } from "./M02_MasterTemplete_Api_Fetch";
import type { LaborCalc, LaborMat, LaborRow, MatMarkKey } from "./M02_MasterTemplete_Labor_Api";
import { logicMatRows } from "./M02_MasterTemplete_Labor_LogicMats";
import { setLogicMark, setMark } from "./M02_MasterTemplete_Labor_MatMarks";
import type { LaborCalc, LaborMat } from "./M02_MasterTemplete_Labor_Api";
import { setMark } from "./M02_MasterTemplete_Labor_MatMarks";
import { matTable } from "./M02_MasterTemplete_Labor_MatTable";
import { tc } from "./M02_MasterTemplete_Labor_Text";
import { valueLine } from "./M02_Labor_Values_Model";
/** 표가 다시 센 답을 받음 — 돌려준 함수 = 그만 받음 */
export type CalcWatch = (fn: (calc: LaborCalc | null) => void) => () => void;
export interface RowModalOptions {
row: LaborRow;
logic: ItemLogic | null;
title: string;
/** 일위대가 머리(이름 · 「1 ㎡ 당」) */
head: string;
readOnly: boolean;
/** 셈 주입(프로젝트 복사본) — 안내 글이 다름 */
inject: boolean;
/** 사용자 자재 코드 — 로직 자재 [바꾸기]로 같은 품목 막음 */
userMats: string[];
watch: CalcWatch;
/** 고침 뒤 — `again` = 서버 다시 셈(입력 · 고름 · 별도계상) · 아니면 화면만 */
done: (again: boolean) => void;
}
const TEXT = {
NoDoc: [
"M01 로직을 바로 담은 줄 — 단가산출 화면 없음 · 고침은 단가산출로 담아(일위대가 [로직 추가]) 그 줄에서",
"Uses the M01 logic directly — add it as a build-up to edit",
],
FromSk: [
"단가산출 「{k}」 에서 담아 온 줄 — 고침은 그 단가산출에서 고쳐 다시 담음",
"Copied from build-up 「{k}」 — edit it there and re-add",
],
Inject: [
"프로젝트 사본 줄 — 단가산출 화면 없음 · 수식 고침은 M02 단가산출에서 고쳐 [재생성]",
"Project copy line — edit the build-up in M02 and regenerate",
],
} as const;
const t = (k: keyof typeof TEXT): string => TEXT[k][0];
export function openRowModal(o: RowModalOptions): void {
const row = o.row;
const edit = !o.readOnly;
const info = el("div", { attrs: { "data-row-head": "" } });
const mats = el("div", { attrs: { "data-row-mats": "" } });
let calc: LaborCalc | null = null;
const draw = (): void => {
const values = valueLine(o.logic?.입력 ?? [], row.입력값);
info.replaceChildren(
createText(o.head, "muted", 14),
...(values.text ? [createText(values.text)] : []),
...(values.empty
? [createText(tc("Labor_Empty").replace("{n}", String(values.empty)), "error")]
: []),
...(row.켜쌓기율 != null
? [createText(tc("Labor_Layer").replace("{n}", String(row.켜쌓기율)), "muted")]
: []),
...(row.메모 ? [createText(row.메모, "muted")] : []),
);
const lead = row.참조
? []
: logicMatRows([row], calc, !calc, {
open: () => undefined,
...(edit
? {
swap: (_r: number, at: number, key: string) => {
if (o.userMats.includes(key))
return showToast(tc("Labor_AlreadyMat").replace("{value}", key), "error");
row.고름 = { ...row.고름, [String(at)]: key };
o.done(true);
},
reset: (_r: number, at: number) => {
if (!row.고름) return;
delete row.고름[String(at)];
if (!Object.keys(row.고름).length) delete row.고름;
o.done(true);
},
mark: (_r: number, at: number, key: MatMarkKey, v: string) => {
setLogicMark(row, at, key, v);
o.done(key === "별도계상");
draw();
},
}
: {}),
});
mats.replaceChildren(
...(lead.length
? [el("h4", { text: tc("Labor_Mats") }), matTable({ mats: [], calc, lead })]
: []),
);
};
// 안내 한 줄(856-1) — 로직 줄 = 온 단가산출(`본뜬`) · 셈 주입 = 프로젝트 사본
const from = row.본뜬 && typeof row.본뜬.이름 === "string" ? row.본뜬.이름 : "";
const note = createBanner({
tone: "info",
text: o.inject ? t("Inject") : from ? t("FromSk").replace("{k}", from) : t("NoDoc"),
});
const stop = o.watch((c) => {
calc = c;
draw();
});
openModal({
title: o.title,
closeLabel: tc("In_Close"),
width: "1100px",
wide: true,
beforeClose: () => (stop(), true),
mount: (body) => body.append(info, note, mats),
});
draw();
}
export interface MatModalOptions {
mat: LaborMat;
watch: CalcWatch;