From 209654f31104382f68d79062a3369f5077f40079 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 24 Sep 2026 14:35:19 +0900 Subject: [PATCH] =?UTF-8?q?fix(M01):=20=EA=B3=84=EC=82=B0=20=EB=A9=88?= =?UTF-8?q?=EC=B6=A4=EC=97=90=EB=8F=84=20=EC=88=98=EB=9F=89=20=EC=B9=B8=20?= =?UTF-8?q?=EB=82=A0=EC=8B=9D=20=C2=B7=20=EA=B9=8C=EB=8B=AD=20=EB=82=A0?= =?UTF-8?q?=EA=B8=80=20=EC=95=88=20=EC=B0=8D=EC=9D=8C=20=E2=80=94=20?= =?UTF-8?q?=EB=A7=88=EC=A7=80=EB=A7=89=20=EC=A1=B0=EA=B0=81=20=C2=B7=20?= =?UTF-8?q?=EB=B9=88=EC=B9=B8=20=C2=B7=20=EA=B9=8C=EB=8B=AD=20=EA=B1=B8?= =?UTF-8?q?=EB=9F=AC=EB=83=84=20(PLAN=206=EC=9E=A5=20=EC=85=8B=EC=A7=B8=20?= =?UTF-8?q?=EC=A4=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT --- M01_MasterData/M01_MasterData_UI_LogicLab.ts | 4 ++++ .../M01_MasterData_UI_LogicLab_Detail.ts | 14 ++++++++++---- .../M01_MasterData_UI_LogicLab_Formula.ts | 9 ++++++--- M01_MasterData/M01_MasterData_UI_Logic_Calc.ts | 7 +++++-- M01_MasterData/M01_MasterData_UI_Logic_Text.ts | 10 ++++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab.ts b/M01_MasterData/M01_MasterData_UI_LogicLab.ts index d7ad8825..3658548f 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab.ts @@ -59,6 +59,8 @@ interface Opened extends Draft { reasons: string[]; lines: CalcLine[] | null; text: TextAnswer | null; + /** 마지막으로 잘 받은 읽는 식 — 멈춘 뒤에도 수량 칸 조각을 이걸로 */ + lastText?: TextAnswer; ownHost: HTMLElement; values: Record; } @@ -170,6 +172,7 @@ export async function mountM01LogicLab( values: current.values, onText: (text) => { current.text = text; + if (text.ok) current.lastText = text; drawEditor(); // [계산] 전 미리보기 응답도 왼쪽 이름 식 칸에 바로 비치게 — onLines 와 같은 자리 }, onLines: (lines) => { @@ -202,6 +205,7 @@ export async function mountM01LogicLab( prices: current.prices, lines: current.lines, text: current.text, + lastText: current.lastText, values: current.values, ownHost: current.ownHost, onChange: touch, diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts b/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts index cbdc2b1b..7a030dd2 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts @@ -20,7 +20,7 @@ import type { import { buildEditor, qtyKind } from "./M01_MasterData_UI_Logic_Edit"; import { formatMoney, formatPrice } from "./M01_MasterData_UI_Logic_Money"; import { openPicker } from "./M01_MasterData_UI_Logic_Pick"; -import { tx } from "./M01_MasterData_UI_Logic_Text"; +import { safeReason, tx } from "./M01_MasterData_UI_Logic_Text"; import { buildFormula } from "./M01_MasterData_UI_LogicLab_Formula"; import { condText, @@ -64,6 +64,8 @@ export interface DetailContext { lines: CalcLine[] | null; /** 마지막 시험 계산의 읽는 식 줄(서버가 줌) */ text: TextAnswer | null; + /** 마지막으로 잘 받은 읽는 식 — `text` 가 멈춤이면 조각을 이걸로 */ + lastText?: TextAnswer; values: Record; /** 자체 로직 편집기 자리 — 다시 그려도 같은 칸을 씀(고치던 값이 안 날아감) */ ownHost: HTMLElement; @@ -166,7 +168,7 @@ function infoBox(ctx: DetailContext): HTMLElement { className: "m01-logic__reasons", children: [ el("strong", { text: tx("Head_Blocked") }), - ...ctx.reasons.map((r) => el("div", { text: r })), + ...ctx.reasons.map((r) => el("div", { text: safeReason(r) })), ], }), ] @@ -287,14 +289,18 @@ function entries(ctx: DetailContext): Entry[] { * 이름을 차례로 따라가며 줄 차례에 맞춤 · 금액 0 로직 부름 줄처럼 묶음이 달라도 찾음 · * 끝내 못 찾으면 날식 대신 빈칸(계산 전 · 서버 실패면 식 글자 그대로) */ function attachPieces(all: Entry[], ctx: DetailContext): void { - if (!ctx.text?.ok) return; + const source = ctx.text?.ok ? ctx.text : ctx.lastText; + if (!source?.ok) { + if (ctx.text) for (const e of all) e.qtyFrag = e.piecesFrag = []; // 멈춤 · 받은 조각 없음 — 날식 대신 빈칸 + return; + } const ho = ctx.row.호표 ?? []; const names = [ ...ho.map((item) => item.이름 ?? (condOf(item) ? condLabel(condOf(item)!) : item.요소)), ...(ctx.row.덧줄 ?? []).map((extra) => extra.이름), ]; const found = new Map(); - for (const g of ctx.text.groups) { + for (const g of source.groups) { let from = 0; for (const line of g.줄) { const at = names.findIndex((n, i) => i >= from && n === line.이름); diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Formula.ts b/M01_MasterData/M01_MasterData_UI_LogicLab_Formula.ts index d90f66be..9adccc09 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Formula.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Formula.ts @@ -8,7 +8,7 @@ import { el } from "@ui/ui_template_elements"; import type { TextAnswer } from "./M01_MasterData_UI_Logic_Api"; import { formatMoney } from "./M01_MasterData_UI_Logic_Money"; -import { tx } from "./M01_MasterData_UI_Logic_Text"; +import { safeReason, tx } from "./M01_MasterData_UI_Logic_Text"; import { tl } from "./M01_MasterData_UI_LogicLab_Text"; import "./M01_MasterData_UI_LogicLab_Formula.css"; @@ -31,7 +31,10 @@ export function buildFormula(host: HTMLElement, ctx: FormulaContext): void { host.replaceChildren( el("div", { className: "m01-logic__reasons", - children: [el("strong", { text: tx("Calc_Stopped") }), el("div", { text: text.reason })], + children: [ + el("strong", { text: tx("Calc_Stopped") }), + el("div", { text: safeReason(text.reason) }), + ], }), ); return; @@ -62,7 +65,7 @@ export function buildFormula(host: HTMLElement, ctx: FormulaContext): void { ? [ el("div", { text: `${line.이름} : ${line.글}` }), ...(line.까닭 - ? [el("div", { className: "m01-logic__muted", text: line.까닭 })] + ? [el("div", { className: "m01-logic__muted", text: safeReason(line.까닭) })] : []), ] : [el("div", { className: "m01-logic__muted", text: tl("Formula_Slot") })], diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Calc.ts b/M01_MasterData/M01_MasterData_UI_Logic_Calc.ts index b09bb7e2..6e8b6eac 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Calc.ts +++ b/M01_MasterData/M01_MasterData_UI_Logic_Calc.ts @@ -17,7 +17,7 @@ import { } from "./M01_MasterData_UI_Logic_Api"; import { formatNumber } from "./M01_MasterData_UI_Logic_Edit"; import { formatMoney } from "./M01_MasterData_UI_Logic_Money"; -import { tx } from "./M01_MasterData_UI_Logic_Text"; +import { safeReason, tx } from "./M01_MasterData_UI_Logic_Text"; /** 고르기 값이 마스터 키(자재·기계·직종)면 이름으로 바꿔 보임 — 값 칸은 키 그대로 보냄 */ const KEY_RE = /^[A-Z]{2}\d{6}$/; @@ -201,7 +201,10 @@ function answerView(answer: CalcAnswer, draft: boolean, money: boolean): HTMLEle ...note, el("div", { className: "m01-logic__reasons", - children: [el("strong", { text: tx("Calc_Stopped") }), el("div", { text: answer.reason })], + children: [ + el("strong", { text: tx("Calc_Stopped") }), + el("div", { text: safeReason(answer.reason) }), + ], }), ]; } diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Text.ts b/M01_MasterData/M01_MasterData_UI_Logic_Text.ts index 8ef71ee7..e0cf849f 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Text.ts +++ b/M01_MasterData/M01_MasterData_UI_Logic_Text.ts @@ -138,6 +138,10 @@ const TEXT = { "「{name}」 규격이 여럿이라 정하지 못함 — 위 「쓰이는 재료·기계」에서 하나를 골라 주세요", "「{name}」 has several specs — pick one in the materials list above", ], + Stop_Generic: [ + "이 조건으로는 셈하지 못함 — 입력값 · 표에 그 조합이 있는지 확인", + "Cannot be calculated with these inputs — check the values and the table", + ], Stop_NoPrice: [ "「{name}」 단가가 자료에 비어 있어 셈하지 못함 — 자료를 채워야 함", "「{name}」 has no price in the data yet", @@ -158,6 +162,12 @@ export function plainReason(reason: string): string { return reason; } +/** 화면에 찍는 까닭의 마지막 방어 — 중괄호 · 따옴표 · Decimal( 이 섞인 날글은 사람 말 한 줄로 */ +export function safeReason(reason: string): string { + const plain = plainReason(reason); + return /[{}"']|Decimal\(/.test(plain) ? tx("Stop_Generic") : plain; +} + /** 흐름 그림 머리 「이렇게 씀」 — 줄 목록 */ /** 공용 `t()` 와 같은 뜻 — `{n}`·`{v}` 는 채움 */