Files
Aislo/M01_MasterData/M01_MasterData_UI_LogicLab_Formula.ts
T
eomsangdonandClaude Sonnet 5 448ef6080f feat(M01): 로직 개선 시험 「텍스트 수식」 컨테이너 — 서버 /text 가 준 줄(비목 묶음 · 소계 · 끝수 · 까닭 옅게)을 그대로 찍음
- `runText` API + 시험 계산 때 `/calc` 와 같은 몸으로 같이 부름 · 화면은 다시 계산하지 않음
- 멈추면 서버 까닭 한 줄
- ORCA 13-4-1 · 12-4 · 12-17-1 소계 합이 호표 계와 같음 · 모달 표 뜸

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT
2026-09-21 19:46:56 +09:00

61 lines
2.2 KiB
TypeScript

/* =============================================================================
* M01_MasterData_UI_LogicLab_Formula.ts
* 「텍스트 수식」 컨테이너 — 서버(`POST /text`)가 준 줄을 그대로 찍음(화면에서 다시 계산하지 않음)
* 비목 묶음 제목 · 줄(`이름 : 글`) · 소계 · 끝수 한 마디 · 까닭 있는 줄은 옅게
* ========================================================================== */
import { el } from "@ui/ui_template_elements";
import type { TextAnswer } from "./M01_MasterData_UI_Logic_Api";
import { formatNumber } from "./M01_MasterData_UI_Logic_Edit";
import { tx } from "./M01_MasterData_UI_Logic_Text";
import { tl } from "./M01_MasterData_UI_LogicLab_Text";
export interface FormulaContext {
text: TextAnswer | null;
}
const muted = (text: string): HTMLElement => el("p", { className: "m01-logic__muted", text });
export function buildFormula(host: HTMLElement, ctx: FormulaContext): void {
const text = ctx.text;
if (!text) {
host.replaceChildren(muted(tl("Formula_Slot")));
return;
}
if (!text.ok) {
host.replaceChildren(
el("div", {
className: "m01-logic__reasons",
children: [el("strong", { text: tx("Calc_Stopped") }), el("div", { text: text.reason })],
}),
);
return;
}
const blocks = text.groups.flatMap((g) => [
el("h4", { className: "m01lab__group", text: g.비목 }),
...g..map((line) =>
el("div", {
className: `m01lab__text${line.까닭 ? " m01lab__text--off" : ""}`,
attrs: { "data-text-line": line.이름 },
children: [
el("div", { text: `${line.이름} : ${line.}` }),
...(line.까닭 ? [el("div", { className: "m01-logic__muted", text: line.까닭 })] : []),
],
}),
),
el("p", {
className: "m01lab__subtotal-text",
attrs: { "data-text-sub": String(g.소계) },
text: `${g.비목} ${tl("Subtotal")} ${formatNumber(g.소계)}${g.끝수 ? ` (${g.끝수})` : ""}`,
}),
]);
blocks.push(
el("p", {
className: "m01lab__total",
attrs: { "data-text-sum": String(text.) },
text: `${tl("Total")} ${formatNumber(text.)}`,
}),
);
host.replaceChildren(...blocks);
}