fix(m01-easycalc): 잘못 넣은 줄(빈 이름 · 숫자 아님 · 0 · 음수) 저장 막음 · 조건 · 표 창에 설계 값 넘김
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
This commit is contained in:
@@ -40,6 +40,7 @@ import {
|
||||
setEasyModelLanguage,
|
||||
toDoc,
|
||||
toRow,
|
||||
type EasyCard,
|
||||
type EasyDoc,
|
||||
} from "./M01_EasyCalc_Model";
|
||||
import { renderSheet, renderTrialStrip } from "./M01_EasyCalc_Sheet";
|
||||
@@ -83,6 +84,10 @@ const TEXT = {
|
||||
Copied: ["내 것으로 만들었음 — 이제 고칠 수 있음", "Your copy is ready — you can edit it now"],
|
||||
Cards: ["무엇이 들어가나", "What goes in"],
|
||||
Sheet: ["실무 일위대가표로 보기", "View as a unit-cost sheet"],
|
||||
BadLines: [
|
||||
"⚠ 표시 줄을 먼저 고쳐 주세요 — 빈 이름 · 숫자 아님 · 0 · 0 보다 작은 수는 저장 안 됨",
|
||||
"Fix the ⚠ lines first — empty names, non-numbers, 0 or negative amounts can't be saved",
|
||||
],
|
||||
Uses_Wait: ["쓰는 곳을 찾는 중 — 10초쯤 걸림", "Looking for places that use it — about 10 s"],
|
||||
Uses_Block: ["쓰는 곳이 있어 못 지움 — {v}", "Cannot delete — it is used by {v}"],
|
||||
Delete_Ask: ["「{v}」 을(를) 지울까요? 되살릴 수 없음", "Delete “{v}”? This cannot be undone"],
|
||||
@@ -114,6 +119,11 @@ const amountOf = (resultUnit: string): string => {
|
||||
return /^\d/.test(unit) ? unit : `1${unit}`;
|
||||
};
|
||||
|
||||
/** 저장을 막는 줄 — 이름 빔 · 수량이 숫자 아님 · 0 · 음수(서버가 0 · 음수를 받아 줌) · 같은 줄 · 너무 큼은 경고만 */
|
||||
const blocksSave = (c: EasyCard): boolean =>
|
||||
!c.name.trim() ||
|
||||
(c.qtyFormula === null && !(c.qty !== null && Number.isFinite(c.qty) && c.qty > 0));
|
||||
|
||||
/** 「추가」 옆에 놓는 단추 — 누르면 큰 창 */
|
||||
export function createEasyCalcButton(): HTMLButtonElement {
|
||||
return createButton({ label: te("Open"), variant: "filled", onClick: openEasyCalc });
|
||||
@@ -379,7 +389,7 @@ function openEasyCalc(): void {
|
||||
}
|
||||
return;
|
||||
}
|
||||
renderCards(cardsHost, doc, ans, { change: edit });
|
||||
renderCards(cardsHost, doc, ans, { change: edit, trial: () => trial });
|
||||
};
|
||||
|
||||
const calc = (): void => {
|
||||
@@ -421,6 +431,7 @@ function openEasyCalc(): void {
|
||||
const bad = checkName(doc.name, mine);
|
||||
name.setError(bad ?? undefined);
|
||||
if (bad) return void name.input.focus();
|
||||
if (doc.cards.some(blocksSave)) return void (note.textContent = te("BadLines"));
|
||||
busy = true;
|
||||
saveButton.disabled = true;
|
||||
note.textContent = te("Saving");
|
||||
|
||||
Reference in New Issue
Block a user