From 9684a83f37ac095af53e20890a51112218c69469 Mon Sep 17 00:00:00 2001 From: SeongHyun Kim Date: Fri, 19 Dec 2025 14:07:35 +0900 Subject: [PATCH] =?UTF-8?q?feat(TableSection):=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=9D=BC=EA=B4=84=20=EC=A0=81=EC=9A=A9=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20TableColumnConfig?= =?UTF-8?q?=EC=97=90=20batchApply=20=EC=86=8D=EC=84=B1=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=82=A0=EC=A7=9C=20=ED=83=80=EC=9E=85=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=EC=84=A4=EC=A0=95=20=EC=8B=9C=20"=EC=9D=BC?= =?UTF-8?q?=EA=B4=84=20=EC=A0=81=EC=9A=A9"=20=EC=8A=A4=EC=9C=84=EC=B9=98?= =?UTF-8?q?=20=ED=91=9C=EC=8B=9C=20=EC=B2=AB=20=EB=B2=88=EC=A7=B8=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=20=EC=9E=85=EB=A0=A5=20=EC=8B=9C=20=EB=AA=A8?= =?UTF-8?q?=EB=93=A0=20=ED=96=89=EC=97=90=20=EC=9E=90=EB=8F=99=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EC=A4=91=EB=B3=B5=20=EC=A0=81=EC=9A=A9=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EC=9C=84=ED=95=9C=20batchAppliedFields=20?= =?UTF-8?q?=ED=94=8C=EB=9E=98=EA=B7=B8=20=EA=B4=80=EB=A6=AC=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=A0=84=EC=B2=B4=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EC=8B=9C=20=ED=94=8C=EB=9E=98=EA=B7=B8=20=EB=A6=AC=EC=85=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TableSectionRenderer.tsx | 46 +++++++++++++++++-- .../modals/TableSectionSettingsModal.tsx | 11 +++++ .../components/universal-form-modal/types.ts | 4 ++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx b/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx index 3c64e543..1d1298cd 100644 --- a/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx +++ b/frontend/lib/registry/components/universal-form-modal/TableSectionRenderer.tsx @@ -335,6 +335,9 @@ export function TableSectionRenderer({ // 동적 데이터 소스 활성화 상태 const [activeDataSources, setActiveDataSources] = useState>({}); + + // 날짜 일괄 적용 완료 플래그 (컬럼별로 한 번만 적용) + const [batchAppliedFields, setBatchAppliedFields] = useState>(new Set()); // RepeaterColumnConfig로 변환 const columns: RepeaterColumnConfig[] = (tableConfig.columns || []).map(convertToRepeaterColumn); @@ -381,13 +384,43 @@ export function TableSectionRenderer({ [calculateRow] ); - // 데이터 변경 핸들러 + // 데이터 변경 핸들러 (날짜 일괄 적용 로직 포함) const handleDataChange = useCallback( (newData: any[]) => { - setTableData(newData); - onTableDataChange(newData); + let processedData = newData; + + // 날짜 일괄 적용 로직: batchApply가 활성화된 날짜 컬럼 처리 + const batchApplyColumns = tableConfig.columns.filter( + (col) => col.type === "date" && col.batchApply === true + ); + + for (const dateCol of batchApplyColumns) { + // 이미 일괄 적용된 컬럼은 건너뜀 + if (batchAppliedFields.has(dateCol.field)) continue; + + // 해당 컬럼에 값이 있는 행과 없는 행 분류 + const itemsWithDate = processedData.filter((item) => item[dateCol.field]); + const itemsWithoutDate = processedData.filter((item) => !item[dateCol.field]); + + // 조건: 정확히 1개만 날짜가 있고, 나머지는 모두 비어있을 때 + if (itemsWithDate.length === 1 && itemsWithoutDate.length > 0) { + const selectedDate = itemsWithDate[0][dateCol.field]; + + // 모든 행에 동일한 날짜 적용 + processedData = processedData.map((item) => ({ + ...item, + [dateCol.field]: selectedDate, + })); + + // 플래그 활성화 (이후 개별 수정 가능) + setBatchAppliedFields((prev) => new Set([...prev, dateCol.field])); + } + } + + setTableData(processedData); + onTableDataChange(processedData); }, - [onTableDataChange] + [onTableDataChange, tableConfig.columns, batchAppliedFields] ); // 행 변경 핸들러 @@ -416,6 +449,11 @@ export function TableSectionRenderer({ const newData = tableData.filter((_, index) => !selectedRows.has(index)); handleDataChange(newData); setSelectedRows(new Set()); + + // 데이터가 모두 삭제되면 일괄 적용 플래그도 리셋 + if (newData.length === 0) { + setBatchAppliedFields(new Set()); + } }, [tableData, selectedRows, handleDataChange]); // 아이템 추가 핸들러 (모달에서 선택) diff --git a/frontend/lib/registry/components/universal-form-modal/modals/TableSectionSettingsModal.tsx b/frontend/lib/registry/components/universal-form-modal/modals/TableSectionSettingsModal.tsx index baf21194..5a845db0 100644 --- a/frontend/lib/registry/components/universal-form-modal/modals/TableSectionSettingsModal.tsx +++ b/frontend/lib/registry/components/universal-form-modal/modals/TableSectionSettingsModal.tsx @@ -419,6 +419,17 @@ function ColumnSettingItem({ 조회 + {/* 날짜 타입일 때만 일괄 적용 옵션 표시 */} + {col.type === "date" && ( + + )} {/* 조회 설정 (조회 ON일 때만 표시) */} diff --git a/frontend/lib/registry/components/universal-form-modal/types.ts b/frontend/lib/registry/components/universal-form-modal/types.ts index 80938d65..3bfa771b 100644 --- a/frontend/lib/registry/components/universal-form-modal/types.ts +++ b/frontend/lib/registry/components/universal-form-modal/types.ts @@ -331,6 +331,10 @@ export interface TableColumnConfig { // 조회 설정 (동적 값 조회) lookup?: LookupConfig; + + // 날짜 일괄 적용 (type이 "date"일 때만 사용) + // 활성화 시 첫 번째 날짜 입력 시 모든 행에 동일한 날짜가 자동 적용됨 + batchApply?: boolean; } // ============================================