Compare commits

..

No commits in common. "025c28bdbe8d24a2e9d34f4d803053dfe7036a15" and "ba5ee357cad7d0600f0a4a2bf3e652f277c169f5" have entirely different histories.

1 changed files with 85 additions and 107 deletions

View File

@ -1632,120 +1632,98 @@ export const SplitPanelLayoutComponent: React.FC<SplitPanelLayoutComponentProps>
const handleEditClick = useCallback( const handleEditClick = useCallback(
(panel: "left" | "right", item: any) => { (panel: "left" | "right", item: any) => {
// 🆕 우측 패널 수정 버튼 설정 확인 // 🆕 우측 패널 수정 버튼 설정 확인
// 🔧 현재 활성 탭에 따라 해당 탭의 editButton 설정 사용 if (panel === "right" && componentConfig.rightPanel?.editButton?.mode === "modal") {
if (panel === "right") { const modalScreenId = componentConfig.rightPanel?.editButton?.modalScreenId;
// 기본 탭(0)이면 rightPanel.editButton, 추가 탭이면 additionalTabs의 editButton 사용
const editButtonConfig =
activeTabIndex === 0
? componentConfig.rightPanel?.editButton
: componentConfig.rightPanel?.additionalTabs?.[activeTabIndex - 1]?.editButton;
// 해당 탭의 테이블명 가져오기 if (modalScreenId) {
const currentTableName = // 커스텀 모달 화면 열기
activeTabIndex === 0 const rightTableName = componentConfig.rightPanel?.tableName || "";
? componentConfig.rightPanel?.tableName || ""
: componentConfig.rightPanel?.additionalTabs?.[activeTabIndex - 1]?.tableName || "";
console.log("🔧 [SplitPanel] 수정 버튼 클릭 - 현재 탭 설정 확인:", { // Primary Key 찾기 (우선순위: 설정값 > id > ID > non-null 필드)
activeTabIndex, // 🔧 설정에서 primaryKeyColumn 지정 가능
editButtonConfig, const configuredPrimaryKey = componentConfig.rightPanel?.editButton?.primaryKeyColumn;
currentTableName,
isModalMode: editButtonConfig?.mode === "modal",
});
if (editButtonConfig?.mode === "modal") { let primaryKeyName = "id";
const modalScreenId = editButtonConfig.modalScreenId; let primaryKeyValue: any;
if (modalScreenId) { if (configuredPrimaryKey && item[configuredPrimaryKey] !== undefined && item[configuredPrimaryKey] !== null) {
// 커스텀 모달 화면 열기 // 설정된 Primary Key 사용
primaryKeyName = configuredPrimaryKey;
// Primary Key 찾기 (우선순위: 설정값 > id > ID > non-null 필드) primaryKeyValue = item[configuredPrimaryKey];
// 🔧 설정에서 primaryKeyColumn 지정 가능 } else if (item.id !== undefined && item.id !== null) {
const configuredPrimaryKey = editButtonConfig.primaryKeyColumn; primaryKeyName = "id";
primaryKeyValue = item.id;
let primaryKeyName = "id"; } else if (item.ID !== undefined && item.ID !== null) {
let primaryKeyValue: any; primaryKeyName = "ID";
primaryKeyValue = item.ID;
if (configuredPrimaryKey && item[configuredPrimaryKey] !== undefined && item[configuredPrimaryKey] !== null) { } else {
// 설정된 Primary Key 사용 // 🔧 첫 번째 non-null 필드를 Primary Key로 간주
primaryKeyName = configuredPrimaryKey; const keys = Object.keys(item);
primaryKeyValue = item[configuredPrimaryKey]; let found = false;
} else if (item.id !== undefined && item.id !== null) { for (const key of keys) {
primaryKeyName = "id"; if (item[key] !== undefined && item[key] !== null) {
primaryKeyValue = item.id; primaryKeyName = key;
} else if (item.ID !== undefined && item.ID !== null) { primaryKeyValue = item[key];
primaryKeyName = "ID"; found = true;
primaryKeyValue = item.ID; break;
} else {
// 🔧 첫 번째 non-null 필드를 Primary Key로 간주
const keys = Object.keys(item);
let found = false;
for (const key of keys) {
if (item[key] !== undefined && item[key] !== null) {
primaryKeyName = key;
primaryKeyValue = item[key];
found = true;
break;
}
}
// 모든 필드가 null이면 첫 번째 필드 사용
if (!found && keys.length > 0) {
primaryKeyName = keys[0];
primaryKeyValue = item[keys[0]];
} }
} }
// 모든 필드가 null이면 첫 번째 필드 사용
console.log("✅ 수정 모달 열기:", { if (!found && keys.length > 0) {
activeTabIndex, primaryKeyName = keys[0];
tableName: currentTableName, primaryKeyValue = item[keys[0]];
primaryKeyName, }
primaryKeyValue,
screenId: modalScreenId,
fullItem: item,
});
// modalDataStore에도 저장 (호환성 유지)
import("@/stores/modalDataStore").then(({ useModalDataStore }) => {
useModalDataStore.getState().setData(currentTableName, [item]);
});
// 🆕 groupByColumns 추출
const groupByColumns = editButtonConfig.groupByColumns || [];
console.log("🔧 [SplitPanel] 수정 버튼 클릭 - groupByColumns 확인:", {
groupByColumns,
editButtonConfig,
hasGroupByColumns: groupByColumns.length > 0,
});
// ScreenModal 열기 이벤트 발생 (URL 파라미터로 ID + groupByColumns + primaryKeyColumn 전달)
window.dispatchEvent(
new CustomEvent("openScreenModal", {
detail: {
screenId: modalScreenId,
urlParams: {
mode: "edit",
editId: primaryKeyValue,
tableName: currentTableName,
primaryKeyColumn: primaryKeyName, // 🆕 Primary Key 컬럼명 전달
...(groupByColumns.length > 0 && {
groupByColumns: JSON.stringify(groupByColumns),
}),
},
},
}),
);
console.log("✅ [SplitPanel] openScreenModal 이벤트 발생:", {
screenId: modalScreenId,
editId: primaryKeyValue,
tableName: currentTableName,
primaryKeyColumn: primaryKeyName,
groupByColumns: groupByColumns.length > 0 ? JSON.stringify(groupByColumns) : "없음",
});
return;
} }
console.log("✅ 수정 모달 열기:", {
tableName: rightTableName,
primaryKeyName,
primaryKeyValue,
screenId: modalScreenId,
fullItem: item,
});
// modalDataStore에도 저장 (호환성 유지)
import("@/stores/modalDataStore").then(({ useModalDataStore }) => {
useModalDataStore.getState().setData(rightTableName, [item]);
});
// 🆕 groupByColumns 추출
const groupByColumns = componentConfig.rightPanel?.editButton?.groupByColumns || [];
console.log("🔧 [SplitPanel] 수정 버튼 클릭 - groupByColumns 확인:", {
groupByColumns,
editButtonConfig: componentConfig.rightPanel?.editButton,
hasGroupByColumns: groupByColumns.length > 0,
});
// ScreenModal 열기 이벤트 발생 (URL 파라미터로 ID + groupByColumns + primaryKeyColumn 전달)
window.dispatchEvent(
new CustomEvent("openScreenModal", {
detail: {
screenId: modalScreenId,
urlParams: {
mode: "edit",
editId: primaryKeyValue,
tableName: rightTableName,
primaryKeyColumn: primaryKeyName, // 🆕 Primary Key 컬럼명 전달
...(groupByColumns.length > 0 && {
groupByColumns: JSON.stringify(groupByColumns),
}),
},
},
}),
);
console.log("✅ [SplitPanel] openScreenModal 이벤트 발생:", {
screenId: modalScreenId,
editId: primaryKeyValue,
tableName: rightTableName,
primaryKeyColumn: primaryKeyName,
groupByColumns: groupByColumns.length > 0 ? JSON.stringify(groupByColumns) : "없음",
});
return;
} }
} }