From ea07beb5c432e12f2184fc55bd1d59e8757a7b62 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 1 Oct 2026 09:54:42 +0900 Subject: [PATCH] =?UTF-8?q?feat(M01-=EC=89=AC=EC=9A=B4=EB=8B=A8=EA=B0=80):?= =?UTF-8?q?=20Cards=20=EC=9E=A0=EA=B8=88=20=EC=B9=B4=EB=93=9C=EC=97=90=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EB=B3=B4=EA=B3=A0=20=EA=B3=A0=EC=B9=98?= =?UTF-8?q?=EA=B8=B0=20=EB=8B=A8=EC=B6=94=20-=20openEasyCond=20=EB=8B=B5?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=8B=9D=20=EB=B0=94=EA=BF=88=20=C2=B7=20?= =?UTF-8?q?=ED=91=9C=EC=99=80=20=EC=A1=B0=EA=B1=B4=20=EB=91=98=20=EB=8B=A4?= =?UTF-8?q?=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EB=91=90=20=EB=8B=A8=EC=B6=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01D2nUMUMTsqm93PbQtipo6c --- M01_MasterData/EasyCalc/M01_EasyCalc_Cards.ts | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/M01_MasterData/EasyCalc/M01_EasyCalc_Cards.ts b/M01_MasterData/EasyCalc/M01_EasyCalc_Cards.ts index f2eef8ac5..666bb13a9 100644 --- a/M01_MasterData/EasyCalc/M01_EasyCalc_Cards.ts +++ b/M01_MasterData/EasyCalc/M01_EasyCalc_Cards.ts @@ -23,6 +23,7 @@ import { type PickResult, } from "./M01_EasyCalc_Model"; import { openEasyPick } from "./M01_EasyCalc_Pick"; +import { openEasyCond, readCond } from "./M01_EasyCalc_Cond"; import { openEasyTable, readFinds } from "./M01_EasyCalc_Table"; import "./M01_EasyCalc_Cards.css"; @@ -62,6 +63,7 @@ const TEXT = { Locked: ["잠김", "Locked"], ToNumber: ["숫자로 바꾸기", "Make it a number"], ByTable: ["표 보고 고르기", "Choose from table"], + ByCond: ["조건 보고 고치기", "Edit conditions"], ToNumber_Wait: ["계산이 끝난 뒤 가능", "Available after calculation"], ToNumber_Ask: [ "자동 값을 그대로 숫자로 바꿈 · 이후 자동으로 달라지지 않음", @@ -207,11 +209,16 @@ async function lockToNumber(ctx: Ctx, card: EasyCard, value: number): Promise { +/** 표 · 조건 창 — 답(새 식)이 있으면 그 카드 식만 바꿈 */ +async function editFormula( + ctx: Ctx, + card: EasyCard, + open: typeof openEasyTable | typeof openEasyCond, +): Promise { if (picking) return; picking = true; try { - const formula = await openEasyTable(card, ctx.doc, ctx.on.trial?.()); + const formula = await open(card, ctx.doc, ctx.on.trial?.()); if (formula !== null) patchCard(ctx, card, { qtyFormula: formula }); } finally { picking = false; @@ -427,16 +434,21 @@ 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), - }), - ); + const formula = card.qtyFormula; + const tools: [boolean, keyof typeof TEXT, typeof openEasyTable | typeof openEasyCond][] = [ + [formula !== null && !!readFinds(formula)?.length, "ByTable", openEasyTable], + [formula !== null && !!readCond(formula, ctx.doc.row), "ByCond", openEasyCond], + ]; + for (const [has, label, open] of tools) { + if (has) + note.push( + createButton({ + label: tc(label), + variant: "ghost", + size: "sm", + onClick: () => void editFormula(ctx, card, open), + }), + ); } } return el("div", { className: "m01-easycards-locknote", children: note });