feat: Implement entity join functionality in V2Repeater and configuration panel
- Added support for entity joins in the V2Repeater component, allowing for automatic resolution of foreign key references to display data from related tables. - Introduced a new `resolveEntityJoins` function to handle the fetching and mapping of reference data based on configured entity joins. - Enhanced the V2RepeaterConfigPanel to manage entity join configurations, including loading available columns and toggling join settings. - Updated the data handling logic to incorporate mapping rules for incoming data, ensuring that only necessary fields are retained during processing. - Improved user experience by providing clear logging and feedback during entity join resolution and data mapping operations.
This commit is contained in:
@@ -305,12 +305,26 @@ export function ItemSelectionModal({
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
// 이미 추가된 항목인지 확인
|
||||
// 이미 추가된 항목인지 확인 (매핑된 데이터의 _sourceData도 검사)
|
||||
const isAlreadyAdded = (item: any): boolean => {
|
||||
if (!uniqueField) return false;
|
||||
return alreadySelected.some(
|
||||
(selected) => selected[uniqueField] === item[uniqueField]
|
||||
);
|
||||
const checkField = uniqueField || "id";
|
||||
const itemValue = item[checkField];
|
||||
if (itemValue === undefined || itemValue === null) return false;
|
||||
const strItemValue = String(itemValue);
|
||||
|
||||
return alreadySelected.some((selected) => {
|
||||
// _sourceData 우선 확인 (DB 로드 항목의 참조 ID가 매핑되어 있음)
|
||||
const sourceValue = selected._sourceData?.[checkField];
|
||||
if (sourceValue !== undefined && sourceValue !== null && String(sourceValue) === strItemValue) {
|
||||
return true;
|
||||
}
|
||||
// _sourceData에 없으면 직접 필드 비교 (동일 필드명인 경우)
|
||||
const directValue = selected[checkField];
|
||||
if (directValue !== undefined && directValue !== null && String(directValue) === strItemValue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// 이미 추가된 항목 제외한 결과 필터링
|
||||
|
||||
Reference in New Issue
Block a user