데이터 저장 설정 개선: INSERT가 아닌 액션에 대한 실행조건 필수 검증 추가 및 DELETE 액션에 대한 필드 매핑 및 데이터 분할 설정 생략 로직 구현. 조건 미비 시 사용자 안내 메시지 추가.

This commit is contained in:
hyeonsu 2025-09-18 13:26:42 +09:00
parent 8bfb269446
commit cbd54316cf
4 changed files with 203 additions and 27 deletions

View File

@ -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와 메시지가 있어야 함

View File

@ -32,6 +32,22 @@ export const ActionConditionsSection: React.FC<ActionConditionsSectionProps> = (
}) => {
const { addActionGroupStart, addActionGroupEnd, getActionCurrentGroupLevel } = useActionConditionHelpers();
// INSERT가 아닌 액션 타입인지 확인
const isConditionRequired = action.actionType !== "insert";
// 유효한 조건이 있는지 확인 (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;
}) || false;
const addActionCondition = () => {
const newActions = [...settings.actions];
if (!newActions[actionIndex].conditions) {
@ -65,14 +81,28 @@ export const ActionConditionsSection: React.FC<ActionConditionsSectionProps> = (
return (
<div className="mt-3">
<details className="group">
<summary className="flex cursor-pointer items-center justify-between rounded border p-2 text-xs font-medium text-gray-700 hover:bg-gray-50 hover:text-gray-900">
<summary
className={`flex cursor-pointer items-center justify-between rounded border p-2 text-xs font-medium hover:bg-gray-50 hover:text-gray-900 ${
isConditionRequired && !hasValidConditions
? "border-red-300 bg-red-50 text-red-700"
: "border-gray-200 text-gray-700"
}`}
>
<div className="flex items-center gap-2">
🔍 ()
🔍
{isConditionRequired ? (
<span className="rounded bg-red-100 px-1 py-0.5 text-xs font-semibold text-red-700"></span>
) : (
<span className="text-gray-500">()</span>
)}
{action.conditions && action.conditions.length > 0 && (
<span className="rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-700">
{action.conditions.length}
</span>
)}
{isConditionRequired && !hasValidConditions && (
<span className="rounded bg-red-100 px-1 py-0.5 text-xs text-red-600"> </span>
)}
</div>
{action.conditions && action.conditions.length > 0 && (
<Button
@ -115,6 +145,36 @@ export const ActionConditionsSection: React.FC<ActionConditionsSectionProps> = (
</Button>
</div>
</div>
{/* 조건이 없을 때 안내 메시지 */}
{(!action.conditions || action.conditions.length === 0) && (
<div
className={`rounded border p-3 text-xs ${
isConditionRequired
? "border-red-200 bg-red-50 text-red-700"
: "border-gray-200 bg-gray-50 text-gray-600"
}`}
>
{isConditionRequired ? (
<div className="flex items-start gap-2">
<span className="text-red-500"></span>
<div>
<div className="font-medium"> </div>
<div className="mt-1">
{action.actionType.toUpperCase()} .
<br />
<strong>, , </strong> .
<br />
: user_name = '관리자우저' AND status = 'active'
</div>
</div>
</div>
) : (
<div> . INSERT .</div>
)}
</div>
)}
{action.conditions && action.conditions.length > 0 && (
<div className="space-y-2">
{action.conditions.map((condition, condIndex) => (

View File

@ -54,7 +54,10 @@ export const ActionFieldMappings: React.FC<ActionFieldMappingsProps> = ({
return (
<div className="mt-3">
<div className="mb-2 flex items-center justify-between">
<Label className="text-xs font-medium"> </Label>
<div className="flex items-center gap-2">
<Label className="text-xs font-medium"> </Label>
<span className="text-xs text-red-600">()</span>
</div>
<Button size="sm" variant="outline" onClick={addFieldMapping} className="h-6 text-xs">
<Plus className="mr-1 h-2 w-2" />
@ -208,6 +211,22 @@ export const ActionFieldMappings: React.FC<ActionFieldMappingsProps> = ({
</div>
</div>
))}
{/* 필드 매핑이 없을 때 안내 메시지 */}
{action.fieldMappings.length === 0 && (
<div className="rounded border border-red-200 bg-red-50 p-3 text-xs text-red-700">
<div className="flex items-start gap-2">
<span className="text-red-500"></span>
<div>
<div className="font-medium"> </div>
<div className="mt-1">
{action.actionType.toUpperCase()}
.
</div>
</div>
</div>
</div>
)}
</div>
</div>
);

View File

@ -135,25 +135,52 @@ export const DataSaveSettings: React.FC<DataSaveSettingsProps> = ({
toTableName={toTableName}
/>
{/* 데이터 분할 설정 */}
<ActionSplitConfig
action={action}
actionIndex={actionIndex}
settings={settings}
onSettingsChange={onSettingsChange}
fromTableColumns={fromTableColumns}
toTableColumns={toTableColumns}
/>
{/* 데이터 분할 설정 - DELETE 액션은 제외 */}
{action.actionType !== "delete" && (
<ActionSplitConfig
action={action}
actionIndex={actionIndex}
settings={settings}
onSettingsChange={onSettingsChange}
fromTableColumns={fromTableColumns}
toTableColumns={toTableColumns}
/>
)}
{/* 필드 매핑 */}
<ActionFieldMappings
action={action}
actionIndex={actionIndex}
settings={settings}
onSettingsChange={onSettingsChange}
availableTables={availableTables}
tableColumnsCache={tableColumnsCache}
/>
{/* 필드 매핑 - DELETE 액션은 제외 */}
{action.actionType !== "delete" && (
<ActionFieldMappings
action={action}
actionIndex={actionIndex}
settings={settings}
onSettingsChange={onSettingsChange}
availableTables={availableTables}
tableColumnsCache={tableColumnsCache}
/>
)}
{/* DELETE 액션일 때 안내 메시지 */}
{action.actionType === "delete" && (
<div className="mt-3">
<div className="rounded border border-blue-200 bg-blue-50 p-3 text-xs text-blue-700">
<div className="flex items-start gap-2">
<span></span>
<div>
<div className="font-medium">DELETE </div>
<div className="mt-1">
DELETE <strong></strong> .
<br />
설정: 불필요 ( )
<br />
매핑: 불필요 ( )
<br />
.
</div>
</div>
</div>
</div>
</div>
)}
</div>
))}
</div>