fix: SelectedItemsDetailInput 수정 모드에서 다중 레코드 로드 오류 수정
DynamicComponentRenderer에 selected-items-detail-input groupedData 전달 추가 SelectedItemsDetailInput에서 groupedData 우선 사용하도록 변경 ScreenModal editData 배열 처리 시 formData/selectedData 분리 저장 TextInput 수정 모드에서 채번 규칙 스킵 로직 추가
This commit is contained in:
@@ -42,6 +42,8 @@ export const SelectedItemsDetailInputComponent: React.FC<SelectedItemsDetailInpu
|
||||
screenId,
|
||||
...props
|
||||
}) => {
|
||||
// 🆕 groupedData 추출 (DynamicComponentRenderer에서 전달)
|
||||
const groupedData = (props as any).groupedData || (props as any)._groupedData;
|
||||
// 🆕 URL 파라미터에서 dataSourceId 읽기
|
||||
const searchParams = useSearchParams();
|
||||
const urlDataSourceId = searchParams?.get("dataSourceId") || undefined;
|
||||
@@ -225,24 +227,32 @@ export const SelectedItemsDetailInputComponent: React.FC<SelectedItemsDetailInpu
|
||||
|
||||
// 🆕 모달 데이터를 ItemData 구조로 변환 (그룹별 구조)
|
||||
useEffect(() => {
|
||||
// 🆕 수정 모드: formData에서 데이터 로드 (URL에 mode=edit이 있으면)
|
||||
// 🆕 수정 모드: groupedData 또는 formData에서 데이터 로드 (URL에 mode=edit이 있으면)
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const mode = urlParams.get("mode");
|
||||
|
||||
if (mode === "edit" && formData) {
|
||||
// 🔧 데이터 소스 우선순위: groupedData > formData (배열) > formData (객체)
|
||||
const sourceData = groupedData && Array.isArray(groupedData) && groupedData.length > 0
|
||||
? groupedData
|
||||
: formData;
|
||||
|
||||
if (mode === "edit" && sourceData) {
|
||||
// 배열인지 단일 객체인지 확인
|
||||
const isArray = Array.isArray(formData);
|
||||
const dataArray = isArray ? formData : [formData];
|
||||
const isArray = Array.isArray(sourceData);
|
||||
const dataArray = isArray ? sourceData : [sourceData];
|
||||
|
||||
if (dataArray.length === 0 || (dataArray.length === 1 && Object.keys(dataArray[0]).length === 0)) {
|
||||
console.warn("⚠️ [SelectedItemsDetailInput] formData가 비어있음");
|
||||
console.warn("⚠️ [SelectedItemsDetailInput] 데이터가 비어있음");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`📝 [SelectedItemsDetailInput] 수정 모드 - ${isArray ? "그룹 레코드" : "단일 레코드"} (${dataArray.length}개)`,
|
||||
);
|
||||
console.log("📝 [SelectedItemsDetailInput] formData (JSON):", JSON.stringify(dataArray, null, 2));
|
||||
console.log("📝 [SelectedItemsDetailInput] 데이터 소스:", {
|
||||
fromGroupedData: groupedData && Array.isArray(groupedData) && groupedData.length > 0,
|
||||
dataArray: JSON.stringify(dataArray, null, 2),
|
||||
});
|
||||
|
||||
const groups = componentConfig.fieldGroups || [];
|
||||
const additionalFields = componentConfig.additionalFields || [];
|
||||
@@ -423,7 +433,7 @@ export const SelectedItemsDetailInputComponent: React.FC<SelectedItemsDetailInpu
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [modalData, component.id, componentConfig.fieldGroups, formData]); // formData 의존성 추가
|
||||
}, [modalData, component.id, componentConfig.fieldGroups, formData, groupedData]); // groupedData 의존성 추가
|
||||
|
||||
// 🆕 Cartesian Product 생성 함수 (items에서 모든 그룹의 조합을 생성)
|
||||
const generateCartesianProduct = useCallback(
|
||||
|
||||
Reference in New Issue
Block a user