diff --git a/backend-node/src/services/dynamicFormService.ts b/backend-node/src/services/dynamicFormService.ts index 604405c3..bc65822c 100644 --- a/backend-node/src/services/dynamicFormService.ts +++ b/backend-node/src/services/dynamicFormService.ts @@ -1707,71 +1707,66 @@ export class DynamicFormService { try { console.log(`๐ŸŽฏ ์ œ์–ด๊ด€๋ฆฌ ์„ค์ • ํ™•์ธ ์ค‘... (screenId: ${screenId})`); - // ํ™”๋ฉด์˜ ์ €์žฅ ๋ฒ„ํŠผ์—์„œ ์ œ์–ด๊ด€๋ฆฌ ์„ค์ • ์กฐํšŒ - const screenLayouts = await query<{ - component_id: string; - properties: any; + // V2 ๋ ˆ์ด์•„์›ƒ์—์„œ layout_data jsonb ์กฐํšŒ + const v2Layouts = await query<{ + layout_id: number; + layout_data: any; }>( - `SELECT component_id, properties - FROM screen_layouts - WHERE screen_id = $1 - AND component_type IN ('component', 'v2-button-primary')`, - [screenId] + `SELECT layout_id, layout_data + FROM screen_layouts_v2 + WHERE screen_id = $1 AND company_code = $2`, + [screenId, companyCode] ); - 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; - for (const layout of screenLayouts) { - const properties = layout.properties as any; + for (const comp of components) { + const overrides = comp?.overrides || {}; - // ๋””๋ฒ„๊น…: ๋ชจ๋“  ์ปดํฌ๋„ŒํŠธ ์ •๋ณด ์ถœ๋ ฅ - console.log(`๐Ÿ” ์ปดํฌ๋„ŒํŠธ ๊ฒ€์‚ฌ:`, { - componentId: layout.component_id, - 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, - }); + const isButtonComponent = + overrides?.type === "v2-button-primary" || + (comp?.url || "").includes("v2-button-primary"); - // ๋ฒ„ํŠผ ์ปดํฌ๋„ŒํŠธ์ด๊ณ  ์ œ์–ด๊ด€๋ฆฌ๊ฐ€ ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ // triggerType์— ๋งž๋Š” ์•ก์…˜ ํƒ€์ž… ๋งค์นญ: insert/update -> save, delete -> delete - const buttonActionType = properties?.componentConfig?.action?.type; + const buttonActionType = overrides?.action?.type; const isMatchingAction = (triggerType === "delete" && buttonActionType === "delete") || ((triggerType === "insert" || triggerType === "update") && buttonActionType === "save"); - - const isButtonComponent = - properties?.componentType === "button-primary" || - properties?.componentType === "v2-button-primary"; - + + console.log(`๐Ÿ” V2 ์ปดํฌ๋„ŒํŠธ ๊ฒ€์‚ฌ:`, { + componentId: comp?.id, + type: overrides?.type, + actionType: buttonActionType, + enableDataflowControl: overrides?.enableDataflowControl, + hasDataflowConfig: !!overrides?.dataflowConfig, + }); + if ( isButtonComponent && isMatchingAction && - properties?.webTypeConfig?.enableDataflowControl === true + overrides?.enableDataflowControl === true ) { - const dataflowConfig = properties?.webTypeConfig?.dataflowConfig; - - // ๋‹ค์ค‘ ์ œ์–ด ์„ค์ • ํ™•์ธ (flowControls ๋ฐฐ์—ด) + const dataflowConfig = overrides?.dataflowConfig; const flowControls = dataflowConfig?.flowControls || []; - // flowControls๊ฐ€ ์žˆ์œผ๋ฉด ๋‹ค์ค‘ ์ œ์–ด ์‹คํ–‰, ์—†์œผ๋ฉด ๊ธฐ์กด ๋‹จ์ผ ์ œ์–ด ์‹คํ–‰ if (flowControls.length > 0) { controlConfigFound = true; console.log(`๐ŸŽฏ ๋‹ค์ค‘ ์ œ์–ด๊ด€๋ฆฌ ์„ค์ • ๋ฐœ๊ฒฌ: ${flowControls.length}๊ฐœ`); - // ์ˆœ์„œ๋Œ€๋กœ ์ •๋ ฌ const sortedControls = [...flowControls].sort( (a: any, b: any) => (a.order || 0) - (b.order || 0) ); - // ๋‹ค์ค‘ ์ œ์–ด ์ˆœ์ฐจ ์‹คํ–‰ await this.executeMultipleFlowControls( sortedControls, savedData, @@ -1782,13 +1777,12 @@ export class DynamicFormService { companyCode ); } else if (dataflowConfig?.selectedDiagramId) { - // ๊ธฐ์กด ๋‹จ์ผ ์ œ์–ด ์‹คํ–‰ (ํ•˜์œ„ ํ˜ธํ™˜์„ฑ) controlConfigFound = true; const diagramId = dataflowConfig.selectedDiagramId; const relationshipId = dataflowConfig.selectedRelationshipId; console.log(`๐ŸŽฏ ๋‹จ์ผ ์ œ์–ด๊ด€๋ฆฌ ์„ค์ • ๋ฐœ๊ฒฌ:`, { - componentId: layout.component_id, + componentId: comp?.id, diagramId, relationshipId, triggerType, @@ -1806,7 +1800,6 @@ export class DynamicFormService { ); } - // ์ฒซ ๋ฒˆ์งธ ์„ค์ •๋œ ๋ฒ„ํŠผ์˜ ์ œ์–ด๊ด€๋ฆฌ๋งŒ ์‹คํ–‰ break; } }