feat: 기본 정렬 설정 기능 추가 및 로깅 개선
- V2PropertiesPanel에서 defaultSort를 currentConfig에 추가하여 기본 정렬 정보를 관리하도록 개선하였습니다. - TableListComponent에서 localStorage에서 기본 정렬 설정을 적용하는 로직을 추가하여 사용자 경험을 향상시켰습니다. - TableListConfigPanel에 기본 정렬 설정 UI를 추가하여 사용자가 테이블 로드 시 기본 정렬 순서를 지정할 수 있도록 하였습니다. - 각 컴포넌트에서 상태 변경 시 로깅을 추가하여 디버깅을 용이하게 하였습니다.
This commit is contained in:
parent
7ec5a438d4
commit
2fb6dd0c32
|
|
@ -263,6 +263,7 @@ export const V2PropertiesPanel: React.FC<V2PropertiesPanelProps> = ({
|
|||
definitionName: definition.name,
|
||||
hasConfigPanel: !!definition.configPanel,
|
||||
currentConfig,
|
||||
defaultSort: currentConfig?.defaultSort, // 🔍 defaultSort 확인
|
||||
});
|
||||
|
||||
// 🔧 ConfigPanelWrapper를 인라인 함수 대신 직접 JSX 반환 (리마운트 방지)
|
||||
|
|
@ -1059,8 +1060,15 @@ export const V2PropertiesPanel: React.FC<V2PropertiesPanelProps> = ({
|
|||
allComponents={allComponents} // 🆕 연쇄 드롭다운 부모 감지용
|
||||
currentComponent={selectedComponent} // 🆕 현재 컴포넌트 정보
|
||||
onChange={(newConfig) => {
|
||||
console.log("🔧 [V2PropertiesPanel] DynamicConfigPanel onChange:", {
|
||||
componentId: selectedComponent.id,
|
||||
newConfigKeys: Object.keys(newConfig),
|
||||
defaultSort: newConfig.defaultSort,
|
||||
newConfig,
|
||||
});
|
||||
// 개별 속성별로 업데이트하여 다른 속성과의 충돌 방지
|
||||
Object.entries(newConfig).forEach(([key, value]) => {
|
||||
console.log(` -> handleUpdate: componentConfig.${key} =`, value);
|
||||
handleUpdate(`componentConfig.${key}`, value);
|
||||
});
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1010,7 +1010,7 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
// unregisterTable 함수는 의존성이 없어 안정적임
|
||||
]);
|
||||
|
||||
// 🎯 초기 로드 시 localStorage에서 정렬 상태 불러오기
|
||||
// 🎯 초기 로드 시 localStorage에서 정렬 상태 불러오기 (없으면 defaultSort 적용)
|
||||
useEffect(() => {
|
||||
if (!tableConfig.selectedTable || !userId || hasInitializedSort.current) return;
|
||||
|
||||
|
|
@ -1024,12 +1024,21 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
setSortColumn(column);
|
||||
setSortDirection(direction);
|
||||
hasInitializedSort.current = true;
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
// 정렬 상태 복원 실패
|
||||
}
|
||||
}
|
||||
}, [tableConfig.selectedTable, userId]);
|
||||
|
||||
// localStorage에 저장된 정렬이 없으면 defaultSort 설정 적용
|
||||
if (tableConfig.defaultSort?.columnName) {
|
||||
console.log("📊 기본 정렬 설정 적용:", tableConfig.defaultSort);
|
||||
setSortColumn(tableConfig.defaultSort.columnName);
|
||||
setSortDirection(tableConfig.defaultSort.direction || "asc");
|
||||
hasInitializedSort.current = true;
|
||||
}
|
||||
}, [tableConfig.selectedTable, tableConfig.defaultSort, userId]);
|
||||
|
||||
// 🆕 초기 로드 시 localStorage에서 컬럼 순서 불러오기
|
||||
useEffect(() => {
|
||||
|
|
@ -1470,8 +1479,9 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
try {
|
||||
const page = tableConfig.pagination?.currentPage || currentPage;
|
||||
const pageSize = localPageSize;
|
||||
const sortBy = sortColumn || undefined;
|
||||
const sortOrder = sortDirection;
|
||||
// 🆕 sortColumn이 없으면 defaultSort 설정을 fallback으로 사용
|
||||
const sortBy = sortColumn || tableConfig.defaultSort?.columnName || undefined;
|
||||
const sortOrder = sortColumn ? sortDirection : (tableConfig.defaultSort?.direction || sortDirection);
|
||||
const search = searchTerm || undefined;
|
||||
|
||||
// 🆕 연결 필터 값 가져오기 (분할 패널 내부일 때)
|
||||
|
|
|
|||
|
|
@ -319,7 +319,9 @@ export const TableListConfigPanel: React.FC<TableListConfigPanelProps> = ({
|
|||
|
||||
const handleChange = (key: keyof TableListConfig, value: any) => {
|
||||
// 기존 config와 병합하여 전달 (다른 속성 손실 방지)
|
||||
onChange({ ...config, [key]: value });
|
||||
const newConfig = { ...config, [key]: value };
|
||||
console.log("📊 TableListConfigPanel handleChange:", { key, value, newConfig });
|
||||
onChange(newConfig);
|
||||
};
|
||||
|
||||
const handleNestedChange = (parentKey: keyof TableListConfig, childKey: string, value: any) => {
|
||||
|
|
@ -884,6 +886,67 @@ export const TableListConfigPanel: React.FC<TableListConfigPanelProps> = ({
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{/* 기본 정렬 설정 */}
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<h3 className="text-sm font-semibold">기본 정렬 설정</h3>
|
||||
<p className="text-muted-foreground text-[10px]">테이블 로드 시 기본 정렬 순서를 지정합니다</p>
|
||||
</div>
|
||||
<hr className="border-border" />
|
||||
<div className="space-y-2">
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="defaultSortColumn" className="text-xs">
|
||||
정렬 컬럼
|
||||
</Label>
|
||||
<select
|
||||
id="defaultSortColumn"
|
||||
value={config.defaultSort?.columnName || ""}
|
||||
onChange={(e) => {
|
||||
if (e.target.value) {
|
||||
handleChange("defaultSort", {
|
||||
columnName: e.target.value,
|
||||
direction: config.defaultSort?.direction || "asc",
|
||||
});
|
||||
} else {
|
||||
handleChange("defaultSort", undefined);
|
||||
}
|
||||
}}
|
||||
className="h-8 w-full rounded-md border px-2 text-xs"
|
||||
>
|
||||
<option value="">정렬 없음</option>
|
||||
{availableColumns.map((col) => (
|
||||
<option key={col.columnName} value={col.columnName}>
|
||||
{col.label || col.columnName}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{config.defaultSort?.columnName && (
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="defaultSortDirection" className="text-xs">
|
||||
정렬 방향
|
||||
</Label>
|
||||
<select
|
||||
id="defaultSortDirection"
|
||||
value={config.defaultSort?.direction || "asc"}
|
||||
onChange={(e) =>
|
||||
handleChange("defaultSort", {
|
||||
...config.defaultSort,
|
||||
columnName: config.defaultSort?.columnName || "",
|
||||
direction: e.target.value as "asc" | "desc",
|
||||
})
|
||||
}
|
||||
className="h-8 w-full rounded-md border px-2 text-xs"
|
||||
>
|
||||
<option value="asc">오름차순 (A→Z, 1→9)</option>
|
||||
<option value="desc">내림차순 (Z→A, 9→1)</option>
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 가로 스크롤 및 컬럼 고정 */}
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -278,6 +278,12 @@ export interface TableListConfig extends ComponentConfig {
|
|||
autoLoad: boolean;
|
||||
refreshInterval?: number; // 초 단위
|
||||
|
||||
// 🆕 기본 정렬 설정
|
||||
defaultSort?: {
|
||||
columnName: string; // 정렬할 컬럼명
|
||||
direction: "asc" | "desc"; // 정렬 방향
|
||||
};
|
||||
|
||||
// 🆕 툴바 버튼 표시 설정
|
||||
toolbar?: ToolbarConfig;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue