feat(m02-df): 다른 로직 입력 — 변환 흐름이 비면 옛 줄 입력 · 자동값으로 받는 알약 · 진짜 서버 길로 값 확인

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ACSGaHdLgnkEkoA4LDtMU
This commit is contained in:
2026-10-01 23:46:31 +09:00
co-authored by Claude Sonnet 5.5
parent e8662131e0
commit 27c5eba521
3 changed files with 50 additions and 4 deletions
@@ -334,6 +334,28 @@ export function masterRef(
: ref;
}
/** 옛 로직 줄(입력 · 자동값)에서 바로 읽은 다른 로직 입력 값 — 흐름 변환이 아직 비어 있을 때 · 받는 알약 = 입력마다 · 예시값 = 자동값 */
export function rowRef(
key: string,
name: string,
resultUnit: string,
inputs: { 이름: string; 단위?: string }[],
auto: Record<string, unknown>,
): CfLogicRef {
const examples: Record<string, number | string> = {};
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,
@@ -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({
@@ -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, "돌": "깬잡석"} # 빈 글 · 입력에 없는 이름은 뺌