버튼에 제어 달기
This commit is contained in:
@@ -575,40 +575,86 @@ const DataConnectionDesigner: React.FC<DataConnectionDesignerProps> = ({
|
||||
setState((prev) => ({ ...prev, isLoading: true }));
|
||||
|
||||
try {
|
||||
// 실제 저장 로직 구현
|
||||
const saveData = {
|
||||
// 실제 저장 로직 구현 - connectionType에 따라 필요한 설정만 포함
|
||||
let saveData: any = {
|
||||
relationshipName: state.relationshipName,
|
||||
description: state.description,
|
||||
connectionType: state.connectionType,
|
||||
// 외부호출인 경우 테이블 정보는 선택사항
|
||||
fromConnection: state.connectionType === "external_call" ? null : state.fromConnection,
|
||||
toConnection: state.connectionType === "external_call" ? null : state.toConnection,
|
||||
fromTable: state.connectionType === "external_call" ? null : state.fromTable,
|
||||
toTable: state.connectionType === "external_call" ? null : state.toTable,
|
||||
// 🔧 멀티 액션 그룹 데이터 포함
|
||||
actionGroups: state.connectionType === "external_call" ? [] : state.actionGroups,
|
||||
groupsLogicalOperator: state.groupsLogicalOperator,
|
||||
// 외부호출 설정 포함
|
||||
externalCallConfig: state.externalCallConfig,
|
||||
// 기존 호환성을 위한 필드들 (첫 번째 액션 그룹의 첫 번째 액션에서 추출)
|
||||
actionType:
|
||||
state.connectionType === "external_call"
|
||||
? "external_call"
|
||||
: state.actionGroups[0]?.actions[0]?.actionType || state.actionType || "insert",
|
||||
controlConditions: state.connectionType === "external_call" ? [] : state.controlConditions,
|
||||
actionConditions:
|
||||
state.connectionType === "external_call"
|
||||
? []
|
||||
: state.actionGroups[0]?.actions[0]?.conditions || state.actionConditions || [],
|
||||
fieldMappings:
|
||||
state.connectionType === "external_call"
|
||||
? []
|
||||
: state.actionGroups[0]?.actions[0]?.fieldMappings || state.fieldMappings || [],
|
||||
};
|
||||
|
||||
if (state.connectionType === "external_call") {
|
||||
// 외부호출 타입인 경우: 외부호출 설정만 포함
|
||||
console.log("💾 외부호출 타입 저장 - 외부호출 설정만 포함");
|
||||
saveData = {
|
||||
...saveData,
|
||||
// 외부호출 관련 설정만 포함
|
||||
externalCallConfig: state.externalCallConfig,
|
||||
actionType: "external_call",
|
||||
// 데이터 저장 관련 설정은 제외 (null/빈 배열로 설정)
|
||||
fromConnection: null,
|
||||
toConnection: null,
|
||||
fromTable: null,
|
||||
toTable: null,
|
||||
actionGroups: [],
|
||||
controlConditions: [],
|
||||
actionConditions: [],
|
||||
fieldMappings: [],
|
||||
};
|
||||
} else if (state.connectionType === "data_save") {
|
||||
// 데이터 저장 타입인 경우: 데이터 저장 설정만 포함
|
||||
console.log("💾 데이터 저장 타입 저장 - 데이터 저장 설정만 포함");
|
||||
saveData = {
|
||||
...saveData,
|
||||
// 데이터 저장 관련 설정만 포함
|
||||
fromConnection: state.fromConnection,
|
||||
toConnection: state.toConnection,
|
||||
fromTable: state.fromTable,
|
||||
toTable: state.toTable,
|
||||
actionGroups: state.actionGroups,
|
||||
groupsLogicalOperator: state.groupsLogicalOperator,
|
||||
controlConditions: state.controlConditions,
|
||||
// 기존 호환성을 위한 필드들 (첫 번째 액션 그룹의 첫 번째 액션에서 추출)
|
||||
actionType: state.actionGroups[0]?.actions[0]?.actionType || state.actionType || "insert",
|
||||
actionConditions: state.actionGroups[0]?.actions[0]?.conditions || state.actionConditions || [],
|
||||
fieldMappings: state.actionGroups[0]?.actions[0]?.fieldMappings || state.fieldMappings || [],
|
||||
// 외부호출 관련 설정은 제외 (null로 설정)
|
||||
externalCallConfig: null,
|
||||
};
|
||||
}
|
||||
|
||||
console.log("💾 직접 저장 시작:", { saveData, diagramId, isEdit: !!diagramId });
|
||||
|
||||
// 외부호출인 경우 external-call-configs에 설정 저장
|
||||
// 데이터 저장 타입인 경우 기존 외부호출 설정 정리
|
||||
if (state.connectionType === "data_save" && diagramId) {
|
||||
console.log("🧹 데이터 저장 타입으로 변경 - 기존 외부호출 설정 정리");
|
||||
try {
|
||||
const { ExternalCallConfigAPI } = await import("@/lib/api/externalCallConfig");
|
||||
|
||||
// 기존 외부호출 설정이 있는지 확인하고 삭제 또는 비활성화
|
||||
const existingConfigs = await ExternalCallConfigAPI.getConfigs({
|
||||
company_code: "*",
|
||||
is_active: "Y",
|
||||
});
|
||||
|
||||
const existingConfig = existingConfigs.data?.find(
|
||||
(config: any) => config.config_name === (state.relationshipName || "외부호출 설정")
|
||||
);
|
||||
|
||||
if (existingConfig) {
|
||||
console.log("🗑️ 기존 외부호출 설정 비활성화:", existingConfig.id);
|
||||
// 설정을 비활성화 (삭제하지 않고 is_active를 'N'으로 변경)
|
||||
await ExternalCallConfigAPI.updateConfig(existingConfig.id, {
|
||||
...existingConfig,
|
||||
is_active: "N",
|
||||
updated_at: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
} catch (cleanupError) {
|
||||
console.warn("⚠️ 외부호출 설정 정리 실패 (무시하고 계속):", cleanupError);
|
||||
}
|
||||
}
|
||||
|
||||
// 외부호출인 경우에만 external-call-configs에 설정 저장
|
||||
if (state.connectionType === "external_call" && state.externalCallConfig) {
|
||||
try {
|
||||
const { ExternalCallConfigAPI } = await import("@/lib/api/externalCallConfig");
|
||||
|
||||
Reference in New Issue
Block a user