diff --git a/A00_Common/design/design_structure_form.ts b/A00_Common/design/design_structure_form.ts index de75abeb6..10d353761 100644 --- a/A00_Common/design/design_structure_form.ts +++ b/A00_Common/design/design_structure_form.ts @@ -41,7 +41,6 @@ import { import { buildSummaryRow } from "../../B05_Profile/B05_Profile_UI_Structures_Summary_Row"; import type { GroupItems, SummaryItem } from "../../common_util/common_util_summary_item"; import { followPipeHeights } from "../../common_util/common_util_culvert_sets"; -import { createCheckbox } from "../../ui_template/ui_template_checkbox"; /** 잇기 값 자리 — 패널 그룹 값(`group_items`)을 그대로 씀. */ export interface SpecLinks { @@ -144,13 +143,6 @@ export function createSpecForm(links: SpecLinks | null, hooks: SpecFormHooks = { select.value = tag ? "" : now; return select; } - if (item.kind === "bool") { - // 빈 값 = 기본값으로 체크(173-7) · 듣개가 `.value` 를 읽음 — 바뀔 때 "true" / "false" - const box = createCheckbox("", { checked: (values[item.id] || item.default) === "true" }); - box.input.value = String(box.input.checked); - box.input.addEventListener("change", () => (box.input.value = String(box.input.checked))); - return box.root; - } if (item.kind === "text") { const input = document.createElement("input"); input.type = "text"; diff --git a/A00_Common/design/design_structure_pipe.ts b/A00_Common/design/design_structure_pipe.ts index 3aa987a31..9b1e7b79e 100644 --- a/A00_Common/design/design_structure_pipe.ts +++ b/A00_Common/design/design_structure_pipe.ts @@ -70,11 +70,15 @@ export const PIPE_SPEC: StructureSpec = { [BASIN]: { form: "inlet_structure", height: "inlet_basin_height_m" }, [SOIL]: revetKeys("inlet"), }), - // 집수정만 · 빈 값 = 참(키 없는 옛 관도 동물이동형 · 173-7) · 저장만(B07 · B08 안 읽음) + // 집수정만 · 유 / 무 = 저장 "true" / "false" · 빈 값 = 유(필수 상자 기본 채움 · 177-2) · 저장만(B07 · B08 안 읽음) { id: "animal", label: "동물이동형", - kind: "bool", + kind: "select", + choices: [ + { value: "true", label: "유" }, + { value: "false", label: "무" }, + ], default: "true", by: { item: "structure", map: { [BASIN]: { key: "inlet_basin_animal" } } }, }, diff --git a/A00_Common/design/design_structure_spec.ts b/A00_Common/design/design_structure_spec.ts index 5c80408e8..3ba11d1d1 100644 --- a/A00_Common/design/design_structure_spec.ts +++ b/A00_Common/design/design_structure_spec.ts @@ -32,8 +32,7 @@ export type SplitRole = "length" | "before" | "after"; export interface SpecItem { id: string; label: string; - /** bool = 체크박스 · 저장 글 "true" / "false" · 빈 값 = `default`(173-7). */ - kind: "select" | "number" | "text" | "auto" | "bool"; + kind: "select" | "number" | "text" | "auto"; /** 저장 키(필수 컨테이너 · `by` 없을 때). */ key?: string; choices?: SpecChoice[]; diff --git a/resources/master_template/구조물정의.json b/resources/master_template/구조물정의.json index 6cc24ba67..732b9baa1 100644 --- a/resources/master_template/구조물정의.json +++ b/resources/master_template/구조물정의.json @@ -3333,6 +3333,8 @@ "inlet.before": "기준측점 전 (m)", "inlet.after": "기준측점 후 (m)", "inlet.animal": "동물이동형", + "inlet.animal=true": "유", + "inlet.animal=false": "무", "outlet.structure": "구조", "outlet.structure=기슭막이": "흙막이", "outlet.form": "형태", diff --git a/resources/tester/helper_173_7_inlet_animal.cjs b/resources/tester/helper_173_7_inlet_animal.cjs index 609c9c8db..89f9a38be 100644 --- a/resources/tester/helper_173_7_inlet_animal.cjs +++ b/resources/tester/helper_173_7_inlet_animal.cjs @@ -1,5 +1,5 @@ -/* 집수정 「동물이동형」 체크 칸(PLAN 173-7) 단위검증 헬퍼 — 공용 명세 폼을 그 자리에서 트랜스파일해 Node 로 돌린다. - * 빈 값 = 체크 · 끄면 "false" · 다시 켜면 "true" · 흙막이 갈래엔 칸 없음. 결과는 표준출력에 JSON 한 벌. +/* 집수정 「동물이동형」 칸(PLAN 173-7 · 177-2 고르기 유 / 무) 단위검증 헬퍼 — 공용 명세 폼을 그 자리에서 트랜스파일해 Node 로 돌린다. + * 빈 값 = 유("true" 적힘) · 무 = "false" · 다시 유 = "true" · 흙막이 갈래엔 칸 없음. 결과는 표준출력에 JSON 한 벌. * 짝 = `test_173_7_inlet_animal.py` · 화면 그릇 흉내는 `helper_54_10_soil_tiers.cjs` 꼴(+ 듣개). */ const fs = require("fs"); @@ -121,32 +121,44 @@ const { createSpecForm } = loadTs( const { PIPE_SPEC } = loadTs(path.join(ROOT, "A00_Common", "design", "design_structure_pipe.ts")); const form = createSpecForm(null, {}); +// 177-2 — 체크박스 → 고르기(유 / 무) · 저장 글 "true" / "false" 그대로 const box = () => form.root .querySelectorAll("label") .find((l) => l.dataset.specItem === "inlet.animal") - ?.querySelector("input") ?? null; + ?.querySelector("select") ?? null; const animal = () => form.read().inlet_basin_animal ?? null; -const toggle = (on) => { - const input = box(); - input.checked = on; - input.fire("change"); +const pick = (v) => { + const select = box(); + select.value = v; + select.fire("change"); +}; +const shown = () => { + const select = box(); + return select + ? { + value: select.value, + options: select.children.map((o) => [o.value, o.textContent]), + saved: animal(), + } + : null; }; const out = {}; form.write(PIPE_SPEC, { pipe_diameter_mm: 1000, inlet_type: "집수정" }); -out.blank = { checked: box()?.checked ?? null, saved: animal() }; -toggle(false); -out.off = { checked: box().checked, saved: animal() }; -toggle(true); -out.on = { checked: box().checked, saved: animal() }; +out.blank = shown(); +pick("false"); +out.off = shown(); +pick("true"); +out.on = shown(); form.write(PIPE_SPEC, { pipe_diameter_mm: 1000, inlet_type: "집수정", inlet_basin_animal: "false", }); -out.storedOff = { checked: box().checked, saved: animal() }; +out.storedOff = shown(); form.write(PIPE_SPEC, { pipe_diameter_mm: 1000, inlet_type: "기슭막이" }); out.soil = { shown: box() !== null, saved: animal() }; +out.checkbox = form.root.querySelectorAll("input").some((i) => i.type === "checkbox"); process.stdout.write(JSON.stringify(out)); diff --git a/resources/tester/test_173_7_inlet_animal.py b/resources/tester/test_173_7_inlet_animal.py index b8539c476..ccb323207 100644 --- a/resources/tester/test_173_7_inlet_animal.py +++ b/resources/tester/test_173_7_inlet_animal.py @@ -1,4 +1,4 @@ -"""173-7 집수정 「동물이동형」 체크 칸 — 공용 체크박스 · 저장 키 inlet_basin_animal · 빈 값 = 참. +"""173-7 · 177-2 집수정 「동물이동형」 칸 — 고르기 유 / 무 · 저장 키 inlet_basin_animal("true"/"false") · 빈 값 = 유. 공용 명세 폼(`design_structure_form.ts`)을 그 자리에서 돌린 값(`helper_173_7_inlet_animal.cjs`) + 배관 폼 키 목록(`B05_Profile_UI_Drainage_Facility_Merge.ts`). @@ -28,14 +28,18 @@ def out() -> dict: return json.loads(done.stdout) -def test_빈_값은_체크_저장_안_함(out: dict) -> None: - assert out["blank"] == {"checked": True, "saved": None} +YU_MU = [["true", "유"], ["false", "무"]] -def test_끄면_false_다시_켜면_true(out: dict) -> None: - assert out["off"] == {"checked": False, "saved": "false"} - assert out["on"] == {"checked": True, "saved": "true"} - assert out["storedOff"] == {"checked": False, "saved": "false"} +def test_빈_값은_유_실제_값으로_적힘(out: dict) -> None: + # 177-2 — 필수 상자 빈 고르기 칸 = 기본값을 실제 값으로(54-43) · 옛 「저장 안 함」 뒤집음 + assert out["blank"] == {"value": "true", "options": YU_MU, "saved": "true"} + + +def test_무면_false_다시_유면_true(out: dict) -> None: + assert out["off"] == {"value": "false", "options": YU_MU, "saved": "false"} + assert out["on"] == {"value": "true", "options": YU_MU, "saved": "true"} + assert out["storedOff"] == {"value": "false", "options": YU_MU, "saved": "false"} def test_흙막이엔_칸_없음(out: dict) -> None: diff --git a/resources/tester/test_177_2_inlet_animal_select.py b/resources/tester/test_177_2_inlet_animal_select.py new file mode 100644 index 000000000..c77e1f35c --- /dev/null +++ b/resources/tester/test_177_2_inlet_animal_select.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +"""PLAN 177-2 — 동물이동형 = 고르기(유 / 무) · 체크박스 꼴(bool) 지움 · 화면 값은 helper_173_7.""" + +import json +import subprocess +from pathlib import Path + +import pytest + +HERE = Path(__file__).parent +ROOT = HERE.parents[1] +DESIGN = ROOT / "A00_Common" / "design" + + +@pytest.fixture(scope="module") +def out() -> dict: + if not (ROOT / "config" / "node_modules").is_dir(): + pytest.skip("의존성 미설치") + done = subprocess.run( # noqa: S603 — 고정 실행 파일 + ["node", str(HERE / "helper_173_7_inlet_animal.cjs")], + capture_output=True, + text=True, + encoding="utf-8", + ) + assert done.returncode == 0, done.stderr + return json.loads(done.stdout) + + +def test_체크박스_없음(out: dict) -> None: + assert out["checkbox"] is False + + +def test_bool_꼴_지움() -> None: + spec = (DESIGN / "design_structure_spec.ts").read_text("utf-8") + form = (DESIGN / "design_structure_form.ts").read_text("utf-8") + pipe = (DESIGN / "design_structure_pipe.ts").read_text("utf-8") + assert '"bool"' not in spec and '"bool"' not in form and '"bool"' not in pipe + assert "createCheckbox" not in form