"use client"; import { useState } from "react"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Trash2, Settings, Database, Link2 } from "lucide-react"; import { useReportDesigner } from "@/contexts/ReportDesignerContext"; import { QueryManager } from "./QueryManager"; export function ReportDesignerRightPanel() { const context = useReportDesigner(); const { selectedComponentId, components, updateComponent, removeComponent, queries } = context; const [activeTab, setActiveTab] = useState("properties"); const selectedComponent = components.find((c) => c.id === selectedComponentId); // 선택된 쿼리의 결과 필드 가져오기 const getQueryFields = (queryId: string): string[] => { const result = context.getQueryResult(queryId); return result ? result.fields : []; }; return (
속성 쿼리
{/* 속성 탭 */}
{!selectedComponent ? (
컴포넌트를 선택하면 속성을 편집할 수 있습니다
) : (
컴포넌트 속성
{/* 타입 */}
{selectedComponent.type}
{/* 위치 */}
updateComponent(selectedComponent.id, { x: parseInt(e.target.value) || 0, }) } className="h-8" />
updateComponent(selectedComponent.id, { y: parseInt(e.target.value) || 0, }) } className="h-8" />
{/* 크기 */}
updateComponent(selectedComponent.id, { width: parseInt(e.target.value) || 50, }) } className="h-8" />
updateComponent(selectedComponent.id, { height: parseInt(e.target.value) || 30, }) } className="h-8" />
{/* 글꼴 크기 */}
updateComponent(selectedComponent.id, { fontSize: parseInt(e.target.value) || 13, }) } className="h-8" />
{/* 글꼴 색상 */}
updateComponent(selectedComponent.id, { fontColor: e.target.value, }) } className="h-8" />
{/* 배경 색상 */}
updateComponent(selectedComponent.id, { backgroundColor: e.target.value, }) } className="h-8" />
{/* 데이터 바인딩 (텍스트/라벨/테이블 컴포넌트) */} {(selectedComponent.type === "text" || selectedComponent.type === "label" || selectedComponent.type === "table") && (
데이터 바인딩
{/* 쿼리 선택 */}
{/* 필드 선택 (텍스트/라벨만) */} {selectedComponent.queryId && (selectedComponent.type === "text" || selectedComponent.type === "label") && (
)} {/* 테이블 안내 메시지 */} {selectedComponent.queryId && selectedComponent.type === "table" && (
테이블은 선택한 쿼리의 모든 필드를 자동으로 표시합니다.
)} {/* 기본값 (텍스트/라벨만) */} {(selectedComponent.type === "text" || selectedComponent.type === "label") && (
updateComponent(selectedComponent.id, { defaultValue: e.target.value, }) } placeholder="데이터가 없을 때 표시할 값" className="h-8" />
)} {/* 포맷 (텍스트/라벨만) */} {(selectedComponent.type === "text" || selectedComponent.type === "label") && (
updateComponent(selectedComponent.id, { format: e.target.value, }) } placeholder="예: YYYY-MM-DD, #,###" className="h-8" />
)}
)}
)}
{/* 쿼리 탭 */}
); }