|
|
|
@@ -571,6 +571,8 @@ export function wireStructureSelection(
|
|
|
|
|
remember?: (chainageM: number, key: string) => void,
|
|
|
|
|
/** 폼에서 고른 벽을 카드 조정창에도 세움(54-30 · 목록 넘김 `applyStructurePick` 과 같은 차례). */
|
|
|
|
|
refreshCard?: (chainageM: number) => void,
|
|
|
|
|
/** 폼에 올린 시설로 보기를 옮김 — 목록에서 고른 길(54-47). */
|
|
|
|
|
reveal?: (chainageM: number) => void,
|
|
|
|
|
): { syncInletStructure: () => void } {
|
|
|
|
|
const ownerChainageOf = (chainageM: number): number => {
|
|
|
|
|
const sectionAt = detail()?.cross_sections.find(
|
|
|
|
@@ -614,23 +616,54 @@ export function wireStructureSelection(
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 관 상자 칸을 고치거나 고르면 그 부분을 고름 — 횡단에서 누른 것과 같은 길(54-30)
|
|
|
|
|
panel.root.addEventListener("change", (event) => {
|
|
|
|
|
// 단 수 칸은 고른 단을 지킴(단 수 바꿈 뒤 강조 유지)
|
|
|
|
|
if ((event.target as HTMLElement).closest('[data-spec-item="outlet.tiers"]')) return;
|
|
|
|
|
const box = (event.target as HTMLElement).closest<HTMLElement>("fieldset[data-spec-container]");
|
|
|
|
|
const keyOf = (box: HTMLElement): RevetKey | null => {
|
|
|
|
|
const id = box.dataset.specContainer;
|
|
|
|
|
if (id === "inlet" || id === "outlet") return id;
|
|
|
|
|
return id === "soil_add" ? `extra${Number(box.dataset.specIndex)}` : null;
|
|
|
|
|
};
|
|
|
|
|
const pickBox = (box: HTMLElement): void => {
|
|
|
|
|
const chainageM = panel.currentChainage();
|
|
|
|
|
const target = chainageM === null ? undefined : sectionAt(chainageM);
|
|
|
|
|
if (!box || !target?.culvert) return;
|
|
|
|
|
const id = box.dataset.specContainer;
|
|
|
|
|
const key: RevetKey | null =
|
|
|
|
|
id === "inlet" || id === "outlet"
|
|
|
|
|
? id
|
|
|
|
|
: id === "soil_add"
|
|
|
|
|
? `extra${Number(box.dataset.specIndex)}`
|
|
|
|
|
: null;
|
|
|
|
|
if (!key || stationControls.revetOffset.highlightFor(target) === key) return;
|
|
|
|
|
const key = keyOf(box);
|
|
|
|
|
if (!key || !target?.culvert || stationControls.revetOffset.highlightFor(target) === key)
|
|
|
|
|
return;
|
|
|
|
|
stationControls.revetOffset.select(target.chainage_m, key);
|
|
|
|
|
refreshCard?.(target.chainage_m);
|
|
|
|
|
};
|
|
|
|
|
// 그 측점 카드 · 알약으로 감(목록에서 고른 길 · 54-47) — 같은 칸을 잇달아 고치면 한 번만(다시 그려도 칸 이름으로)
|
|
|
|
|
const fieldOf = (el: HTMLElement): string => {
|
|
|
|
|
const box = el.closest<HTMLElement>("fieldset[data-spec-container]");
|
|
|
|
|
const item = el.closest<HTMLElement>("[data-spec-item]")?.dataset.specItem;
|
|
|
|
|
return `${box?.dataset.specContainer}:${box?.dataset.specIndex}:${item}`;
|
|
|
|
|
};
|
|
|
|
|
let revealed: string | null = null;
|
|
|
|
|
const revealAt = (chainageM: number, field: string | null): void => {
|
|
|
|
|
if (field && field === revealed) return;
|
|
|
|
|
revealed = field;
|
|
|
|
|
reveal?.(chainageM);
|
|
|
|
|
};
|
|
|
|
|
panel.root.addEventListener("focusin", (event) => {
|
|
|
|
|
if (fieldOf(event.target as HTMLElement) !== revealed) revealed = null;
|
|
|
|
|
});
|
|
|
|
|
panel.root.addEventListener("change", ({ target: el }) => {
|
|
|
|
|
const box = (el as HTMLElement).closest<HTMLElement>("fieldset[data-spec-container]");
|
|
|
|
|
const chainageM = panel.currentChainage();
|
|
|
|
|
if (!box || chainageM === null) return;
|
|
|
|
|
revealAt(chainageM, fieldOf(el as HTMLElement));
|
|
|
|
|
// 단 수 칸은 고른 단을 지킴(단 수 바꿈 뒤 강조 유지) — 새 단은 다시 그린 뒤 아래에서 고름
|
|
|
|
|
if (!(el as HTMLElement).closest('[data-spec-item="outlet.tiers"]')) pickBox(box);
|
|
|
|
|
});
|
|
|
|
|
// 상자가 새로 서면(단 늘림 · [추가]) 그 상자를 고름 — 같은 시설을 다시 그린 때만
|
|
|
|
|
let painted: { chainageM: number | null; keys: Set<string> } | null = null;
|
|
|
|
|
panel.root.addEventListener("specpaint", () => {
|
|
|
|
|
const chainageM = panel.currentChainage();
|
|
|
|
|
const boxes = [...panel.root.querySelectorAll<HTMLElement>("fieldset[data-spec-container]")];
|
|
|
|
|
const before = painted?.chainageM === chainageM ? painted.keys : null;
|
|
|
|
|
painted = { chainageM, keys: new Set(boxes.map(fieldOf)) };
|
|
|
|
|
const born = before ? boxes.filter((box) => !before.has(fieldOf(box))).at(-1) : undefined;
|
|
|
|
|
if (!born || chainageM === null) return;
|
|
|
|
|
revealAt(chainageM, null);
|
|
|
|
|
pickBox(born);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const origFord = stationControls.ford.select;
|
|
|
|
|