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 || ( + + 설명 추가 + )} +
+ )}