지반침하 연계 관로 탭의 부모 종속 제거 처리
This commit is contained in:
@@ -170,7 +170,8 @@ const WATER_RISK_GRID_LAYER_ID = "SN_WATER_RISK_GRID";
|
||||
const WATER_RISK_PIPE_LAYER_ID = "SN_WATER_RISK_PIPE";
|
||||
const FLOOD_HISTORY_SELECTION_PADDING: [number, number, number, number] = [100, 380, 120, 120];
|
||||
const RIGHT_PANEL_TAB_LIMIT = 5;
|
||||
const RIGHT_PANEL_PIPE_TAB_ID = "feature:tb_ms_swage_ppl:singleton";
|
||||
// Only pipes opened from sinkhole details share one slot within the parent-return flow.
|
||||
const RIGHT_PANEL_SINKHOLE_PIPE_TAB_ID = "feature:tb_ms_swage_ppl:sinkhole-singleton";
|
||||
|
||||
type RightPanelTabKind = "feature" | "sinkhole" | "gisEdit";
|
||||
type RightPanelTabCategory =
|
||||
@@ -237,34 +238,20 @@ const RIGHT_PANEL_TAB_STYLE_BY_CATEGORY: Record<
|
||||
},
|
||||
};
|
||||
|
||||
// 탭 제한을 넘으면 새 탭과 현재 탭을 보존하고 오래된 일반 상세부터 정리한다.
|
||||
// 공용 우측 탭은 유형과 활성 상태에 관계없이 먼저 열린 탭부터 제거한다.
|
||||
const findRightPanelTabOverflowCandidate = (
|
||||
tabs: RightPanelTab[],
|
||||
nextTabId: string,
|
||||
activeTabId: string | null,
|
||||
) => {
|
||||
const protectedTabIds = new Set([nextTabId, activeTabId].filter(Boolean) as string[]);
|
||||
[nextTabId, activeTabId].forEach((tabId) => {
|
||||
const pipeTab = tabs.find((tab) => tab.id === tabId && tab.category === "pipe");
|
||||
const parentTabId = pipeTab?.parentTabId;
|
||||
if (parentTabId && tabs.some((tab) => tab.id === parentTabId)) {
|
||||
protectedTabIds.add(parentTabId);
|
||||
}
|
||||
});
|
||||
|
||||
const removableTabs = tabs
|
||||
.filter((tab) => !protectedTabIds.has(tab.id))
|
||||
.sort((a, b) => a.lastActiveAt - b.lastActiveAt);
|
||||
|
||||
return (
|
||||
removableTabs.find((tab) => tab.kind === "feature") ??
|
||||
removableTabs.find((tab) => tab.kind !== "gisEdit") ??
|
||||
removableTabs[0] ??
|
||||
tabs.filter((tab) => tab.id !== nextTabId).sort((a, b) => a.lastActiveAt - b.lastActiveAt)[0] ??
|
||||
null
|
||||
);
|
||||
return tabs.find((tab) => tab.id !== nextTabId) ?? null;
|
||||
};
|
||||
|
||||
// 부모 지반침하가 제거되면 그 부모에서 열린 연계 관로도 같은 탭 그룹으로 제거한다.
|
||||
const removeRightPanelTabGroup = (tabs: RightPanelTab[], removedTabId: string) =>
|
||||
tabs.filter(
|
||||
(tab) => tab.id !== removedTabId && tab.parentTabId !== removedTabId,
|
||||
);
|
||||
|
||||
// 오른쪽 상세 패널에 상세가 2개 이상 쌓였을 때만 책갈피형 전환 버튼을 보여준다.
|
||||
const RightPanelBookmarkTabs = ({
|
||||
tabs,
|
||||
@@ -291,7 +278,7 @@ const RightPanelBookmarkTabs = ({
|
||||
isActive ? style.active : style.inactive,
|
||||
].join(" ")}
|
||||
>
|
||||
{tab.category === "pipe" && isActive && parentTab ? (
|
||||
{tab.category === "pipe" && parentTab ? (
|
||||
<button
|
||||
type="button"
|
||||
className="mr-1 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded text-sm font-bold transition-colors hover:bg-black/10 focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-1"
|
||||
@@ -4750,15 +4737,17 @@ const Map = () => {
|
||||
|
||||
const category = getRightPanelTabCategory(data);
|
||||
const featureId = getRightPanelFeatureIdentifier(data) || `${layerTypeName || "feature"}:${now}`;
|
||||
// Direct map selections accumulate per pipe; only a pipe with a sinkhole parent replaces the linked slot.
|
||||
const pipeParentTabId = category === "pipe" ? pipeParentTabIdRef.current : null;
|
||||
return {
|
||||
id:
|
||||
category === "pipe"
|
||||
? RIGHT_PANEL_PIPE_TAB_ID
|
||||
category === "pipe" && pipeParentTabId
|
||||
? RIGHT_PANEL_SINKHOLE_PIPE_TAB_ID
|
||||
: `feature:${layerTypeName || "unknown"}:${featureId}`,
|
||||
kind: "feature",
|
||||
category,
|
||||
displayLabel: getRightPanelFeatureDisplayLabel(data, category),
|
||||
parentTabId: category === "pipe" ? pipeParentTabIdRef.current : null,
|
||||
parentTabId: pipeParentTabId,
|
||||
featureData: data,
|
||||
lastActiveAt: now,
|
||||
};
|
||||
@@ -4779,14 +4768,13 @@ const Map = () => {
|
||||
const overflowCandidate = findRightPanelTabOverflowCandidate(
|
||||
mergedTabs,
|
||||
nextTab.id,
|
||||
activeRightPanelTabId,
|
||||
);
|
||||
if (!overflowCandidate) return mergedTabs.slice(-RIGHT_PANEL_TAB_LIMIT);
|
||||
|
||||
return mergedTabs.filter((item) => item.id !== overflowCandidate.id);
|
||||
return removeRightPanelTabGroup(mergedTabs, overflowCandidate.id);
|
||||
});
|
||||
setActiveRightPanelTabId(tab.id);
|
||||
}, [activeRightPanelTabId]);
|
||||
}, []);
|
||||
|
||||
const activateRightPanelTab = useCallback(
|
||||
(tabId: string) => {
|
||||
@@ -4834,9 +4822,7 @@ const Map = () => {
|
||||
(tabId: string | null) => {
|
||||
if (!tabId) return;
|
||||
const closingTab = rightPanelTabs.find((tab) => tab.id === tabId);
|
||||
const remainingTabs = rightPanelTabs
|
||||
.filter((tab) => tab.id !== tabId)
|
||||
.map((tab) => (tab.parentTabId === tabId ? { ...tab, parentTabId: null } : tab));
|
||||
const remainingTabs = removeRightPanelTabGroup(rightPanelTabs, tabId);
|
||||
|
||||
if (closingTab?.kind === "sinkhole") {
|
||||
setSelectedSinkholeDetail(null);
|
||||
@@ -4886,11 +4872,9 @@ const Map = () => {
|
||||
if (hasSinkholeTab && activeRightPanelTabId === sinkholeTabId) {
|
||||
closeRightPanelTab(sinkholeTabId);
|
||||
} else {
|
||||
// 비활성 지반침하 탭은 현재 활성 탭을 바꾸지 않고 제거하며 종속 관로의 부모 연결만 해제한다.
|
||||
// 비활성 지반침하 탭은 현재 활성 탭을 바꾸지 않고 종속 관로와 함께 제거한다.
|
||||
setRightPanelTabs((currentTabs) =>
|
||||
currentTabs
|
||||
.filter((tab) => tab.id !== sinkholeTabId)
|
||||
.map((tab) => (tab.parentTabId === sinkholeTabId ? { ...tab, parentTabId: null } : tab)),
|
||||
removeRightPanelTabGroup(currentTabs, sinkholeTabId),
|
||||
);
|
||||
setSelectedSinkholeDetail(null);
|
||||
setSelectedSinkholeNearbyPipes([]);
|
||||
|
||||
Reference in New Issue
Block a user