171 lines
6.7 KiB
TypeScript
171 lines
6.7 KiB
TypeScript
"use client";
|
|
|
|
import type { GisEditSessionSnapshot, GisEditTool } from "./gisEditTypes";
|
|
|
|
type Props = GisEditSessionSnapshot & {
|
|
onRemoveFocusedChange: () => void;
|
|
onRemoveLastChange: () => void;
|
|
onClearChanges: () => void;
|
|
onFocusChange: (changeId: string) => void;
|
|
onOpenPopup?: () => void;
|
|
variant?: "inline" | "popup";
|
|
className?: string;
|
|
};
|
|
|
|
const TOOL_LABELS: Record<GisEditTool, string> = {
|
|
ADD: "추가",
|
|
MOVE: "이동",
|
|
VERTEX_EDIT: "꼭지점편집",
|
|
DELETE: "삭제",
|
|
};
|
|
|
|
const buildChangeItemClassName = (isFocused: boolean) =>
|
|
`block w-full rounded border px-2 py-2 text-left text-[12px] transition ${
|
|
isFocused
|
|
? "border-[#5a9bd5] bg-[#eef7ff] shadow-[inset_0_0_0_1px_rgba(90,155,213,0.2)]"
|
|
: "border-[#d8dee8] bg-[#fbfcfe] hover:border-[#bfd2e5] hover:bg-white"
|
|
}`;
|
|
|
|
const getChangeLabel = (change: GisEditSessionSnapshot["changes"][number]) =>
|
|
change.attributeOnly ? "상세정보수정" : TOOL_LABELS[change.editType];
|
|
|
|
const getChangeSummary = (change: GisEditSessionSnapshot["changes"][number]) => {
|
|
if (change.attributeOnly) return "변경한 상세정보를 확인하세요.";
|
|
if (change.editType === "ADD") return "추가한 객체 위치를 확인하세요.";
|
|
if (change.editType === "MOVE") return "객체를 드래그해 위치를 조정하세요.";
|
|
if (change.editType === "VERTEX_EDIT") return "점을 옮기거나 선분을 끌어 추가하세요.";
|
|
return "삭제할 객체가 맞는지 확인하세요.";
|
|
};
|
|
|
|
type ChangeListProps = {
|
|
changes: GisEditSessionSnapshot["changes"];
|
|
focusedChangeId: string | null;
|
|
onFocusChange: (changeId: string) => void;
|
|
};
|
|
|
|
const ChangeList = ({ changes, focusedChangeId, onFocusChange }: ChangeListProps) => (
|
|
<>
|
|
{changes.map((change, index) => (
|
|
<button
|
|
key={change.changeId}
|
|
type="button"
|
|
className={buildChangeItemClassName(focusedChangeId === change.changeId)}
|
|
onClick={() => onFocusChange(change.changeId)}
|
|
>
|
|
<div className="flex items-center gap-1">
|
|
<div className="shrink-0 whitespace-nowrap text-[11px] font-semibold leading-4 text-[#173f67]">
|
|
{index + 1}. {getChangeLabel(change)} / {change.objectLabel}
|
|
</div>
|
|
<div className="ml-auto flex shrink-0 items-center gap-1">
|
|
{change.basicInfoSavedAt && focusedChangeId !== change.changeId ? (
|
|
<span className="whitespace-nowrap rounded-full border border-[#a9d9bd] bg-white px-1.5 py-0.5 text-[9px] font-semibold text-[#16834f]">
|
|
정보저장
|
|
</span>
|
|
) : null}
|
|
{focusedChangeId === change.changeId ? (
|
|
<span className="whitespace-nowrap rounded-full border border-[#b8d3ef] bg-white px-1.5 py-0.5 text-[9px] font-semibold text-[#176db8]">
|
|
지도 미리보기 선택
|
|
</span>
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
<div className="mt-1 truncate text-[11px] text-[#526173]">{getChangeSummary(change)}</div>
|
|
</button>
|
|
))}
|
|
</>
|
|
);
|
|
|
|
export default function GisEditSessionPanel({
|
|
isEditMode,
|
|
selectedLayerName,
|
|
activeTool,
|
|
changes,
|
|
canUndo,
|
|
focusedChangeId,
|
|
onRemoveFocusedChange,
|
|
onRemoveLastChange,
|
|
onClearChanges,
|
|
onFocusChange,
|
|
onOpenPopup,
|
|
variant = "inline",
|
|
className = "",
|
|
}: Props) {
|
|
const isCompactInline = variant === "inline" && changes.length === 0;
|
|
|
|
return (
|
|
<div
|
|
className={`flex min-h-0 flex-col overflow-hidden rounded-lg border border-[#d8dee8] bg-[rgba(255,255,255,0.98)] text-sm text-[#304255] shadow-[0_10px_26px_rgba(23,42,70,0.14)] ${isCompactInline ? "h-[58px] p-2" : "p-4"} ${className}`.trim()}
|
|
>
|
|
<div className={`flex shrink-0 justify-between gap-3 ${isCompactInline ? "mb-0 items-center" : "mb-3 items-start"}`}>
|
|
<div className="min-w-0">
|
|
{variant === "inline" ? (
|
|
<div className="mb-1 text-[14px] font-bold text-[#173f67]">편집 세션</div>
|
|
) : null}
|
|
<div className="truncate text-[12px] text-[#667485]">
|
|
레이어: {selectedLayerName || "미선택"} / 모드: {isEditMode ? (activeTool ? TOOL_LABELS[activeTool] : "대기") : "편집 모드 종료"}
|
|
</div>
|
|
</div>
|
|
{onOpenPopup ? (
|
|
<button
|
|
type="button"
|
|
className="flex shrink-0 items-center gap-1 rounded border border-[#b8d3ef] bg-white px-2.5 py-1.5 text-[11px] font-semibold text-[#176db8] transition hover:bg-[#eef7ff]"
|
|
onClick={onOpenPopup}
|
|
title="편집 세션을 기존 윈도우 팝업으로 열기"
|
|
>
|
|
<span aria-hidden="true" className="text-[12px] leading-none">↗</span>
|
|
<span>팝업</span>
|
|
</button>
|
|
) : null}
|
|
</div>
|
|
|
|
<div className={`${isCompactInline ? "hidden" : "mb-3 flex"} shrink-0 flex-wrap items-center gap-2`}>
|
|
<button
|
|
type="button"
|
|
className="rounded border border-[#d8dee8] bg-white px-3 py-1.5 text-[12px] font-semibold text-[#304255] transition hover:bg-[#f8fafc] disabled:cursor-not-allowed disabled:text-[#9aa8b7]"
|
|
disabled={!focusedChangeId}
|
|
onClick={onRemoveFocusedChange}
|
|
>
|
|
취소
|
|
</button>
|
|
<button
|
|
type="button"
|
|
className="rounded border border-[#d8dee8] bg-white px-3 py-1.5 text-[12px] font-semibold text-[#304255] transition hover:bg-[#f8fafc] disabled:cursor-not-allowed disabled:text-[#9aa8b7]"
|
|
disabled={!canUndo}
|
|
onClick={onRemoveLastChange}
|
|
>
|
|
뒤로가기
|
|
</button>
|
|
<button
|
|
type="button"
|
|
className="rounded border border-[#f3d0d0] bg-white px-3 py-1.5 text-[12px] font-semibold text-[#b42318] transition hover:bg-[#fff5f5] disabled:cursor-not-allowed disabled:text-[#d0a5a5]"
|
|
disabled={!canUndo}
|
|
onClick={onClearChanges}
|
|
>
|
|
초기화
|
|
</button>
|
|
<div className="ml-auto rounded-full border border-[#d8dee8] bg-white px-2.5 py-1 text-[11px] font-semibold text-[#526173]">
|
|
총 {changes.length}건
|
|
</div>
|
|
</div>
|
|
|
|
<div className={`${isCompactInline ? "hidden" : "min-h-0 flex-1"} overflow-hidden`}>
|
|
{changes.length === 0 ? (
|
|
<div className="rounded border border-dashed border-[#d8dee8] bg-[#fbfcfe] px-3 py-4 text-[12px] text-[#667485]">
|
|
저장할 편집 변경분이 없습니다.
|
|
</div>
|
|
) : (
|
|
<div className="h-full overflow-y-auto pr-1">
|
|
<div className="space-y-2">
|
|
<ChangeList
|
|
changes={changes}
|
|
focusedChangeId={focusedChangeId}
|
|
onFocusChange={onFocusChange}
|
|
/>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|