diff --git a/frontend/components/screen/panels/V2PropertiesPanel.tsx b/frontend/components/screen/panels/V2PropertiesPanel.tsx index a843d710..8b42d753 100644 --- a/frontend/components/screen/panels/V2PropertiesPanel.tsx +++ b/frontend/components/screen/panels/V2PropertiesPanel.tsx @@ -263,6 +263,7 @@ export const V2PropertiesPanel: React.FC = ({ definitionName: definition.name, hasConfigPanel: !!definition.configPanel, currentConfig, + defaultSort: currentConfig?.defaultSort, // 🔍 defaultSort 확인 }); // 🔧 ConfigPanelWrapper를 인라인 함수 대신 직접 JSX 반환 (리마운트 방지) @@ -1059,8 +1060,15 @@ export const V2PropertiesPanel: React.FC = ({ 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); }); }} diff --git a/frontend/lib/registry/components/v2-table-list/TableListComponent.tsx b/frontend/lib/registry/components/v2-table-list/TableListComponent.tsx index 02ef8643..543724b5 100644 --- a/frontend/lib/registry/components/v2-table-list/TableListComponent.tsx +++ b/frontend/lib/registry/components/v2-table-list/TableListComponent.tsx @@ -1010,7 +1010,7 @@ export const TableListComponent: React.FC = ({ // unregisterTable 함수는 의존성이 없어 안정적임 ]); - // 🎯 초기 로드 시 localStorage에서 정렬 상태 불러오기 + // 🎯 초기 로드 시 localStorage에서 정렬 상태 불러오기 (없으면 defaultSort 적용) useEffect(() => { if (!tableConfig.selectedTable || !userId || hasInitializedSort.current) return; @@ -1024,12 +1024,21 @@ export const TableListComponent: React.FC = ({ 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 = ({ 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; // 🆕 연결 필터 값 가져오기 (분할 패널 내부일 때) diff --git a/frontend/lib/registry/components/v2-table-list/TableListConfigPanel.tsx b/frontend/lib/registry/components/v2-table-list/TableListConfigPanel.tsx index ff76960e..977830ca 100644 --- a/frontend/lib/registry/components/v2-table-list/TableListConfigPanel.tsx +++ b/frontend/lib/registry/components/v2-table-list/TableListConfigPanel.tsx @@ -319,7 +319,9 @@ export const TableListConfigPanel: React.FC = ({ 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 = ({ + {/* 기본 정렬 설정 */} +
+
+

기본 정렬 설정

+

테이블 로드 시 기본 정렬 순서를 지정합니다

+
+
+
+
+ + +
+ + {config.defaultSort?.columnName && ( +
+ + +
+ )} +
+
+ {/* 가로 스크롤 및 컬럼 고정 */}
diff --git a/frontend/lib/registry/components/v2-table-list/types.ts b/frontend/lib/registry/components/v2-table-list/types.ts index a43ccdfa..1cc04375 100644 --- a/frontend/lib/registry/components/v2-table-list/types.ts +++ b/frontend/lib/registry/components/v2-table-list/types.ts @@ -278,6 +278,12 @@ export interface TableListConfig extends ComponentConfig { autoLoad: boolean; refreshInterval?: number; // 초 단위 + // 🆕 기본 정렬 설정 + defaultSort?: { + columnName: string; // 정렬할 컬럼명 + direction: "asc" | "desc"; // 정렬 방향 + }; + // 🆕 툴바 버튼 표시 설정 toolbar?: ToolbarConfig;