Files
Aislo/M02_MasterTemplete/M02_MasterTemplete_Sangeun_Cover.ts
T
eomsangdonandClaude Sonnet 5.5 db590e6fa8 feat(750-2): 단가산출 보기 넷 = SK 셈 답 하나 — 시험 계산 · 텍스트 수식도 SK 답(글 · 중간) · 바탕 M01 로직 따로 셈 걷음 · 옵션 바꿈 서버 셈 한 번
- Sangeun_Detail — 텍스트 수식 = 답 `글` · 시험 계산 = 답 `줄` · `기준` · `중간`(`buildCalc` 덧칸 `answer` · `shown` · `held`) · `/logic-lib/calc` · `/text` · 미리보기 부름 · `baseCovers` · `dropText` · `applyCovers` 걷음 · 바탕 원값 셈 = `보기: false`
- 재료 고름(줄 모달 · 시험 계산 재료 칸) = SK 문서 `고름`(cid 열쇠 · 둘째 기초 세부 줄은 보기만)
- LogicLab_Ho — 읽는 식 줄을 `cid` 로 이음(`HoContext.cids` · 이름 차례 추측은 M01 만) · LogicLab_Formula — 단위 환산 `나눔` 머리 한 줄
- 낡은 시험 고침 — test_717_2b(`baseCovers` · `dropText` 단정 뺌 · 함수 지움) · test_725_1(`void recalc()` 새 꼴) · 새 지킴 test_750_2
- M01 단가산출 기초 = 덧칸 안 넘겨 옛 길 그대로

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-02 23:01:57 +09:00

90 lines
3.4 KiB
TypeScript

/* =============================================================================
* M02_MasterTemplete_Sangeun_Cover.ts
* 단가산출(SK) 셈 길 부름 · 뺀 줄 띠(PLAN 717-2b · 717-3 · 724-1)
* · 셈 = `calcSangeun`(`POST /layers/{층}/sangeun/calc` · 저장 안 함 · 부르는 쪽이 최신 응답만 받음) ·
* [단가산출로 저장] = `sangeunFromLine`(`/sangeun/from-line`)
* · 고침 표는 공용 상세(`M01_MasterData_UI_LogicLab_Ho` · 724-1) — 여기는 뺀 줄 되살림 띠만
* ========================================================================== */
import { createBadge } from "@ui/ui_template_badge";
import { createButton } from "@ui/ui_template_button";
import { el } from "@ui/ui_template_elements";
import { t as L } from "@ui/ui_template_locale";
import { createText } from "@ui/ui_template_text";
import { call, type Layer } from "./M02_MasterTemplete_Api_Fetch";
import { withSameAsk } from "./M02_MasterTemplete_Library_SameAsk";
import type { PatchRow, SkAnswer } from "./logic/M02_Sangeun_Cover_Model";
import "./M02_MasterTemplete_Sangeun.css";
export interface SkScope {
layer: Layer;
owner: string | null;
}
const q = (scope: SkScope): string =>
scope.owner && scope.layer !== "system" ? `?owner=${encodeURIComponent(scope.owner)}` : "";
/** 셈(저장 안 함) — 문서 = 화면 문서 · `given` = 시험 입력(빈 칸 뺌) · 서버가 M01 엔진 한 벌로 셈 */
export function calcSangeun<T = SkAnswer>(
scope: SkScope,
doc: Record<string, unknown>,
given: Record<string, string> = {},
seen = true,
): Promise<T> {
const 입력값 = Object.fromEntries(Object.entries(given).filter(([, v]) => String(v).trim()));
return call<T>(`/layers/${scope.layer}/sangeun/calc${q(scope)}`, {
method: "POST",
body: JSON.stringify({ 문서: doc, 입력값, 보기: seen }), // 보기 false = 글 · 중간 덧칸 안 지음(바탕 원값 셈)
});
}
/** [단가산출로 저장] — 그 층 새 SK · 답 = 새 키 + 그 SK 참조 줄 · 같은 내용이 있으면 물음(733-3 ·
* 그것을 씀 = 그 키 · 그래도 새로) · 취소 = null */
export const sangeunFromLine = (
scope: SkScope,
line: PatchRow & Record<string, unknown>,
이름: string,
단위: string,
): Promise<{ 이름: string; 줄: Record<string, unknown> } | null> =>
withSameAsk((extra) =>
call(`/layers/${scope.layer}/sangeun/from-line${q(scope)}`, {
method: "POST",
body: JSON.stringify({ 줄: line, 이름, 단위, ...extra }),
}),
);
/** 뺀 줄(cid · 이름) 띠 — 고칠 수 있으면 [되살림] */
export function removedStrip(
removed: { cid: string; 이름: string }[],
edit: boolean,
onRestore: (cid: string) => void,
): HTMLElement[] {
if (!removed.length) return [];
return [
el("div", {
className: "m02-sk__removed",
attrs: { "data-removed": "" },
children: [
createText(L("M02_SangeunRemoved")),
...removed.map((x) =>
el("span", {
className: "m02-sk__removed-item",
children: [
createBadge(x.이름, "neutral"),
...(edit
? [
createButton({
label: L("M02_SangeunRestore"),
variant: "ghost",
size: 22,
onClick: () => onRestore(x.cid),
}),
]
: []),
],
}),
),
],
}),
];
}