Merge pull request 'feat(테이블타입): 헤더 표시명/설명 inline click-to-edit (Google Docs 패턴)' (#17) from johngreen into main
Build & Deploy to K8s / build-and-deploy (push) Successful in 7m1s

This commit was merged in pull request #17.
This commit is contained in:
2026-05-14 01:53:05 +00:00
@@ -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<Record<string, ReferenceTableColumn[]>>({});
@@ -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() {
</div>
) : (
<>
{/* 중앙 헤더: 테이블명 + 라벨 입력 + 저장 */}
<div className="bg-card flex flex-shrink-0 items-center gap-3 border-b px-5 py-3">
<div className="min-w-0 flex-shrink-0">
<div className="text-[15px] font-bold tracking-tight">
{tableLabel || selectedTable}
</div>
<div className="text-muted-foreground font-mono text-[11px] tracking-tight">
{/* 중앙 헤더: inline click-to-edit (Google Docs / Notion 패턴) */}
<div className="bg-card flex flex-shrink-0 items-start gap-3 border-b px-5 py-3">
<div className="min-w-0 flex-1">
{/* 표시명 (display_name) — 클릭하면 그 자리에서 편집 */}
{editingHeaderField === "label" ? (
<Input
autoFocus
value={editingHeaderValue}
onChange={(e) => 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"
/>
) : (
<div
role="button"
tabIndex={0}
onClick={() => {
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 || (
<span className="text-muted-foreground/60">{selectedTable}</span>
)}
</div>
)}
{/* table_name (코드, 편집 불가) */}
<div className="-mx-2 px-2 text-muted-foreground font-mono text-[11px] tracking-tight">
{selectedTable}
</div>
</div>
<div className="flex min-w-0 flex-1 items-center gap-2">
<Input
value={tableLabel}
onChange={(e) => setTableLabel(e.target.value)}
placeholder="표시명"
className="h-8 max-w-[160px] text-xs"
/>
<Input
value={tableDescription}
onChange={(e) => setTableDescription(e.target.value)}
placeholder="설명"
className="h-8 max-w-[200px] text-xs"
/>
{/* 설명 (description) — 클릭하면 그 자리에서 편집 */}
{editingHeaderField === "description" ? (
<Input
autoFocus
value={editingHeaderValue}
onChange={(e) => 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"
/>
) : (
<div
role="button"
tabIndex={0}
onClick={() => {
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 || (
<span className="text-muted-foreground/50">+ </span>
)}
</div>
)}
</div>
<Button
onClick={saveAllSettings}
disabled={!selectedTable || columns.length === 0 || isSaving}
size="sm"
className="h-8 gap-1.5 text-xs"
className="h-8 flex-shrink-0 gap-1.5 text-xs"
>
{isSaving ? (
<Loader2 className="h-3.5 w-3.5 animate-spin" />
) : (
<Save className="h-3.5 w-3.5" />
)}
{isSaving ? "저장 중..." : "전체 설정 저장"}
{isSaving ? "저장 중..." : "컬럼 설정 저장"}
</Button>
</div>