Merge branch 'iipbs/sn/dev'

This commit is contained in:
kiminchan
2026-09-28 10:00:24 +09:00
49 changed files with 564 additions and 213 deletions
@@ -93,6 +93,8 @@ function Gis({
showLayerPanelTitle = true,
// sn 관망도처럼 트리와 선택 설정을 카드 두 개로 구분해야 하는 화면에서만 활성화한다.
sectionedTreePanel = false,
// 전체 체크 조작은 필요한 화면에서만 명시적으로 활성화한다.
showBulkLayerToggle = false,
showZoomScaleInfo = false,
}) {
const mapRef = useRef();
@@ -345,6 +347,7 @@ function Gis({
detachedToggleButton={detachedTreeToggleButton}
showLayerPanelTitle={showLayerPanelTitle}
sectionedPanel={sectionedTreePanel}
showBulkLayerToggle={showBulkLayerToggle}
/>
{typeof WaterDepth === "function" && (
@@ -10,6 +10,7 @@ import React, { useEffect, useLayoutEffect, useState, useRef, useCallback } from
import { showBusinessUserMessage } from "../../lib/user-message";
import { useGisContext } from "./Gis";
import GisApp from "./lib/gis.core";
import { getBulkLayerSelection, getBulkLayerState } from "./layerBulkSelection";
/**
* GisTree (React memoized component)
@@ -63,6 +64,7 @@ export default React.memo(function GisTree({
showLayerPanelTitle = true,
detachedToggleButton = false,
sectionedPanel = false,
showBulkLayerToggle = false,
}) {
const { gisCore, treeData } = useGisContext();
@@ -71,6 +73,8 @@ export default React.memo(function GisTree({
const [expanded, setExpanded] = useState([]);
const [nodes, setNodes] = useState([]);
const [activeTab, setActiveTab] = useState("layers");
// 전체 선택이면 ON, 부분 선택이면 OFF 위치와 별도 상태 문구로 구분한다.
const bulkLayerState = getBulkLayerState(nodes, checked);
// 자동 애니메이션 관련 ref (실행 인덱스, 대상 노드 목록, 일시정지, 타이머)
const currentAnimationIndexRef = useRef(0);
@@ -470,6 +474,19 @@ export default React.memo(function GisTree({
isPausedRef.current = true;
}, []);
/** 전체 조작은 자동재생을 멈추고 트리·지도·업무 콜백에 같은 선택을 한 번 반영한다. */
const handleBulkLayerToggle = useCallback((enabled) => {
if (!gisCore || nodes.length === 0) return;
pauseAnimation();
setIsPlaying(false);
const { checkedIds, uncheckedIds, selectedNodes } = getBulkLayerSelection(nodes, enabled);
// 배경지도나 편집 오버레이가 아닌 현재 트리에 등록된 레이어만 변경한다.
gisCore.setLayerOnMap(uncheckedIds, false);
gisCore.setLayerOnMap(checkedIds, true);
setChecked(checkedIds);
onCheckedChange?.(checkedIds, selectedNodes);
}, [gisCore, nodes, onCheckedChange, pauseAnimation, setIsPlaying]);
/**
* 재생/정지/대상/간격 변경에 반응하여 애니메이션을 관리합니다.
*/
@@ -626,6 +643,20 @@ export default React.memo(function GisTree({
<Layers size={14} strokeWidth={2} />
</span>
<h3 className="text-[1.4rem] font-bold text-foreground">레이어 관리</h3>
{showBulkLayerToggle && (
<button type="button" role="switch" aria-label="전체 레이어"
aria-checked={bulkLayerState.allChecked}
aria-description={bulkLayerState.partiallyChecked ? "일부 레이어 켜짐. 누르면 전체를 켭니다." : undefined}
title={bulkLayerState.allChecked ? "레이어 전체 끄기" : "레이어 전체 켜기"}
disabled={!gisCore || bulkLayerState.disabled}
className="ml-auto flex shrink-0 items-center gap-1 rounded-sm text-[1.1rem] focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-40"
onClick={() => handleBulkLayerToggle(!bulkLayerState.allChecked)}>
<span>{bulkLayerState.partiallyChecked ? "일부 켜짐" : "전체"}</span>
<span aria-hidden="true" className={`relative inline-flex h-[18px] w-[32px] items-center rounded-full transition-colors ${bulkLayerState.allChecked ? "bg-[#168CFF]" : "bg-gray-300"}`}>
<span className={`h-[14px] w-[14px] rounded-full bg-white shadow-sm transition-transform ${bulkLayerState.allChecked ? "translate-x-[16px]" : "translate-x-[2px]"}`} />
</span>
</button>
)}
</div>
)}
<div
@@ -0,0 +1,25 @@
/** 화면에 표시하도록 허용된 트리 노드만 전체 켜기 대상으로 선택한다. */
export function getBulkLayerSelection(nodes, enabled) {
const selectedNodes = enabled
? nodes.filter((node) => node.data?.exprsYn === "Y")
: [];
const checkedIds = selectedNodes.map((node) => node.id);
const selected = new Set(checkedIds);
return {
checkedIds,
selectedNodes,
uncheckedIds: nodes.filter((node) => !selected.has(node.id)).map((node) => node.id),
};
}
/** 개별 체크 변경도 전체 토글에 반영하며 숨김 노드는 집계에서 제외한다. */
export function getBulkLayerState(nodes, checkedIds) {
const visibleIds = nodes.filter((node) => node.data?.exprsYn === "Y").map((node) => node.id);
const checked = new Set(checkedIds);
const count = visibleIds.filter((id) => checked.has(id)).length;
return {
disabled: visibleIds.length === 0,
allChecked: visibleIds.length > 0 && count === visibleIds.length,
partiallyChecked: count > 0 && count < visibleIds.length,
};
}