From ca241c017dbf1a9040cec5f6f0b64b02db299515 Mon Sep 17 00:00:00 2001 From: johngreen Date: Thu, 14 May 2026 10:52:29 +0900 Subject: [PATCH] =?UTF-8?q?feat(=ED=85=8C=EC=9D=B4=EB=B8=94=ED=83=80?= =?UTF-8?q?=EC=9E=85):=20=ED=97=A4=EB=8D=94=20=ED=91=9C=EC=8B=9C=EB=AA=85/?= =?UTF-8?q?=EC=84=A4=EB=AA=85=20inline=20click-to-edit=20(Google=20Docs=20?= =?UTF-8?q?=ED=8C=A8=ED=84=B4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기존 "헤딩 + 옆에 input box 2개 + 저장 버튼" 구조의 UX 문제: - 같은 값을 헤딩과 input 양쪽에서 중복 표시 - 항상 폼처럼 보여 컬럼 그리드 시선을 뺏음 - 라벨만 바꾸려는 의도가 "전체 설정 저장" 에 묶여 흐려짐 변경: 헤딩 텍스트 자체를 클릭하면 그 자리에서 input 으로 변신 (Google Docs 문서 제목 / Notion 패턴). - blur 또는 Enter → PUT /label 즉시 저장 - Esc → 취소 - hover 시 muted/60 배경, cursor: text, title tooltip 으로 affordance - 설명이 비어 있으면 "+ 설명 추가" 힌트 표시 - 표시명은 비울 수 없게 가드 (toast.error) "전체 설정 저장" → "컬럼 설정 저장" 으로 책임 분리: - 헤더 라벨/설명: inline 즉시 저장 - 컬럼 input_type/web_type/detail_settings 등 일괄: 버튼 키보드 접근성: - Tab 으로 헤딩에 focus → Enter/Space 로 편집 모드 - Esc 로 취소, Enter 로 커밋 (blur 트리거) Co-Authored-By: Claude Opus 4.7 (1M context) --- .../admin/systemMng/tableMngList/page.tsx | 165 ++++++++++++++---- 1 file changed, 128 insertions(+), 37 deletions(-) diff --git a/frontend/app/(main)/admin/systemMng/tableMngList/page.tsx b/frontend/app/(main)/admin/systemMng/tableMngList/page.tsx index f3e41f02..639fc044 100644 --- a/frontend/app/(main)/admin/systemMng/tableMngList/page.tsx +++ b/frontend/app/(main)/admin/systemMng/tableMngList/page.tsx @@ -73,6 +73,9 @@ export default function TableManagementPage() { // 테이블 라벨 상태 const [tableLabel, setTableLabel] = useState(""); const [tableDescription, setTableDescription] = useState(""); + // 헤더 인라인 편집 상태 (Google Docs / Notion 패턴) + const [editingHeaderField, setEditingHeaderField] = useState<"label" | "description" | null>(null); + const [editingHeaderValue, setEditingHeaderValue] = useState(""); // 🎯 Entity 조인 관련 상태 const [referenceTableColumns, setReferenceTableColumns] = useState>({}); @@ -745,26 +748,49 @@ export default function TableManagementPage() { } }; - // 전체 저장 (테이블 라벨 + 모든 컬럼 설정) + // 헤더 표시명/설명 인라인 저장 (PUT /label) — Google Docs 식 blur/Enter 커밋 + const commitHeaderEdit = async () => { + if (!editingHeaderField || !selectedTable) { + setEditingHeaderField(null); + return; + } + const next = editingHeaderValue.trim(); + const current = editingHeaderField === "label" ? tableLabel : tableDescription; + if (next === current) { + setEditingHeaderField(null); + return; + } + const newLabel = editingHeaderField === "label" ? next : tableLabel; + const newDescription = editingHeaderField === "description" ? next : tableDescription; + if (editingHeaderField === "label" && !newLabel) { + toast.error("표시명은 비울 수 없습니다."); + setEditingHeaderField(null); + return; + } + if (editingHeaderField === "label") setTableLabel(newLabel); + else setTableDescription(newDescription); + setEditingHeaderField(null); + try { + await apiClient.put(`/table-management/tables/${selectedTable}/label`, { + display_name: newLabel, + description: newDescription, + }); + toast.success(editingHeaderField === "label" ? "표시명이 저장되었습니다." : "설명이 저장되었습니다."); + } catch (error: any) { + showErrorToast("저장에 실패했습니다", error, { + guidance: "잠시 후 다시 시도해 주세요.", + }); + } + }; + + // 컬럼 설정만 일괄 저장 (헤더 라벨/설명은 inline 편집으로 즉시 저장됨) const saveAllSettings = async () => { if (!selectedTable) return; if (isSaving) return; // 저장 중 중복 실행 방지 setIsSaving(true); try { - // 1. 테이블 라벨 저장 (변경된 경우에만) - if (tableLabel !== selectedTable || tableDescription) { - try { - await apiClient.put(`/table-management/tables/${selectedTable}/label`, { - display_name: tableLabel, - description: tableDescription, - }); - } catch (error) { - // console.warn("테이블 라벨 저장 실패 (API 미구현 가능):", error); - } - } - - // 2. 모든 컬럼 설정 저장 + // 모든 컬럼 설정 저장 if (columns.length > 0) { const columnSettings = columns.map((column) => { // detailSettings 계산 @@ -1507,42 +1533,107 @@ export default function TableManagementPage() { ) : ( <> - {/* 중앙 헤더: 테이블명 + 라벨 입력 + 저장 */} -
-
-
- {tableLabel || selectedTable} -
-
+ {/* 중앙 헤더: inline click-to-edit (Google Docs / Notion 패턴) */} +
+
+ {/* 표시명 (display_name) — 클릭하면 그 자리에서 편집 */} + {editingHeaderField === "label" ? ( + setEditingHeaderValue(e.target.value)} + onBlur={commitHeaderEdit} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + e.currentTarget.blur(); + } else if (e.key === "Escape") { + setEditingHeaderField(null); + } + }} + className="h-7 -mx-2 px-2 text-[15px] font-bold tracking-tight" + /> + ) : ( +
{ + setEditingHeaderValue(tableLabel); + setEditingHeaderField("label"); + }} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + setEditingHeaderValue(tableLabel); + setEditingHeaderField("label"); + } + }} + className="-mx-2 cursor-text rounded px-2 py-0.5 text-[15px] font-bold tracking-tight hover:bg-muted/60 transition-colors" + title="클릭하여 표시명 편집" + > + {tableLabel || ( + {selectedTable} + )} +
+ )} + {/* table_name (코드, 편집 불가) */} +
{selectedTable}
-
-
- setTableLabel(e.target.value)} - placeholder="표시명" - className="h-8 max-w-[160px] text-xs" - /> - setTableDescription(e.target.value)} - placeholder="설명" - className="h-8 max-w-[200px] text-xs" - /> + {/* 설명 (description) — 클릭하면 그 자리에서 편집 */} + {editingHeaderField === "description" ? ( + setEditingHeaderValue(e.target.value)} + onBlur={commitHeaderEdit} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + e.currentTarget.blur(); + } else if (e.key === "Escape") { + setEditingHeaderField(null); + } + }} + placeholder="이 테이블에 대한 짧은 설명" + className="mt-1 h-7 -mx-2 px-2 text-xs" + /> + ) : ( +
{ + setEditingHeaderValue(tableDescription); + setEditingHeaderField("description"); + }} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + setEditingHeaderValue(tableDescription); + setEditingHeaderField("description"); + } + }} + className="-mx-2 mt-0.5 cursor-text rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/60 transition-colors" + title="클릭하여 설명 편집" + > + {tableDescription || ( + + 설명 추가 + )} +
+ )}