feat(M01-쉬운단가): Cards 잠금 카드에 표 보고 고르기 단추 - openEasyTable 답으로 식 바꿈 · on.trial 받음
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D2nUMUMTsqm93PbQtipo6c
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
type PickResult,
|
||||
} from "./M01_EasyCalc_Model";
|
||||
import { openEasyPick } from "./M01_EasyCalc_Pick";
|
||||
import { openEasyTable, readFinds } from "./M01_EasyCalc_Table";
|
||||
import "./M01_EasyCalc_Cards.css";
|
||||
|
||||
const TEXT = {
|
||||
@@ -60,6 +61,7 @@ const TEXT = {
|
||||
Auto: ["자동", "auto"],
|
||||
Locked: ["잠김", "Locked"],
|
||||
ToNumber: ["숫자로 바꾸기", "Make it a number"],
|
||||
ByTable: ["표 보고 고르기", "Choose from table"],
|
||||
ToNumber_Wait: ["계산이 끝난 뒤 가능", "Available after calculation"],
|
||||
ToNumber_Ask: [
|
||||
"자동 값을 그대로 숫자로 바꿈 · 이후 자동으로 달라지지 않음",
|
||||
@@ -92,7 +94,7 @@ interface Ctx {
|
||||
doc: EasyDoc;
|
||||
lines: Map<string, CalcLine>;
|
||||
readOnly: boolean;
|
||||
on: { change(doc: EasyDoc): void };
|
||||
on: { change(doc: EasyDoc): void; trial?(): Record<string, unknown> };
|
||||
/** 숫자 아님으로 친 글 — 다시 그려도 칸에 남김 */
|
||||
badText: Map<string, string>;
|
||||
}
|
||||
@@ -205,6 +207,17 @@ async function lockToNumber(ctx: Ctx, card: EasyCard, value: number): Promise<vo
|
||||
}
|
||||
}
|
||||
|
||||
async function pickFromTable(ctx: Ctx, card: EasyCard): Promise<void> {
|
||||
if (picking) return;
|
||||
picking = true;
|
||||
try {
|
||||
const formula = await openEasyTable(card, ctx.doc, ctx.on.trial?.());
|
||||
if (formula !== null) patchCard(ctx, card, { qtyFormula: formula });
|
||||
} finally {
|
||||
picking = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------ 칸 만들기 ------------------------------ */
|
||||
|
||||
const text = (cls: string, value: string): HTMLSpanElement =>
|
||||
@@ -414,6 +427,17 @@ function lockedNote(ctx: Ctx, card: EasyCard): HTMLElement {
|
||||
});
|
||||
if (!line) button.title = tc("ToNumber_Wait");
|
||||
note.push(button);
|
||||
// 표 찾기가 있는 식만 — 조건 꼴 [조건 보고 고치기] 자리는 비워 둠(sub7)
|
||||
if (card.qtyFormula !== null && readFinds(card.qtyFormula)?.length) {
|
||||
note.push(
|
||||
createButton({
|
||||
label: tc("ByTable"),
|
||||
variant: "ghost",
|
||||
size: "sm",
|
||||
onClick: () => void pickFromTable(ctx, card),
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
return el("div", { className: "m01-easycards-locknote", children: note });
|
||||
}
|
||||
@@ -485,7 +509,7 @@ export function renderCards(
|
||||
host: HTMLElement,
|
||||
doc: EasyDoc,
|
||||
ans: CalcAnswer | null,
|
||||
on: { change(doc: EasyDoc): void },
|
||||
on: { change(doc: EasyDoc): void; trial?(): Record<string, unknown> },
|
||||
): void {
|
||||
const badText = badTexts.get(host) ?? new Map<string, string>();
|
||||
badTexts.set(host, badText);
|
||||
|
||||
Reference in New Issue
Block a user