summaryrefslogtreecommitdiff
path: root/components/form-data/form-data-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/form-data/form-data-table.tsx')
-rw-r--r--components/form-data/form-data-table.tsx50
1 files changed, 28 insertions, 22 deletions
diff --git a/components/form-data/form-data-table.tsx b/components/form-data/form-data-table.tsx
index 57913192..d964b17b 100644
--- a/components/form-data/form-data-table.tsx
+++ b/components/form-data/form-data-table.tsx
@@ -317,10 +317,6 @@ export default function DynamicTable({
// 새로 추가된 Template 가져오기 함수
const handleGetTemplate = async () => {
- if (selectedRowCount !== 1) {
- toast.error("Please select exactly one row to view template");
- return;
- }
if (!projectCode) {
toast.error("Project code is not available");
@@ -329,12 +325,12 @@ export default function DynamicTable({
try {
setIsLoadingTemplate(true);
-
+
const templateResult = await fetchTemplateFromSEDP(projectCode, formCode);
-
+
setTemplateData(templateResult);
setTemplateDialogOpen(true);
-
+
toast.success("Template data loaded successfully");
} catch (error) {
console.error("Error fetching template:", error);
@@ -818,7 +814,7 @@ export default function DynamicTable({
variant="outline"
size="sm"
onClick={handleGetTemplate}
- disabled={isAnyOperationPending || selectedRowCount !== 1}
+ disabled={isAnyOperationPending}
>
{isLoadingTemplate ? (
<Loader className="mr-2 size-4 animate-spin" />
@@ -826,13 +822,9 @@ export default function DynamicTable({
<Eye className="mr-2 size-4" />
)}
View Template
- {selectedRowCount === 1 && (
- <span className="ml-2 text-xs bg-green-100 text-green-700 px-2 py-1 rounded">
- 1
- </span>
- )}
</Button>
+
{/* COMPARE WITH SEDP 버튼 */}
<Button
variant="outline"
@@ -920,19 +912,33 @@ export default function DynamicTable({
isOpen={templateDialogOpen}
onClose={() => setTemplateDialogOpen(false)}
templateData={templateData}
- selectedRow={selectedRowsData[0]}
+ selectedRow={selectedRowsData[0]} // SPR_ITM_LST_SETUP용
+ tableData={tableData} // SPR_LST_SETUP용 - 새로 추가
formCode={formCode}
contractItemId={contractItemId}
editableFieldsMap={editableFieldsMap}
onUpdateSuccess={(updatedValues) => {
- // SpreadSheets에서 업데이트된 값을 테이블에 반영
- const tagNo = updatedValues.TAG_NO;
- if (tagNo) {
- setTableData(prev =>
- prev.map(item =>
- item.TAG_NO === tagNo ? updatedValues : item
- )
- );
+ // 업데이트 로직도 수정해야 함 - 단일 행 또는 복수 행 처리
+ if (Array.isArray(updatedValues)) {
+ // SPR_LST_SETUP의 경우 - 복수 행 업데이트
+ const updatedData = [...tableData];
+ updatedValues.forEach(updatedItem => {
+ const index = updatedData.findIndex(item => item.TAG_NO === updatedItem.TAG_NO);
+ if (index !== -1) {
+ updatedData[index] = updatedItem;
+ }
+ });
+ setTableData(updatedData);
+ } else {
+ // SPR_ITM_LST_SETUP의 경우 - 단일 행 업데이트
+ const tagNo = updatedValues.TAG_NO;
+ if (tagNo) {
+ setTableData(prev =>
+ prev.map(item =>
+ item.TAG_NO === tagNo ? updatedValues : item
+ )
+ );
+ }
}
}}
/>