쿼리를 새로 실행하면 기존 컬럼 설정이 초기화

This commit is contained in:
dohyeons 2025-10-28 15:42:53 +09:00
parent e1c40b23fb
commit dcb32f26b0
1 changed files with 12 additions and 17 deletions

View File

@ -94,24 +94,19 @@ export function ListWidgetConfigSidebar({ element, isOpen, onClose, onApply }: L
const handleQueryTest = useCallback((result: QueryResult) => { const handleQueryTest = useCallback((result: QueryResult) => {
setQueryResult(result); setQueryResult(result);
// 쿼리 결과의 컬럼을 자동으로 listConfig.columns에 추가 (기존 컬럼은 유지) // 쿼리 실행 시마다 컬럼 설정 초기화 (새로운 쿼리 결과로 덮어쓰기)
setListConfig((prev) => { const newColumns = result.columns.map((col, idx) => ({
const existingFields = prev.columns.map((col) => col.field); id: `col_${Date.now()}_${idx}`,
const newColumns = result.columns field: col,
.filter((col) => !existingFields.includes(col)) label: col,
.map((col, idx) => ({ visible: true,
id: `col_${Date.now()}_${idx}`, align: "left" as const,
field: col, }));
label: col,
visible: true,
align: "left" as const,
}));
return { setListConfig((prev) => ({
...prev, ...prev,
columns: [...prev.columns, ...newColumns], columns: newColumns,
}; }));
});
}, []); }, []);
// 컬럼 설정 변경 // 컬럼 설정 변경