feat(m01-lb): Entry 를 LB 타입(LbLogic · LbTables)으로 맞춤 · 금액 합계 칸 고침

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
This commit is contained in:
2026-10-01 11:45:54 +09:00
co-authored by Claude Opus 5.5
parent b71c41f0e7
commit b114ad13e6
+29 -3
View File
@@ -28,6 +28,8 @@ import {
type EasyListItem,
} from "../EasyCalc/M01_EasyCalc_Api";
import { renderSheet } from "../EasyCalc/M01_EasyCalc_Sheet";
import { lbCalcLater, type LbTables } from "./M01_LB_Api";
import { readLogic, type LbLogic } from "./M01_LB_Blocks";
import "./M01_LB_Entry.css";
const TEXT = {
@@ -104,15 +106,36 @@ const amountOf = (resultUnit: string): string => {
};
const isMoney = (resultUnit: string): boolean => resultUnit.startsWith("원/");
/** 고치는 화면이 쥔 것 — 2걸음에 Blocks 의 LbLogic 으로 바꿈 */
/** 고치는 화면이 쥔 것 — row = 저장할 로직 줄 · lb = 블록(못 읽으면 null) · tables = 고친 표 사본(저장 안 함) */
interface Paper {
key: string;
version: string;
isBase: boolean;
row: LogicRow;
trial: Record<string, unknown>;
lb: LbLogic | null;
tables: LbTables;
}
/* ponytail: Blocks(sub7) · LB Api(sub4) 속이 「준비 중」 인 동안만 대신함 — 채워지면 두 catch 를 지움 */
const blocksOf = (row: LogicRow, key: string, version: string, isBase: boolean): LbLogic | null => {
try {
return readLogic(row, { key, version, isBase });
} catch {
return null;
}
};
const calcWith = (
p: Paper,
onDone: (ans: CalcAnswer | null, plain: string | null) => void,
): void => {
try {
lbCalcLater(p.row, p.trial, p.tables, onDone);
} catch {
calcLater(p.row, p.trial, onDone);
}
};
/** 「쉬운 단가산출(시험)」 옆에 놓는 단추 — 누르면 큰 창 */
export function createLogicBuilderButton(): HTMLButtonElement {
return createButton({ label: te("Open"), variant: "filled", onClick: openLogicBuilder });
@@ -241,7 +264,8 @@ function openLogicBuilder(): void {
body.replaceChildren(el("p", { className: "m01-lb__muted", text: te("Loading") }));
try {
const opened = await openEasy(key);
paper = { key, ...opened };
const lb = blocksOf(opened.row, key, opened.version, opened.isBase);
paper = { key, ...opened, lb, tables: {} };
dirty = false;
showPaper();
} catch (error) {
@@ -282,7 +306,7 @@ function openLogicBuilder(): void {
const calc = (): void => {
drawResult(true);
calcLater(p.row, p.trial, (next, plain) => {
calcWith(p, (next, plain) => {
ans = next;
note.textContent = plain ?? "";
drawResult(false);
@@ -301,6 +325,8 @@ function openLogicBuilder(): void {
isBase: false,
row: saved.row,
trial: p.trial,
lb: blocksOf(saved.row, saved.key, saved.version, false),
tables: {},
};
logics = null;
showToast(te("Copied"), "success");