jskim-node #420
|
|
@ -1707,71 +1707,66 @@ export class DynamicFormService {
|
||||||
try {
|
try {
|
||||||
console.log(`🎯 제어관리 설정 확인 중... (screenId: ${screenId})`);
|
console.log(`🎯 제어관리 설정 확인 중... (screenId: ${screenId})`);
|
||||||
|
|
||||||
// 화면의 저장 버튼에서 제어관리 설정 조회
|
// V2 레이아웃에서 layout_data jsonb 조회
|
||||||
const screenLayouts = await query<{
|
const v2Layouts = await query<{
|
||||||
component_id: string;
|
layout_id: number;
|
||||||
properties: any;
|
layout_data: any;
|
||||||
}>(
|
}>(
|
||||||
`SELECT component_id, properties
|
`SELECT layout_id, layout_data
|
||||||
FROM screen_layouts
|
FROM screen_layouts_v2
|
||||||
WHERE screen_id = $1
|
WHERE screen_id = $1 AND company_code = $2`,
|
||||||
AND component_type IN ('component', 'v2-button-primary')`,
|
[screenId, companyCode]
|
||||||
[screenId]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(`📋 화면 컴포넌트 조회 결과:`, screenLayouts.length);
|
if (v2Layouts.length === 0) {
|
||||||
|
console.log(`ℹ️ V2 레이아웃이 없습니다. (화면 ID: ${screenId}, company: ${companyCode})`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// layout_data.components 배열에서 버튼 컴포넌트 추출
|
||||||
|
const layoutData = v2Layouts[0].layout_data;
|
||||||
|
const components: any[] = layoutData?.components || [];
|
||||||
|
|
||||||
|
console.log(`📋 V2 컴포넌트 조회 결과: ${components.length}개`);
|
||||||
|
|
||||||
// 저장 버튼 중에서 제어관리가 활성화된 것 찾기
|
|
||||||
let controlConfigFound = false;
|
let controlConfigFound = false;
|
||||||
for (const layout of screenLayouts) {
|
for (const comp of components) {
|
||||||
const properties = layout.properties as any;
|
const overrides = comp?.overrides || {};
|
||||||
|
|
||||||
// 디버깅: 모든 컴포넌트 정보 출력
|
const isButtonComponent =
|
||||||
console.log(`🔍 컴포넌트 검사:`, {
|
overrides?.type === "v2-button-primary" ||
|
||||||
componentId: layout.component_id,
|
(comp?.url || "").includes("v2-button-primary");
|
||||||
componentType: properties?.componentType,
|
|
||||||
actionType: properties?.componentConfig?.action?.type,
|
|
||||||
enableDataflowControl:
|
|
||||||
properties?.webTypeConfig?.enableDataflowControl,
|
|
||||||
hasDataflowConfig: !!properties?.webTypeConfig?.dataflowConfig,
|
|
||||||
hasDiagramId:
|
|
||||||
!!properties?.webTypeConfig?.dataflowConfig?.selectedDiagramId,
|
|
||||||
hasFlowControls:
|
|
||||||
!!properties?.webTypeConfig?.dataflowConfig?.flowControls,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 버튼 컴포넌트이고 제어관리가 활성화된 경우
|
|
||||||
// triggerType에 맞는 액션 타입 매칭: insert/update -> save, delete -> delete
|
// triggerType에 맞는 액션 타입 매칭: insert/update -> save, delete -> delete
|
||||||
const buttonActionType = properties?.componentConfig?.action?.type;
|
const buttonActionType = overrides?.action?.type;
|
||||||
const isMatchingAction =
|
const isMatchingAction =
|
||||||
(triggerType === "delete" && buttonActionType === "delete") ||
|
(triggerType === "delete" && buttonActionType === "delete") ||
|
||||||
((triggerType === "insert" || triggerType === "update") && buttonActionType === "save");
|
((triggerType === "insert" || triggerType === "update") && buttonActionType === "save");
|
||||||
|
|
||||||
const isButtonComponent =
|
console.log(`🔍 V2 컴포넌트 검사:`, {
|
||||||
properties?.componentType === "button-primary" ||
|
componentId: comp?.id,
|
||||||
properties?.componentType === "v2-button-primary";
|
type: overrides?.type,
|
||||||
|
actionType: buttonActionType,
|
||||||
|
enableDataflowControl: overrides?.enableDataflowControl,
|
||||||
|
hasDataflowConfig: !!overrides?.dataflowConfig,
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isButtonComponent &&
|
isButtonComponent &&
|
||||||
isMatchingAction &&
|
isMatchingAction &&
|
||||||
properties?.webTypeConfig?.enableDataflowControl === true
|
overrides?.enableDataflowControl === true
|
||||||
) {
|
) {
|
||||||
const dataflowConfig = properties?.webTypeConfig?.dataflowConfig;
|
const dataflowConfig = overrides?.dataflowConfig;
|
||||||
|
|
||||||
// 다중 제어 설정 확인 (flowControls 배열)
|
|
||||||
const flowControls = dataflowConfig?.flowControls || [];
|
const flowControls = dataflowConfig?.flowControls || [];
|
||||||
|
|
||||||
// flowControls가 있으면 다중 제어 실행, 없으면 기존 단일 제어 실행
|
|
||||||
if (flowControls.length > 0) {
|
if (flowControls.length > 0) {
|
||||||
controlConfigFound = true;
|
controlConfigFound = true;
|
||||||
console.log(`🎯 다중 제어관리 설정 발견: ${flowControls.length}개`);
|
console.log(`🎯 다중 제어관리 설정 발견: ${flowControls.length}개`);
|
||||||
|
|
||||||
// 순서대로 정렬
|
|
||||||
const sortedControls = [...flowControls].sort(
|
const sortedControls = [...flowControls].sort(
|
||||||
(a: any, b: any) => (a.order || 0) - (b.order || 0)
|
(a: any, b: any) => (a.order || 0) - (b.order || 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// 다중 제어 순차 실행
|
|
||||||
await this.executeMultipleFlowControls(
|
await this.executeMultipleFlowControls(
|
||||||
sortedControls,
|
sortedControls,
|
||||||
savedData,
|
savedData,
|
||||||
|
|
@ -1782,13 +1777,12 @@ export class DynamicFormService {
|
||||||
companyCode
|
companyCode
|
||||||
);
|
);
|
||||||
} else if (dataflowConfig?.selectedDiagramId) {
|
} else if (dataflowConfig?.selectedDiagramId) {
|
||||||
// 기존 단일 제어 실행 (하위 호환성)
|
|
||||||
controlConfigFound = true;
|
controlConfigFound = true;
|
||||||
const diagramId = dataflowConfig.selectedDiagramId;
|
const diagramId = dataflowConfig.selectedDiagramId;
|
||||||
const relationshipId = dataflowConfig.selectedRelationshipId;
|
const relationshipId = dataflowConfig.selectedRelationshipId;
|
||||||
|
|
||||||
console.log(`🎯 단일 제어관리 설정 발견:`, {
|
console.log(`🎯 단일 제어관리 설정 발견:`, {
|
||||||
componentId: layout.component_id,
|
componentId: comp?.id,
|
||||||
diagramId,
|
diagramId,
|
||||||
relationshipId,
|
relationshipId,
|
||||||
triggerType,
|
triggerType,
|
||||||
|
|
@ -1806,7 +1800,6 @@ export class DynamicFormService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 첫 번째 설정된 버튼의 제어관리만 실행
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue