From 27c5eba52163334d82b42c99933bb691586270c4 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Thu, 1 Oct 2026 23:46:31 +0900 Subject: [PATCH] =?UTF-8?q?feat(m02-df):=20=EB=8B=A4=EB=A5=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=85=EB=A0=A5=20=E2=80=94=20=EB=B3=80=ED=99=98?= =?UTF-8?q?=20=ED=9D=90=EB=A6=84=EC=9D=B4=20=EB=B9=84=EB=A9=B4=20=EC=98=9B?= =?UTF-8?q?=20=EC=A4=84=20=EC=9E=85=EB=A0=A5=20=C2=B7=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=EA=B0=92=EC=9C=BC=EB=A1=9C=20=EB=B0=9B=EB=8A=94=20=EC=95=8C?= =?UTF-8?q?=EC=95=BD=20=C2=B7=20=EC=A7=84=EC=A7=9C=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=EA=B8=B8=EB=A1=9C=20=EA=B0=92=20=ED=99=95=EC=9D=B8?= 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_019ACSGaHdLgnkEkoA4LDtMU --- .../DataFlow/M02_DF_InputPanel_Build.ts | 22 +++++++++++++++++++ .../DataFlow/M02_DF_InputPanel_Logic.ts | 18 +++++++++++---- resources/tester/test_m02_df_input_logic.py | 14 ++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Build.ts b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Build.ts index b98570887..46d22c4ae 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Build.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Build.ts @@ -334,6 +334,28 @@ export function masterRef( : ref; } +/** 옛 로직 줄(입력 · 자동값)에서 바로 읽은 다른 로직 입력 값 — 흐름 변환이 아직 비어 있을 때 · 받는 알약 = 입력마다 · 예시값 = 자동값 */ +export function rowRef( + key: string, + name: string, + resultUnit: string, + inputs: { 이름: string; 단위?: string }[], + auto: Record, +): CfLogicRef { + const examples: Record = {}; + for (const i of inputs) { + const v = auto[i.이름]; + if (typeof v === "number" || (typeof v === "string" && v !== "")) examples[i.이름] = v; + } + return { + key, + name, + outputs: COST_OUTPUTS.map((n) => ({ name: n, unit: resultUnit || "-" })), + designs: inputs.map((i) => ({ name: i.이름, unit: i.단위 || "-" })), + ...(Object.keys(examples).length ? { examples } : {}), + }; +} + /** 이 로직이 자기 자신을 부르거나 돌고 도나 — `load` 가 로직을 주면 입력 상자의 「다른 로직」 을 따라가 봄(깊이 8) */ export async function wouldCycle( selfKey: string | null, diff --git a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Logic.ts b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Logic.ts index 3ac1c5507..d23404fed 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Logic.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_InputPanel_Logic.ts @@ -14,7 +14,11 @@ import { el, showToast, } from "@ui/ui_template_elements"; -import { fetchLogics } from "../../M01_MasterData/M01_MasterData_UI_Logic_Api"; +import { + fetchAuto, + fetchLogic, + fetchLogics, +} from "../../M01_MasterData/M01_MasterData_UI_Logic_Api"; import { cfGet, cfList, cfLogicFlow, cfLogicValue, cfPlain } from "./M02_DF_Api"; import type { CfLogic, CfLogicRef } from "./M02_DF_Model"; import { @@ -23,6 +27,7 @@ import { logicChapters, logicRefOf, masterRef, + rowRef, pageRange, setKind, setLogicInput, @@ -235,9 +240,14 @@ export function renderLogicInput( if (await wouldCycle(lg.key, i.키, loadForCycle)) return void showToast(t("Cycle"), "error"); const got = await flowOf(i); readNotes.set(i.키, { converted: got.converted, notes: got.notes }); - const picked = got.converted - ? masterRef(i.키, got.flow, true, i.결과단위) - : { ...logicRefOf(i.키, got.flow), name: i.이름 }; + // 옛 로직을 흐름도로 바꾼 것이 아직 비어 있으면 옛 줄의 입력 · 자동값에서 바로 읽음 + const empty = got.converted && got.flow.boxes.length === 0; + const row = empty ? await fetchLogic(i.키).catch(() => null) : null; + const picked = row + ? rowRef(i.키, i.이름, i.결과단위, row.logic.입력 ?? [], await fetchAuto(i.키)) + : got.converted + ? masterRef(i.키, got.flow, true, i.결과단위) + : { ...logicRefOf(i.키, got.flow), name: i.이름 }; const done = setLogicInput(lg, boxId, picked); // 기본 이름이면 고른 로직 이름으로 on.change({ diff --git a/resources/tester/test_m02_df_input_logic.py b/resources/tester/test_m02_df_input_logic.py index 1b5dd1765..d5351d187 100644 --- a/resources/tester/test_m02_df_input_logic.py +++ b/resources/tester/test_m02_df_input_logic.py @@ -252,3 +252,17 @@ def test_조건_찾기_요소와_검사(): assert call("checkGroupRule", el, [el]) == "같은 이름의 알약이 이미 있음" no_pill = call("groupRuleElement", "노임", "이름", {"box": "", "name": ""}) assert "변수 알약" in call("checkGroupRule", no_pill, []) + + +def test_옛_줄_입력과_자동값으로_다른_로직_입력을_읽음(): + inputs = [{"이름": "뒷길이", "단위": "㎝"}, {"이름": "돌"}, {"이름": "쌓기"}] + auto = {"뒷길이": 25, "돌": "깬잡석", "쌓기": "", "남는": 1} + ref = call("rowRef", "GF000219", "돌쌓기 메쌓기(인력)", "원/㎡", inputs, auto) + assert ref["key"] == "GF000219" + assert [o["name"] for o in ref["outputs"]] == ["노무비", "재료비", "경비", "계"] + assert ref["designs"] == [ + {"name": "뒷길이", "unit": "㎝"}, + {"name": "돌", "unit": "-"}, + {"name": "쌓기", "unit": "-"}, + ] + assert ref["examples"] == {"뒷길이": 25, "돌": "깬잡석"} # 빈 글 · 입력에 없는 이름은 뺌