fix(B06): 월류 폭을 바꾸면 월류 높이(필요 수심)가 따라오게 한다

`syncFordSummary`가 "빈 칸이거나 계산값보다 작을 때만" 높이를 채워 넣어, 폭을
바꿔 필요 수심이 **낮아지는** 쪽으로 움직이면 칸이 옛 값 그대로 남았다. 안내문
(설계유량·필요 수심·필요 단면)만 바뀌고 높이는 안 바뀌는 것으로 보였다.

칸이 아직 **직전에 자동으로 채운 값 그대로**인지 본다(±0.005m). 그대로면 자동
상태로 보고 계산값을 계속 따라가고, 사용자가 다른 값을 넣었으면 그때부터 그
값이 이긴다. 시설을 새로 폼에 올릴 때는 추적을 끊어(`fordAutoDepthM = null`)
저장돼 있던 높이를 사용자 값으로 대접한다.

자체검증(공용 브라우저 5174, 측점 7+9.7 세월교, 설계유량 36.734 ㎥/s):
- tsc --noEmit 통과.
- 자동 상태(폭 10 → 높이 0.39)에서 폭 5 → 0.63(올라감), 폭 20 → 0.25(내려감).
  수정 전에는 0.63에서 내려오지 않았다.
- 높이를 2.5로 직접 넣은 뒤 폭 20→5 → 2.5 유지(사용자 값 우선).
- 조작값은 원래대로(폭 10 · 높이 자동 0.39) 되돌려 놓았다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-30 12:23:38 +09:00
co-authored by Claude Opus 5
parent f8086e786d
commit 7385b4d76f
@@ -385,6 +385,10 @@ export function createFacilityOptionsForm(
let designFlowM3s: number | null = null;
/** 현재 조건(설계유량·월류 폭)의 필요 최소 수심(m). 계산 불가면 null. */
let fordMinDepthM: number | null = null;
/** 직전에 자동으로 채워 넣은 필요 수심(m) — 칸이 아직 그 값이면 "자동"으로 보고
* 월류 폭이 바뀔 때마다 계산값을 계속 따라가게 한다. 사용자가 다른 값을 넣으면
* 그때부터 그 값이 이긴다(2026-08-30 사용자: 폭을 바꿔도 높이가 안 따라온다). */
let fordAutoDepthM: number | null = null;
function syncFordSummary(): void {
const section =
@@ -393,10 +397,14 @@ export function createFacilityOptionsForm(
: null;
fordMinDepthM = section ? section.depthM : null;
if (section) {
// 표시 정밀도(0.01m)로 맞춘 최소값 — 비었거나 그보다 작으면 계산값으로 채운다.
// 표시 정밀도(0.01m)로 맞춘 최소값 — 비었거나, 그보다 작거나, 아직 직전
// 자동값 그대로면 계산값으로 다시 채운다.
const min = Number(section.depthM.toFixed(2));
const current = Number.parseFloat(fordHeight.value);
if (!Number.isFinite(current) || current < min) fordHeight.value = min.toFixed(2);
const untouched = fordAutoDepthM !== null && Math.abs(current - fordAutoDepthM) < 0.005;
if (!Number.isFinite(current) || current < min || untouched)
fordHeight.value = min.toFixed(2);
fordAutoDepthM = min;
}
if (designFlowM3s === null) {
fordSummary.textContent =
@@ -615,6 +623,8 @@ export function createFacilityOptionsForm(
fordCount.value = isFord ? text("pipe_count") : "";
fordWidth.value = text("ford_width_m");
fordHeight.value = text("ford_height_m");
// 새 시설을 올리는 참이다 — 저장된 높이는 사용자 값으로 보고 자동 추적을 끊는다.
fordAutoDepthM = null;
fordSlope.value = text("ford_slope_pct");
revetSide.value = text("side") || "양쪽";
const spread = legacyRevetOptions(options);