데이터 저장 설정 개선: INSERT가 아닌 액션에 대한 실행조건 필수 검증 추가 및 DELETE 액션에 대한 필드 매핑 및 데이터 분할 설정 생략 로직 구현. 조건 미비 시 사용자 안내 메시지 추가.
This commit is contained in:
@@ -343,6 +343,37 @@ export const ConnectionSetupModal: React.FC<ConnectionSetupModalProps> = ({
|
||||
break;
|
||||
case "data-save":
|
||||
settings = dataSaveSettings;
|
||||
|
||||
// INSERT가 아닌 액션 타입에 대한 실행조건 필수 검증
|
||||
for (const action of dataSaveSettings.actions) {
|
||||
if (action.actionType !== "insert") {
|
||||
if (!action.conditions || action.conditions.length === 0) {
|
||||
toast.error(
|
||||
`${action.actionType.toUpperCase()} 액션은 실행조건이 필수입니다. '${action.name}' 액션에 실행조건을 추가해주세요.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 실제 조건이 있는지 확인 (group-start, group-end만 있는 경우 제외)
|
||||
const hasValidConditions = action.conditions.some((condition) => {
|
||||
if (condition.type !== "condition") return false;
|
||||
if (!condition.field || !condition.operator) return false;
|
||||
|
||||
// value가 null, undefined, 빈 문자열이면 유효하지 않음
|
||||
const value = condition.value;
|
||||
if (value === null || value === undefined || value === "") return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!hasValidConditions) {
|
||||
toast.error(
|
||||
`${action.actionType.toUpperCase()} 액션은 완전한 실행조건이 필요합니다. '${action.name}' 액션에 필드, 연산자, 값을 모두 설정해주세요.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "external-call":
|
||||
// 외부 호출은 plan에 저장
|
||||
@@ -508,9 +539,21 @@ export const ConnectionSetupModal: React.FC<ConnectionSetupModalProps> = ({
|
||||
case "data-save":
|
||||
// 데이터 저장: 액션과 필드 매핑이 완성되어야 함
|
||||
const hasActions = dataSaveSettings.actions.length > 0;
|
||||
const allActionsHaveMappings = dataSaveSettings.actions.every((action) => action.fieldMappings.length > 0);
|
||||
const allMappingsComplete = dataSaveSettings.actions.every((action) =>
|
||||
action.fieldMappings.every((mapping) => {
|
||||
|
||||
// DELETE 액션은 필드 매핑이 필요 없음
|
||||
const allActionsHaveMappings = dataSaveSettings.actions.every((action) => {
|
||||
if (action.actionType === "delete") {
|
||||
return true; // DELETE는 필드 매핑 불필요
|
||||
}
|
||||
return action.fieldMappings.length > 0;
|
||||
});
|
||||
|
||||
const allMappingsComplete = dataSaveSettings.actions.every((action) => {
|
||||
if (action.actionType === "delete") {
|
||||
return true; // DELETE는 필드 매핑 검증 생략
|
||||
}
|
||||
|
||||
return action.fieldMappings.every((mapping) => {
|
||||
// 타겟은 항상 필요
|
||||
if (!mapping.targetTable || !mapping.targetField) return false;
|
||||
|
||||
@@ -525,9 +568,36 @@ export const ConnectionSetupModal: React.FC<ConnectionSetupModalProps> = ({
|
||||
|
||||
// FROM 테이블이 있으면 소스 매핑 완성 또는 기본값 필요
|
||||
return hasSource || hasDefault;
|
||||
}),
|
||||
);
|
||||
return !hasActions || !allActionsHaveMappings || !allMappingsComplete;
|
||||
});
|
||||
});
|
||||
|
||||
// INSERT가 아닌 액션 타입에 대한 실행조건 필수 검증
|
||||
const allRequiredConditionsMet = dataSaveSettings.actions.every((action) => {
|
||||
if (action.actionType === "insert") {
|
||||
return true; // INSERT는 조건 불필요
|
||||
}
|
||||
|
||||
// INSERT가 아닌 액션은 유효한 조건이 있어야 함
|
||||
if (!action.conditions || action.conditions.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 실제 조건이 있는지 확인 (group-start, group-end만 있는 경우 제외)
|
||||
const hasValidConditions = action.conditions.some((condition) => {
|
||||
if (condition.type !== "condition") return false;
|
||||
if (!condition.field || !condition.operator) return false;
|
||||
|
||||
// value가 null, undefined, 빈 문자열이면 유효하지 않음
|
||||
const value = condition.value;
|
||||
if (value === null || value === undefined || value === "") return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return hasValidConditions;
|
||||
});
|
||||
|
||||
return !hasActions || !allActionsHaveMappings || !allMappingsComplete || !allRequiredConditionsMet;
|
||||
|
||||
case "external-call":
|
||||
// 외부 호출: 설정 ID와 메시지가 있어야 함
|
||||
|
||||
Reference in New Issue
Block a user