쿼리를 새로 실행하면 기존 컬럼 설정이 초기화
This commit is contained in:
parent
e1c40b23fb
commit
dcb32f26b0
|
|
@ -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,
|
||||||
};
|
}));
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// 컬럼 설정 변경
|
// 컬럼 설정 변경
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue