Files
Aislo/B05_Profile/B05_Profile_UI_Structure_Pick_Session.ts
T
eomsangdonandClaude Opus 5.5 26c2e8b05f fix(b06): 횡단도 구조물 고르기 → 좌측 패널 연결 점검 · 고침(53-1)
- 다른 측점 부재를 누를 때 옛 카드 선택 풀기가 폼 · 선택 칸을 비우던 것 막음(첫 누름부터 잡힘)
- 컨테이너 상자 강조가 폼 다시 그리기에 지워지던 것 · 옛 상자 강조 남던 것 · 유입 · 유출도 보이게 스크롤
- 고른 구조물 기준 측점 고침 = 바로 반영 · 횡단 카드 · 알약 · 선택 칸이 따라감
- 부재키는 같은 것을 다시 적을 때만 지킴 · 풀면 지움(B05 ↔ B06 오갈 때 옛 조정창 안 열림)
- 카드 고름이 일반 측점 · 이음 카드 알약을 지우던 것 → 연 구조물 알약 지킴
- B05 되살리기 = 구조물 id 가 같은 측점 관보다 먼저 · B06 다시 들어올 때 넘김값 다시 적용
- 시험: ui_checks/53-1_횡단_고르기.js(점검 116 · 흠 0) · 선택 시험 새 규칙으로

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4uKaV4ZBhsJN4GHG7yRj4
2026-10-06 10:20:37 +09:00

97 lines
4.7 KiB
TypeScript

/* =============================================================================
* B05_Profile_UI_Structure_Pick_Session.ts
* 3D에서 고른 구조물을 **좌측 「구조물 배치」 패널로 넘기고**, 그 선택을 세션 한 칸에
* 남겨 **B06 진입 때 같은 측점 카드가 열리게** 한다(2026-09-04 사용자 확정).
*
* B05·B06은 라우터가 따로 띄우는 화면이라 실시간 양방향이 아니다 — 조작 상태는 캐시
* 몫이라는 데이터 3층 규칙대로 sessionStorage 한 칸에 남긴다. 값은 **지우지 않고 남긴다**
* (2026-09-04 사용자: 두 화면이 한 페이지처럼 움직여야 함) — B06에서 고른 것도 같은 칸에
* 적혀, 어느 쪽으로 오가든 마지막 선택이 그대로 살아 있다.
* ========================================================================== */
import {
NO_SELECTION,
readSelection,
selectDesign,
type DesignSelection,
} from "../A00_Common/design/design_selection";
import type { StructurePick, StructurePickControls } from "./B05_Profile_UI_Viewer_Structure_Pick";
import type { StructuresSection } from "./B05_Profile_UI_Structures_Panel_Types";
/** B06으로 넘기는 선택 — B06이 쓰는 `{ 측점, 부재키 }` 한 쌍에 구조물 id 가 붙는다. */
export interface StructurePickHandoff {
at: number;
key?: string;
structureId?: string;
}
/* 넘김값은 `design_selection` 의 selection 한 곳이다 — 3D · 알약 · 목록 · 횡단 카드 어디서
골라도 그 함수 하나로 적고(`selectDesign`), 여기서는 읽기만 한다. 값은 ② 설계 초안이라
등록표(`b_page_state`)를 쓴다(2026-09-06 캐시·세션 일원화). */
/** 세션에 남은 선택을 읽는다(지우지 않는다). 없으면 null. */
export function readStructurePick(projectId: string | null): StructurePickHandoff | null {
const value = readSelection(projectId);
if (!value || value.chainageM === null) return null;
return {
at: value.chainageM,
key: value.partKey,
structureId: value.structureId ?? undefined,
};
}
/**
* 3D 클릭 결과를 화면 전체에 적용한다.
*
* 배수관 세트(기슭막이·집수정·배관)는 `selectStation`(=기존 선택 동기화)이 좌측 폼·종단
* 그래프·3D 마커·유역도를 한 줄로 맞춘다. 그 줄에서 아무것도 안 잡히면 옛 정본 구조물로
* 보고 폼이 구조물 id 로 연다 — 관·구조물 찾는 거리와 순서는 `resolveSelection` 한 곳이다.
*/
export function wireStructurePick(
controls: StructurePickControls,
projectId: string | null,
structures: StructuresSection,
/** 기존 선택 동기화(`selectStationOfPipe`) — 누가거리 하나로 전 화면을 맞춘다. */
selectStation: (chainageM: number | null) => void,
): void {
controls.onPick = (pick: StructurePick | null): void => {
if (!pick) {
selectDesign(projectId, NO_SELECTION, { from: "b05" });
selectStation(null);
return;
}
const selection: DesignSelection = { chainageM: pick.chainageM, structureId: null };
const { structureId } = structures.resolveAt(selection);
selectDesign(projectId, { ...selection, structureId }, { partKey: pick.key, from: "b05" });
selectStation(pick.chainageM);
if (!structures.hasSelection()) structures.selectAt({ ...selection, structureId });
};
}
/**
* 화면에 들어올 때 세션에 남은 선택을 되살린다 — B06에서 고른 것도 그대로 이어 받는다
* (2026-09-04 사용자: 두 화면이 한 페이지처럼). 3D 강조는 코리도가 뜬 뒤 자동으로 다시
* 칠해지므로 여기서는 선택만 세워 둔다.
*
* **되살렸으면 true.** 관 목록이 아직 안 실렸으면 폼이 그 시설을 못 찾으므로 false를
* 돌려준다 — 부르는 쪽은 목록이 실릴 때마다 다시 부르면 된다.
*/
export function restoreStructurePick(
controls: StructurePickControls,
projectId: string | null,
structures: StructuresSection,
selectStation: (chainageM: number | null) => void,
): boolean {
const handoff = readStructurePick(projectId);
if (!handoff) return true; // 되살릴 것이 없으면 끝난 것으로 본다.
controls.select({ chainageM: handoff.at, kind: "", key: handoff.key });
selectStation(handoff.at);
// 구조물 id 가 적혀 있을 때만 구조물로 연다 — 관 목록이 아직 안 실렸을 때 측점만으로 구조물을
// 짐작하면 그 측점을 덮는 다른 구조물이 열린다(관은 목록이 실릴 때 위 `selectStation` 이 연다).
// id 가 있으면 측점이 연 관보다 먼저다(resolveSelection ① · 53-1)
if (handoff.structureId) {
structures.selectAt({ chainageM: handoff.at, structureId: handoff.structureId });
}
return structures.hasSelection();
}