[agent-pipeline] pipe-20260311155325-udmh round-2
This commit is contained in:
parent
52a73e8cda
commit
e1508e9087
|
|
@ -0,0 +1,564 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* V2 출발지/도착지 선택 설정 패널
|
||||||
|
* 토스식 단계별 UX: 데이터 소스 -> 필드 매핑 -> UI 설정 -> DB 초기값(접힘)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||||
|
import { Settings, ChevronDown } from "lucide-react";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { apiClient } from "@/lib/api/client";
|
||||||
|
|
||||||
|
interface V2LocationSwapSelectorConfigPanelProps {
|
||||||
|
config: any;
|
||||||
|
onChange: (config: any) => void;
|
||||||
|
tableColumns?: Array<{ columnName: string; columnLabel?: string; dataType?: string }>;
|
||||||
|
screenTableName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const V2LocationSwapSelectorConfigPanel: React.FC<V2LocationSwapSelectorConfigPanelProps> = ({
|
||||||
|
config,
|
||||||
|
onChange,
|
||||||
|
tableColumns = [],
|
||||||
|
screenTableName,
|
||||||
|
}) => {
|
||||||
|
const [tables, setTables] = useState<Array<{ name: string; label: string }>>([]);
|
||||||
|
const [columns, setColumns] = useState<Array<{ name: string; label: string }>>([]);
|
||||||
|
const [codeCategories, setCodeCategories] = useState<Array<{ value: string; label: string }>>([]);
|
||||||
|
const [dbSettingsOpen, setDbSettingsOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadTables = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiClient.get("/table-management/tables");
|
||||||
|
if (response.data.success && response.data.data) {
|
||||||
|
setTables(
|
||||||
|
response.data.data.map((t: any) => ({
|
||||||
|
name: t.tableName || t.table_name,
|
||||||
|
label: t.displayName || t.tableLabel || t.table_label || t.tableName || t.table_name,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("테이블 목록 로드 실패:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadTables();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadColumns = async () => {
|
||||||
|
const tableName = config?.dataSource?.tableName;
|
||||||
|
if (!tableName) {
|
||||||
|
setColumns([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await apiClient.get(`/table-management/tables/${tableName}/columns`);
|
||||||
|
if (response.data.success) {
|
||||||
|
let columnData = response.data.data;
|
||||||
|
if (!Array.isArray(columnData) && columnData?.columns) {
|
||||||
|
columnData = columnData.columns;
|
||||||
|
}
|
||||||
|
if (Array.isArray(columnData)) {
|
||||||
|
setColumns(
|
||||||
|
columnData.map((c: any) => ({
|
||||||
|
name: c.columnName || c.column_name || c.name,
|
||||||
|
label: c.displayName || c.columnLabel || c.column_label || c.columnName || c.column_name || c.name,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("컬럼 목록 로드 실패:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (config?.dataSource?.type === "table") {
|
||||||
|
loadColumns();
|
||||||
|
}
|
||||||
|
}, [config?.dataSource?.tableName, config?.dataSource?.type]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadCodeCategories = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiClient.get("/code-management/categories");
|
||||||
|
if (response.data.success && response.data.data) {
|
||||||
|
setCodeCategories(
|
||||||
|
response.data.data.map((c: any) => ({
|
||||||
|
value: c.category_code || c.categoryCode || c.code,
|
||||||
|
label: c.category_name || c.categoryName || c.name,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error?.response?.status !== 404) {
|
||||||
|
console.error("코드 카테고리 로드 실패:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadCodeCategories();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleChange = (path: string, value: any) => {
|
||||||
|
const keys = path.split(".");
|
||||||
|
const newConfig = { ...config };
|
||||||
|
let current: any = newConfig;
|
||||||
|
for (let i = 0; i < keys.length - 1; i++) {
|
||||||
|
if (!current[keys[i]]) {
|
||||||
|
current[keys[i]] = {};
|
||||||
|
}
|
||||||
|
current = current[keys[i]];
|
||||||
|
}
|
||||||
|
current[keys[keys.length - 1]] = value;
|
||||||
|
onChange(newConfig);
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataSourceType = config?.dataSource?.type || "static";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* ─── 1단계: 데이터 소스 ─── */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<p className="text-sm font-medium">데이터 소스</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">장소 목록을 어디서 가져올지 선택해요</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
|
{/* 소스 타입 카드 선택 */}
|
||||||
|
<div className="grid grid-cols-3 gap-2">
|
||||||
|
{[
|
||||||
|
{ value: "static", label: "고정 옵션" },
|
||||||
|
{ value: "table", label: "테이블" },
|
||||||
|
{ value: "code", label: "코드 관리" },
|
||||||
|
].map(({ value, label }) => (
|
||||||
|
<button
|
||||||
|
key={value}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleChange("dataSource.type", value)}
|
||||||
|
className={cn(
|
||||||
|
"rounded-md border p-2 text-xs transition-colors text-center",
|
||||||
|
dataSourceType === value
|
||||||
|
? "border-primary bg-primary/5 text-primary"
|
||||||
|
: "border-border bg-background text-muted-foreground hover:bg-muted/50"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 고정 옵션 설정 */}
|
||||||
|
{dataSourceType === "static" && (
|
||||||
|
<div className="space-y-2 pt-1">
|
||||||
|
<div className="rounded-md border border-primary/20 bg-primary/5 p-2">
|
||||||
|
<p className="text-[10px] text-primary">고정된 2개 장소만 사용할 때 설정해요 (예: 포항 / 광양)</p>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Label className="text-[10px] text-muted-foreground">옵션 1 값</Label>
|
||||||
|
<Input
|
||||||
|
value={config?.dataSource?.staticOptions?.[0]?.value || ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
const options = config?.dataSource?.staticOptions || [];
|
||||||
|
const newOptions = [...options];
|
||||||
|
newOptions[0] = { ...newOptions[0], value: e.target.value };
|
||||||
|
handleChange("dataSource.staticOptions", newOptions);
|
||||||
|
}}
|
||||||
|
placeholder="포항"
|
||||||
|
className="h-7 text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Label className="text-[10px] text-muted-foreground">옵션 1 표시명</Label>
|
||||||
|
<Input
|
||||||
|
value={config?.dataSource?.staticOptions?.[0]?.label || ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
const options = config?.dataSource?.staticOptions || [];
|
||||||
|
const newOptions = [...options];
|
||||||
|
newOptions[0] = { ...newOptions[0], label: e.target.value };
|
||||||
|
handleChange("dataSource.staticOptions", newOptions);
|
||||||
|
}}
|
||||||
|
placeholder="포항"
|
||||||
|
className="h-7 text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Label className="text-[10px] text-muted-foreground">옵션 2 값</Label>
|
||||||
|
<Input
|
||||||
|
value={config?.dataSource?.staticOptions?.[1]?.value || ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
const options = config?.dataSource?.staticOptions || [];
|
||||||
|
const newOptions = [...options];
|
||||||
|
newOptions[1] = { ...newOptions[1], value: e.target.value };
|
||||||
|
handleChange("dataSource.staticOptions", newOptions);
|
||||||
|
}}
|
||||||
|
placeholder="광양"
|
||||||
|
className="h-7 text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Label className="text-[10px] text-muted-foreground">옵션 2 표시명</Label>
|
||||||
|
<Input
|
||||||
|
value={config?.dataSource?.staticOptions?.[1]?.label || ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
const options = config?.dataSource?.staticOptions || [];
|
||||||
|
const newOptions = [...options];
|
||||||
|
newOptions[1] = { ...newOptions[1], label: e.target.value };
|
||||||
|
handleChange("dataSource.staticOptions", newOptions);
|
||||||
|
}}
|
||||||
|
placeholder="광양"
|
||||||
|
className="h-7 text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* 테이블 설정 */}
|
||||||
|
{dataSourceType === "table" && (
|
||||||
|
<div className="space-y-2 pt-1">
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">테이블</span>
|
||||||
|
<Select
|
||||||
|
value={config?.dataSource?.tableName || ""}
|
||||||
|
onValueChange={(value) => handleChange("dataSource.tableName", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[160px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{tables.map((table) => (
|
||||||
|
<SelectItem key={table.name} value={table.name}>
|
||||||
|
{table.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">값 필드</span>
|
||||||
|
<Select
|
||||||
|
value={config?.dataSource?.valueField || ""}
|
||||||
|
onValueChange={(value) => handleChange("dataSource.valueField", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[160px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{columns.map((col) => (
|
||||||
|
<SelectItem key={col.name} value={col.name}>{col.label}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">표시 필드</span>
|
||||||
|
<Select
|
||||||
|
value={config?.dataSource?.labelField || ""}
|
||||||
|
onValueChange={(value) => handleChange("dataSource.labelField", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[160px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{columns.map((col) => (
|
||||||
|
<SelectItem key={col.name} value={col.name}>{col.label}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* 코드 카테고리 설정 */}
|
||||||
|
{dataSourceType === "code" && (
|
||||||
|
<div className="pt-1">
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">코드 카테고리</span>
|
||||||
|
<Select
|
||||||
|
value={config?.dataSource?.codeCategory || ""}
|
||||||
|
onValueChange={(value) => handleChange("dataSource.codeCategory", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[160px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{codeCategories.map((cat) => (
|
||||||
|
<SelectItem key={cat.value} value={cat.value}>{cat.label}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ─── 2단계: 필드 매핑 ─── */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<p className="text-sm font-medium">필드 매핑</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">
|
||||||
|
출발지/도착지 값이 저장될 컬럼을 지정해요
|
||||||
|
{screenTableName && (
|
||||||
|
<span className="ml-1">(화면 테이블: <strong>{screenTableName}</strong>)</span>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">출발지 저장 컬럼</span>
|
||||||
|
{tableColumns.length > 0 ? (
|
||||||
|
<Select
|
||||||
|
value={config?.departureField || ""}
|
||||||
|
onValueChange={(value) => handleChange("departureField", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[140px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{tableColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.columnLabel || col.columnName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
) : (
|
||||||
|
<Input
|
||||||
|
value={config?.departureField || "departure"}
|
||||||
|
onChange={(e) => handleChange("departureField", e.target.value)}
|
||||||
|
className="h-7 w-[140px] text-xs"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">도착지 저장 컬럼</span>
|
||||||
|
{tableColumns.length > 0 ? (
|
||||||
|
<Select
|
||||||
|
value={config?.destinationField || ""}
|
||||||
|
onValueChange={(value) => handleChange("destinationField", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[140px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{tableColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.columnLabel || col.columnName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
) : (
|
||||||
|
<Input
|
||||||
|
value={config?.destinationField || "destination"}
|
||||||
|
onChange={(e) => handleChange("destinationField", e.target.value)}
|
||||||
|
className="h-7 w-[140px] text-xs"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<span className="text-xs text-muted-foreground">출발지명 컬럼</span>
|
||||||
|
<p className="text-[10px] text-muted-foreground mt-0.5">라벨 저장용 (선택)</p>
|
||||||
|
</div>
|
||||||
|
{tableColumns.length > 0 ? (
|
||||||
|
<Select
|
||||||
|
value={config?.departureLabelField || "__none__"}
|
||||||
|
onValueChange={(value) => handleChange("departureLabelField", value === "__none__" ? "" : value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[140px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="__none__">없음</SelectItem>
|
||||||
|
{tableColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.columnLabel || col.columnName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
) : (
|
||||||
|
<Input
|
||||||
|
value={config?.departureLabelField || ""}
|
||||||
|
onChange={(e) => handleChange("departureLabelField", e.target.value)}
|
||||||
|
placeholder="departure_name"
|
||||||
|
className="h-7 w-[140px] text-xs"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<span className="text-xs text-muted-foreground">도착지명 컬럼</span>
|
||||||
|
<p className="text-[10px] text-muted-foreground mt-0.5">라벨 저장용 (선택)</p>
|
||||||
|
</div>
|
||||||
|
{tableColumns.length > 0 ? (
|
||||||
|
<Select
|
||||||
|
value={config?.destinationLabelField || "__none__"}
|
||||||
|
onValueChange={(value) => handleChange("destinationLabelField", value === "__none__" ? "" : value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[140px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="__none__">없음</SelectItem>
|
||||||
|
{tableColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.columnLabel || col.columnName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
) : (
|
||||||
|
<Input
|
||||||
|
value={config?.destinationLabelField || ""}
|
||||||
|
onChange={(e) => handleChange("destinationLabelField", e.target.value)}
|
||||||
|
placeholder="destination_name"
|
||||||
|
className="h-7 w-[140px] text-xs"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ─── 3단계: UI 설정 ─── */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<p className="text-sm font-medium">UI 설정</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">라벨과 스타일을 설정해요</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">출발지 라벨</span>
|
||||||
|
<Input
|
||||||
|
value={config?.departureLabel || "출발지"}
|
||||||
|
onChange={(e) => handleChange("departureLabel", e.target.value)}
|
||||||
|
className="h-7 w-[120px] text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">도착지 라벨</span>
|
||||||
|
<Input
|
||||||
|
value={config?.destinationLabel || "도착지"}
|
||||||
|
onChange={(e) => handleChange("destinationLabel", e.target.value)}
|
||||||
|
className="h-7 w-[120px] text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">스타일</span>
|
||||||
|
<Select
|
||||||
|
value={config?.variant || "card"}
|
||||||
|
onValueChange={(value) => handleChange("variant", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[120px] text-xs">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="card">카드</SelectItem>
|
||||||
|
<SelectItem value="inline">인라인</SelectItem>
|
||||||
|
<SelectItem value="minimal">미니멀</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">교환 버튼</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">출발지와 도착지를 바꿀 수 있어요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config?.showSwapButton !== false}
|
||||||
|
onCheckedChange={(checked) => handleChange("showSwapButton", checked)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ─── 4단계: DB 초기값 로드 (Collapsible) ─── */}
|
||||||
|
<Collapsible open={dbSettingsOpen} onOpenChange={setDbSettingsOpen}>
|
||||||
|
<CollapsibleTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="flex w-full items-center justify-between rounded-lg border bg-muted/30 px-4 py-2.5 text-left transition-colors hover:bg-muted/50"
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Settings className="h-4 w-4 text-muted-foreground" />
|
||||||
|
<span className="text-sm font-medium">DB 초기값 로드</span>
|
||||||
|
</div>
|
||||||
|
<ChevronDown
|
||||||
|
className={cn(
|
||||||
|
"h-4 w-4 text-muted-foreground transition-transform duration-200",
|
||||||
|
dbSettingsOpen && "rotate-180"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</CollapsibleTrigger>
|
||||||
|
<CollapsibleContent>
|
||||||
|
<div className="rounded-b-lg border border-t-0 p-4 space-y-3">
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">DB에서 초기값 로드</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">새로고침 후에도 DB에 저장된 값을 자동으로 불러와요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config?.loadFromDb !== false}
|
||||||
|
onCheckedChange={(checked) => handleChange("loadFromDb", checked)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{config?.loadFromDb !== false && (
|
||||||
|
<div className="ml-1 border-l-2 border-primary/20 pl-3 space-y-3">
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">조회 테이블</span>
|
||||||
|
<Select
|
||||||
|
value={config?.dbTableName || "vehicles"}
|
||||||
|
onValueChange={(value) => handleChange("dbTableName", value)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[140px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="vehicles">vehicles (기본)</SelectItem>
|
||||||
|
{tables.map((table) => (
|
||||||
|
<SelectItem key={table.name} value={table.name}>
|
||||||
|
{table.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<span className="text-xs text-muted-foreground">키 필드</span>
|
||||||
|
<p className="text-[10px] text-muted-foreground mt-0.5">현재 사용자 ID로 조회할 필드</p>
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
value={config?.dbKeyField || "user_id"}
|
||||||
|
onChange={(e) => handleChange("dbKeyField", e.target.value)}
|
||||||
|
placeholder="user_id"
|
||||||
|
className="h-7 w-[120px] text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</CollapsibleContent>
|
||||||
|
</Collapsible>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
V2LocationSwapSelectorConfigPanel.displayName = "V2LocationSwapSelectorConfigPanel";
|
||||||
|
|
||||||
|
export default V2LocationSwapSelectorConfigPanel;
|
||||||
|
|
@ -0,0 +1,572 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* V2 타임라인 스케줄러 설정 패널
|
||||||
|
* 토스식 단계별 UX: 스케줄 생성 설정 -> 리소스 설정 -> 표시 설정(접힘)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||||
|
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||||
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command";
|
||||||
|
import { Settings, ChevronDown, Check, ChevronsUpDown, Database, Users } from "lucide-react";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { tableTypeApi } from "@/lib/api/screen";
|
||||||
|
import type { TimelineSchedulerConfig, ScheduleType, SourceDataConfig, ResourceFieldMapping } from "@/lib/registry/components/v2-timeline-scheduler/types";
|
||||||
|
import { zoomLevelOptions, scheduleTypeOptions } from "@/lib/registry/components/v2-timeline-scheduler/config";
|
||||||
|
|
||||||
|
interface V2TimelineSchedulerConfigPanelProps {
|
||||||
|
config: TimelineSchedulerConfig;
|
||||||
|
onChange: (config: Partial<TimelineSchedulerConfig>) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TableInfo {
|
||||||
|
tableName: string;
|
||||||
|
displayName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ColumnInfo {
|
||||||
|
columnName: string;
|
||||||
|
displayName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const V2TimelineSchedulerConfigPanel: React.FC<V2TimelineSchedulerConfigPanelProps> = ({
|
||||||
|
config,
|
||||||
|
onChange,
|
||||||
|
}) => {
|
||||||
|
const [tables, setTables] = useState<TableInfo[]>([]);
|
||||||
|
const [sourceColumns, setSourceColumns] = useState<ColumnInfo[]>([]);
|
||||||
|
const [resourceColumns, setResourceColumns] = useState<ColumnInfo[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [sourceTableOpen, setSourceTableOpen] = useState(false);
|
||||||
|
const [resourceTableOpen, setResourceTableOpen] = useState(false);
|
||||||
|
const [displayOpen, setDisplayOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadTables = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const tableList = await tableTypeApi.getTables();
|
||||||
|
if (Array.isArray(tableList)) {
|
||||||
|
setTables(
|
||||||
|
tableList.map((t: any) => ({
|
||||||
|
tableName: t.table_name || t.tableName,
|
||||||
|
displayName: t.display_name || t.displayName || t.table_name || t.tableName,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("테이블 목록 로드 오류:", err);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadTables();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadSourceColumns = async () => {
|
||||||
|
if (!config.sourceConfig?.tableName) {
|
||||||
|
setSourceColumns([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const columns = await tableTypeApi.getColumns(config.sourceConfig.tableName);
|
||||||
|
if (Array.isArray(columns)) {
|
||||||
|
setSourceColumns(
|
||||||
|
columns.map((col: any) => ({
|
||||||
|
columnName: col.column_name || col.columnName,
|
||||||
|
displayName: col.display_name || col.displayName || col.column_name || col.columnName,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("소스 컬럼 로드 오류:", err);
|
||||||
|
setSourceColumns([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadSourceColumns();
|
||||||
|
}, [config.sourceConfig?.tableName]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadResourceColumns = async () => {
|
||||||
|
if (!config.resourceTable) {
|
||||||
|
setResourceColumns([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const columns = await tableTypeApi.getColumns(config.resourceTable);
|
||||||
|
if (Array.isArray(columns)) {
|
||||||
|
setResourceColumns(
|
||||||
|
columns.map((col: any) => ({
|
||||||
|
columnName: col.column_name || col.columnName,
|
||||||
|
displayName: col.display_name || col.displayName || col.column_name || col.columnName,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error("리소스 컬럼 로드 오류:", err);
|
||||||
|
setResourceColumns([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadResourceColumns();
|
||||||
|
}, [config.resourceTable]);
|
||||||
|
|
||||||
|
const updateConfig = (updates: Partial<TimelineSchedulerConfig>) => {
|
||||||
|
onChange({ ...config, ...updates });
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateSourceConfig = (updates: Partial<SourceDataConfig>) => {
|
||||||
|
updateConfig({
|
||||||
|
sourceConfig: {
|
||||||
|
...config.sourceConfig,
|
||||||
|
...updates,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateResourceFieldMapping = (field: string, value: string) => {
|
||||||
|
updateConfig({
|
||||||
|
resourceFieldMapping: {
|
||||||
|
...config.resourceFieldMapping,
|
||||||
|
id: config.resourceFieldMapping?.id || "id",
|
||||||
|
name: config.resourceFieldMapping?.name || "name",
|
||||||
|
[field]: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* ─── 1단계: 스케줄 생성 설정 ─── */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Database className="h-4 w-4 text-muted-foreground" />
|
||||||
|
<p className="text-sm font-medium">스케줄 생성 설정</p>
|
||||||
|
</div>
|
||||||
|
<p className="text-[11px] text-muted-foreground">스케줄 자동 생성 시 참조할 원본 데이터를 설정해요 (저장: schedule_mng)</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
|
{/* 스케줄 타입 */}
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">스케줄 타입</span>
|
||||||
|
<Select
|
||||||
|
value={config.scheduleType || "PRODUCTION"}
|
||||||
|
onValueChange={(v) => updateConfig({ scheduleType: v as ScheduleType })}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[140px] text-xs">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{scheduleTypeOptions.map((opt) => (
|
||||||
|
<SelectItem key={opt.value} value={opt.value}>
|
||||||
|
{opt.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 소스 테이블 Combobox */}
|
||||||
|
<div className="space-y-1">
|
||||||
|
<span className="text-xs text-muted-foreground">소스 테이블 (수주/작업요청 등)</span>
|
||||||
|
<Popover open={sourceTableOpen} onOpenChange={setSourceTableOpen}>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
role="combobox"
|
||||||
|
aria-expanded={sourceTableOpen}
|
||||||
|
className="h-8 w-full justify-between text-xs"
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{config.sourceConfig?.tableName
|
||||||
|
? tables.find((t) => t.tableName === config.sourceConfig?.tableName)?.displayName ||
|
||||||
|
config.sourceConfig.tableName
|
||||||
|
: "소스 테이블 선택..."}
|
||||||
|
<ChevronsUpDown className="ml-2 h-3 w-3 shrink-0 opacity-50" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="p-0" style={{ width: "var(--radix-popover-trigger-width)" }} align="start">
|
||||||
|
<Command
|
||||||
|
filter={(value, search) => {
|
||||||
|
return value.toLowerCase().includes(search.toLowerCase()) ? 1 : 0;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CommandInput placeholder="테이블 검색..." className="text-xs" />
|
||||||
|
<CommandList>
|
||||||
|
<CommandEmpty className="text-xs">테이블을 찾을 수 없습니다.</CommandEmpty>
|
||||||
|
<CommandGroup>
|
||||||
|
{tables.map((table) => (
|
||||||
|
<CommandItem
|
||||||
|
key={table.tableName}
|
||||||
|
value={`${table.displayName} ${table.tableName}`}
|
||||||
|
onSelect={() => {
|
||||||
|
updateSourceConfig({ tableName: table.tableName });
|
||||||
|
setSourceTableOpen(false);
|
||||||
|
}}
|
||||||
|
className="text-xs"
|
||||||
|
>
|
||||||
|
<Check
|
||||||
|
className={cn(
|
||||||
|
"mr-2 h-3 w-3",
|
||||||
|
config.sourceConfig?.tableName === table.tableName ? "opacity-100" : "opacity-0"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span>{table.displayName}</span>
|
||||||
|
<span className="text-muted-foreground text-[10px]">{table.tableName}</span>
|
||||||
|
</div>
|
||||||
|
</CommandItem>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 소스 필드 매핑 (테이블 선택 시) */}
|
||||||
|
{config.sourceConfig?.tableName && (
|
||||||
|
<div className="ml-1 border-l-2 border-primary/20 pl-3 space-y-2 pt-1">
|
||||||
|
<p className="text-xs font-medium text-primary">필드 매핑</p>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<span className="text-xs text-muted-foreground">기준일 (마감일/납기일) *</span>
|
||||||
|
<p className="text-[10px] text-muted-foreground mt-0.5">스케줄 종료일로 사용돼요</p>
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
value={config.sourceConfig?.dueDateField || ""}
|
||||||
|
onValueChange={(v) => updateSourceConfig({ dueDateField: v })}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[130px] text-xs">
|
||||||
|
<SelectValue placeholder="필수 선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{sourceColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.displayName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">수량 필드</span>
|
||||||
|
<Select
|
||||||
|
value={config.sourceConfig?.quantityField || ""}
|
||||||
|
onValueChange={(v) => updateSourceConfig({ quantityField: v })}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[130px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{sourceColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.displayName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">그룹 필드 (품목코드)</span>
|
||||||
|
<Select
|
||||||
|
value={config.sourceConfig?.groupByField || ""}
|
||||||
|
onValueChange={(v) => updateSourceConfig({ groupByField: v })}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[130px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{sourceColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.displayName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">그룹명 필드 (품목명)</span>
|
||||||
|
<Select
|
||||||
|
value={config.sourceConfig?.groupNameField || ""}
|
||||||
|
onValueChange={(v) => updateSourceConfig({ groupNameField: v })}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[130px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{sourceColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.displayName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ─── 2단계: 리소스 설정 ─── */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Users className="h-4 w-4 text-muted-foreground" />
|
||||||
|
<p className="text-sm font-medium">리소스 설정 (설비/작업자)</p>
|
||||||
|
</div>
|
||||||
|
<p className="text-[11px] text-muted-foreground">타임라인 Y축에 표시할 리소스를 설정해요</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="rounded-lg border bg-muted/30 p-4 space-y-3">
|
||||||
|
{/* 리소스 테이블 Combobox */}
|
||||||
|
<div className="space-y-1">
|
||||||
|
<span className="text-xs text-muted-foreground">리소스 테이블</span>
|
||||||
|
<Popover open={resourceTableOpen} onOpenChange={setResourceTableOpen}>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
role="combobox"
|
||||||
|
aria-expanded={resourceTableOpen}
|
||||||
|
className="h-8 w-full justify-between text-xs"
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{config.resourceTable
|
||||||
|
? tables.find((t) => t.tableName === config.resourceTable)?.displayName || config.resourceTable
|
||||||
|
: "리소스 테이블 선택..."}
|
||||||
|
<ChevronsUpDown className="ml-2 h-3 w-3 shrink-0 opacity-50" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="p-0" style={{ width: "var(--radix-popover-trigger-width)" }} align="start">
|
||||||
|
<Command
|
||||||
|
filter={(value, search) => {
|
||||||
|
return value.toLowerCase().includes(search.toLowerCase()) ? 1 : 0;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CommandInput placeholder="테이블 검색..." className="text-xs" />
|
||||||
|
<CommandList>
|
||||||
|
<CommandEmpty className="text-xs">테이블을 찾을 수 없습니다.</CommandEmpty>
|
||||||
|
<CommandGroup>
|
||||||
|
{tables.map((table) => (
|
||||||
|
<CommandItem
|
||||||
|
key={table.tableName}
|
||||||
|
value={`${table.displayName} ${table.tableName}`}
|
||||||
|
onSelect={() => {
|
||||||
|
updateConfig({ resourceTable: table.tableName });
|
||||||
|
setResourceTableOpen(false);
|
||||||
|
}}
|
||||||
|
className="text-xs"
|
||||||
|
>
|
||||||
|
<Check
|
||||||
|
className={cn(
|
||||||
|
"mr-2 h-3 w-3",
|
||||||
|
config.resourceTable === table.tableName ? "opacity-100" : "opacity-0"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<span>{table.displayName}</span>
|
||||||
|
<span className="text-muted-foreground text-[10px]">{table.tableName}</span>
|
||||||
|
</div>
|
||||||
|
</CommandItem>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 리소스 필드 매핑 */}
|
||||||
|
{config.resourceTable && (
|
||||||
|
<div className="ml-1 border-l-2 border-primary/20 pl-3 space-y-2 pt-1">
|
||||||
|
<p className="text-xs font-medium text-primary">리소스 필드</p>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">ID 필드</span>
|
||||||
|
<Select
|
||||||
|
value={config.resourceFieldMapping?.id || ""}
|
||||||
|
onValueChange={(v) => updateResourceFieldMapping("id", v)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[130px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{resourceColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.displayName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">이름 필드</span>
|
||||||
|
<Select
|
||||||
|
value={config.resourceFieldMapping?.name || ""}
|
||||||
|
onValueChange={(v) => updateResourceFieldMapping("name", v)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[130px] text-xs">
|
||||||
|
<SelectValue placeholder="선택" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{resourceColumns.map((col) => (
|
||||||
|
<SelectItem key={col.columnName} value={col.columnName}>
|
||||||
|
{col.displayName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ─── 3단계: 표시 설정 (Collapsible) ─── */}
|
||||||
|
<Collapsible open={displayOpen} onOpenChange={setDisplayOpen}>
|
||||||
|
<CollapsibleTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="flex w-full items-center justify-between rounded-lg border bg-muted/30 px-4 py-2.5 text-left transition-colors hover:bg-muted/50"
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Settings className="h-4 w-4 text-muted-foreground" />
|
||||||
|
<span className="text-sm font-medium">표시 설정</span>
|
||||||
|
</div>
|
||||||
|
<ChevronDown
|
||||||
|
className={cn(
|
||||||
|
"h-4 w-4 text-muted-foreground transition-transform duration-200",
|
||||||
|
displayOpen && "rotate-180"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</CollapsibleTrigger>
|
||||||
|
<CollapsibleContent>
|
||||||
|
<div className="rounded-b-lg border border-t-0 p-4 space-y-3">
|
||||||
|
{/* 줌 레벨 */}
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">기본 줌 레벨</span>
|
||||||
|
<Select
|
||||||
|
value={config.defaultZoomLevel || "day"}
|
||||||
|
onValueChange={(v) => updateConfig({ defaultZoomLevel: v as any })}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="h-7 w-[100px] text-xs">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{zoomLevelOptions.map((opt) => (
|
||||||
|
<SelectItem key={opt.value} value={opt.value}>
|
||||||
|
{opt.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 높이 */}
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">높이 (px)</span>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
value={config.height || 500}
|
||||||
|
onChange={(e) => updateConfig({ height: parseInt(e.target.value) || 500 })}
|
||||||
|
className="h-7 w-[100px] text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 행 높이 */}
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<span className="text-xs text-muted-foreground">행 높이 (px)</span>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
value={config.rowHeight || 50}
|
||||||
|
onChange={(e) => updateConfig({ rowHeight: parseInt(e.target.value) || 50 })}
|
||||||
|
className="h-7 w-[100px] text-xs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Switch 토글들 */}
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">편집 가능</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">스케줄을 직접 수정할 수 있어요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.editable ?? true}
|
||||||
|
onCheckedChange={(v) => updateConfig({ editable: v })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">드래그 이동</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">스케줄을 드래그해서 날짜를 변경해요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.draggable ?? true}
|
||||||
|
onCheckedChange={(v) => updateConfig({ draggable: v })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">리사이즈</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">스케줄의 기간을 늘이거나 줄여요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.resizable ?? true}
|
||||||
|
onCheckedChange={(v) => updateConfig({ resizable: v })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">오늘 표시선</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">오늘 날짜에 빨간 세로선을 표시해요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.showTodayLine ?? true}
|
||||||
|
onCheckedChange={(v) => updateConfig({ showTodayLine: v })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">진행률 표시</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">각 스케줄의 진행률 바를 보여줘요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.showProgress ?? true}
|
||||||
|
onCheckedChange={(v) => updateConfig({ showProgress: v })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between py-1">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm">툴바 표시</p>
|
||||||
|
<p className="text-[11px] text-muted-foreground">상단의 네비게이션/줌 컨트롤을 보여줘요</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={config.showToolbar ?? true}
|
||||||
|
onCheckedChange={(v) => updateConfig({ showToolbar: v })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CollapsibleContent>
|
||||||
|
</Collapsible>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
V2TimelineSchedulerConfigPanel.displayName = "V2TimelineSchedulerConfigPanel";
|
||||||
|
|
||||||
|
export default V2TimelineSchedulerConfigPanel;
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import { createComponentDefinition } from "../../utils/createComponentDefinition";
|
import { createComponentDefinition } from "../../utils/createComponentDefinition";
|
||||||
import { ComponentCategory } from "@/types/component";
|
import { ComponentCategory } from "@/types/component";
|
||||||
import { LocationSwapSelectorComponent } from "./LocationSwapSelectorComponent";
|
import { LocationSwapSelectorComponent } from "./LocationSwapSelectorComponent";
|
||||||
import { LocationSwapSelectorConfigPanel } from "./LocationSwapSelectorConfigPanel";
|
import { V2LocationSwapSelectorConfigPanel as LocationSwapSelectorConfigPanel } from "@/components/v2/config-panels/V2LocationSwapSelectorConfigPanel";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LocationSwapSelector 컴포넌트 정의
|
* LocationSwapSelector 컴포넌트 정의
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import { ComponentCategory } from "@/types/component";
|
import { ComponentCategory } from "@/types/component";
|
||||||
import { createComponentDefinition } from "../../utils/createComponentDefinition";
|
import { createComponentDefinition } from "../../utils/createComponentDefinition";
|
||||||
import { TimelineSchedulerComponent } from "./TimelineSchedulerComponent";
|
import { TimelineSchedulerComponent } from "./TimelineSchedulerComponent";
|
||||||
import { TimelineSchedulerConfigPanel } from "./TimelineSchedulerConfigPanel";
|
import { V2TimelineSchedulerConfigPanel as TimelineSchedulerConfigPanel } from "@/components/v2/config-panels/V2TimelineSchedulerConfigPanel";
|
||||||
import { defaultTimelineSchedulerConfig } from "./config";
|
import { defaultTimelineSchedulerConfig } from "./config";
|
||||||
import { TimelineSchedulerConfig } from "./types";
|
import { TimelineSchedulerConfig } from "./types";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue