diff --git a/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx b/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx index 1ae66e0b..112a285c 100644 --- a/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx +++ b/frontend/lib/registry/components/button-primary/ButtonPrimaryComponent.tsx @@ -393,6 +393,16 @@ export const ButtonPrimaryComponent: React.FC = ({ return; } + // ๐Ÿ†• ๋ชจ๋“  ์ปดํฌ๋„ŒํŠธ์˜ ์„ค์ • ์ˆ˜์ง‘ (parentDataMapping ๋“ฑ) + const componentConfigs: Record = {}; + if (allComponents && Array.isArray(allComponents)) { + for (const comp of allComponents) { + if (comp.id && comp.componentConfig) { + componentConfigs[comp.id] = comp.componentConfig; + } + } + } + const context: ButtonActionContext = { formData: formData || {}, originalData: originalData || {}, // ๋ถ€๋ถ„ ์—…๋ฐ์ดํŠธ์šฉ ์›๋ณธ ๋ฐ์ดํ„ฐ ์ถ”๊ฐ€ @@ -418,7 +428,9 @@ export const ButtonPrimaryComponent: React.FC = ({ // ํ”Œ๋กœ์šฐ ์„ ํƒ๋œ ๋ฐ์ดํ„ฐ ์ •๋ณด ์ถ”๊ฐ€ flowSelectedData, flowSelectedStepId, - }; + // ๐Ÿ†• ์ปดํฌ๋„ŒํŠธ๋ณ„ ์„ค์ • (parentDataMapping ๋“ฑ) + componentConfigs, + } as ButtonActionContext; // ํ™•์ธ์ด ํ•„์š”ํ•œ ์•ก์…˜์ธ์ง€ ํ™•์ธ if (confirmationRequiredActions.includes(processedConfig.action.type)) { diff --git a/frontend/lib/utils/buttonActions.ts b/frontend/lib/utils/buttonActions.ts index ca390a8f..58a3b288 100644 --- a/frontend/lib/utils/buttonActions.ts +++ b/frontend/lib/utils/buttonActions.ts @@ -135,6 +135,9 @@ export interface ButtonActionContext { currentPage?: number; // ํ˜„์žฌ ํŽ˜์ด์ง€ pageSize?: number; // ํŽ˜์ด์ง€ ํฌ๊ธฐ totalItems?: number; // ์ „์ฒด ํ•ญ๋ชฉ ์ˆ˜ + + // ๐Ÿ†• ์ปดํฌ๋„ŒํŠธ๋ณ„ ์„ค์ • (parentDataMapping ๋“ฑ) + componentConfigs?: Record; // ์ปดํฌ๋„ŒํŠธ ID โ†’ ์ปดํฌ๋„ŒํŠธ ์„ค์ • } /** @@ -538,9 +541,19 @@ export class ButtonActionExecutor { // selectedRowsData ๋˜๋Š” originalData๋ฅผ parentData๋กœ ์‚ฌ์šฉ const parentData = selectedRowsData?.[0] || originalData || {}; + // ๐Ÿ†• modalDataStore์—์„œ ๋ˆ„์ ๋œ ๋ชจ๋“  ํ…Œ์ด๋ธ” ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ + // (์—ฌ๋Ÿฌ ๋‹จ๊ณ„ ๋ชจ๋‹ฌ์—์„œ ์ „๋‹ฌ๋œ ๋ฐ์ดํ„ฐ ์ ‘๊ทผ์šฉ) + const modalDataStore = typeof window !== 'undefined' + ? (window as any).__modalDataRegistry || {} + : {}; + console.log(`๐Ÿ” [handleBatchSave] ๋ถ€๋ชจ ๋ฐ์ดํ„ฐ:`, { hasParentData: Object.keys(parentData).length > 0, parentDataKeys: Object.keys(parentData), + parentDataFull: parentData, + selectedRowsData, + originalData, + modalDataStoreKeys: Object.keys(modalDataStore), }); // ๊ฐ SelectedItemsDetailInput ์ปดํฌ๋„ŒํŠธ์˜ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ @@ -555,14 +568,15 @@ export class ButtonActionExecutor { console.log(`๐Ÿ“ฆ [handleBatchSave] ${key} ์ฒ˜๋ฆฌ ์ค‘ (${items.length}๊ฐœ ํ’ˆ๋ชฉ)`); // ๐Ÿ†• ์ด ์ปดํฌ๋„ŒํŠธ์˜ parentDataMapping ์„ค์ • ๊ฐ€์ ธ์˜ค๊ธฐ - // TODO: ์‹ค์ œ๋กœ๋Š” componentConfig์—์„œ ๊ฐ€์ ธ์™€์•ผ ํ•จ - // ํ˜„์žฌ๋Š” selectedItemsKeys[0]์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž„์‹œ๋กœ ๊ฐ€์ ธ์˜ด - const componentConfig = (context as any).componentConfigs?.[key]; + const componentConfig = context.componentConfigs?.[key]; const parentDataMapping = componentConfig?.parentDataMapping || []; console.log(`๐Ÿ” [handleBatchSave] parentDataMapping ์„ค์ •:`, { + componentId: key, + hasComponentConfig: !!componentConfig, hasMapping: parentDataMapping.length > 0, - mappings: parentDataMapping + mappings: parentDataMapping, + sourceTable: componentConfig?.sourceTable, }); // ๐Ÿ†• ๊ฐ ํ’ˆ๋ชฉ์˜ ๊ทธ๋ฃน ๊ฐ„ ์กฐํ•ฉ(์นดํ‹ฐ์…˜ ๊ณฑ) ์ƒ์„ฑ @@ -615,8 +629,8 @@ export class ButtonActionExecutor { let sourceData: any; // ๐Ÿ” sourceTable๊ณผ ์‹ค์ œ ๋ฐ์ดํ„ฐ ํ…Œ์ด๋ธ” ๋น„๊ต - // - parentData๋Š” ์ด์ „ ํ™”๋ฉด ๋ฐ์ดํ„ฐ (์˜ˆ: ๊ฑฐ๋ž˜์ฒ˜ ํ…Œ์ด๋ธ”) - // - item.originalData๋Š” ์„ ํƒ๋œ ํ•ญ๋ชฉ ๋ฐ์ดํ„ฐ (์˜ˆ: ํ’ˆ๋ชฉ ํ…Œ์ด๋ธ”) + // - modalDataStore๋Š” ๋ชจ๋“  ์ด์ „ ํ™”๋ฉด์˜ ๋ˆ„์  ๋ฐ์ดํ„ฐ (์˜ˆ: ๊ฑฐ๋ž˜์ฒ˜, ํ’ˆ๋ชฉ) + // - item.originalData๋Š” ํ˜„์žฌ ์„ ํƒ๋œ ํ•ญ๋ชฉ ๋ฐ์ดํ„ฐ (์˜ˆ: ํ’ˆ๋ชฉ ํ…Œ์ด๋ธ”) // ์›๋ณธ ๋ฐ์ดํ„ฐ ํ…Œ์ด๋ธ”๋ช… ํ™•์ธ (sourceTable์ด config์— ๋ช…์‹œ๋˜์–ด ์žˆ์Œ) const sourceTableName = mapping.sourceTable; @@ -629,13 +643,30 @@ export class ButtonActionExecutor { sourceData = item.originalData; console.log(` ๐Ÿ“ฆ ์†Œ์Šค: ์„ ํƒ๋œ ํ•ญ๋ชฉ ๋ฐ์ดํ„ฐ (${sourceTableName})`); } else { - // ์ด์ „ ํ™”๋ฉด ๋ฐ์ดํ„ฐ ์‚ฌ์šฉ - sourceData = parentData; - console.log(` ๐Ÿ‘ค ์†Œ์Šค: ์ด์ „ ํ™”๋ฉด ๋ฐ์ดํ„ฐ (${sourceTableName})`); + // ๐Ÿ†• modalDataStore์—์„œ ํ•ด๋‹น ํ…Œ์ด๋ธ” ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ + const tableData = modalDataStore[sourceTableName]; + if (tableData && Array.isArray(tableData) && tableData.length > 0) { + sourceData = tableData[0]; // ์ฒซ ๋ฒˆ์งธ ํ•ญ๋ชฉ ์‚ฌ์šฉ + console.log(` ๐ŸŒ ์†Œ์Šค: modalDataStore (${sourceTableName})`); + } else { + // ํด๋ฐฑ: ์ด์ „ ํ™”๋ฉด ๋ฐ์ดํ„ฐ ์‚ฌ์šฉ + sourceData = parentData; + console.log(` ๐Ÿ‘ค ์†Œ์Šค: ์ด์ „ ํ™”๋ฉด ๋ฐ์ดํ„ฐ (${sourceTableName}) [ํด๋ฐฑ]`); + } } const sourceValue = sourceData[mapping.sourceField]; + console.log(` ๐Ÿ” ๋ฐ์ดํ„ฐ ์†Œ์Šค ์ƒ์„ธ:`, { + sourceTable: sourceTableName, + selectedItemTable, + isFromSelectedItem: sourceTableName === selectedItemTable, + sourceDataKeys: Object.keys(sourceData), + sourceField: mapping.sourceField, + sourceValue, + targetField: mapping.targetField + }); + if (sourceValue !== undefined && sourceValue !== null) { mappedData[mapping.targetField] = sourceValue; console.log(` โœ… [${sourceTableName}] ${mapping.sourceField} โ†’ ${mapping.targetField}: ${sourceValue}`);