feat: 카테고리 컴포넌트 메뉴 스코프 전환 완료

 구현 내용:
1. 백엔드 API 추가
   - GET /api/table-management/menu/:menuObjid/category-columns
   - 형제 메뉴들의 테이블에서 카테고리 타입 컬럼 조회
   - menuService.getSiblingMenuObjids() 재사용

2. 프론트엔드 CategoryWidget 수정
   - menuObjid를 props로 받아 CategoryColumnList에 전달
   - effectiveMenuObjid로 props.menuObjid도 처리
   - 선택된 컬럼에 tableName 포함하여 상태 관리

3. CategoryColumnList 수정
   - menuObjid 기반으로 형제 메뉴의 모든 카테고리 컬럼 조회
   - 테이블명+컬럼명 함께 표시
   - onColumnSelect에 tableName 전달

4. 메뉴 네비게이션 수정
   - AppLayout.tsx: 화면 이동 시 menuObjid를 URL 쿼리 파라미터로 전달
   - useMenu.ts: 동일하게 menuObjid 전달
   - page.tsx: 자식 컴포넌트에도 menuObjid 전달

🎯 효과:
- 이제 형제 메뉴들이 서로 다른 테이블을 사용해도 카테고리 공유 가능
- 메뉴 클릭 → 화면 이동 시 자동으로 menuObjid 전달
- 카테고리 위젯이 형제 메뉴의 모든 카테고리 컬럼 표시
This commit is contained in:
kjs
2025-11-11 14:44:22 +09:00
parent 668b45d4ea
commit 23911d3dd8
7 changed files with 218 additions and 82 deletions

View File

@@ -6,20 +6,52 @@ import { CategoryValueManager } from "@/components/table-category/CategoryValueM
import { GripVertical } from "lucide-react";
interface CategoryWidgetProps {
widgetId: string;
tableName: string; // 현재 화면의 테이블
menuObjid?: number; // 현재 메뉴 OBJID (메뉴 스코프)
widgetId?: string;
tableName?: string; // 현재 화면의 테이블 (옵션 - 형제 메뉴 전체 표시)
menuObjid?: number; // 현재 메뉴 OBJID (메뉴 스코프) - 필수
component?: any; // DynamicComponentRenderer에서 전달되는 컴포넌트 정보
[key: string]: any; // 추가 props 허용
}
/**
* 카테고리 관리 위젯 (좌우 분할)
* - 좌측: 현재 테이블의 카테고리 타입 컬럼 목록
* - 좌측: 형제 메뉴들의 모든 카테고리 타입 컬럼 목록 (메뉴 스코프)
* - 우측: 선택된 컬럼의 카테고리 값 관리 (메뉴 스코프)
*/
export function CategoryWidget({ widgetId, tableName, menuObjid }: CategoryWidgetProps) {
export function CategoryWidget({ widgetId, tableName, menuObjid, component, ...props }: CategoryWidgetProps) {
// menuObjid가 없으면 경고 로그
React.useEffect(() => {
console.log("🔍 CategoryWidget 받은 props:", {
widgetId,
tableName,
menuObjid,
hasComponent: !!component,
propsKeys: Object.keys(props),
propsMenuObjid: props.menuObjid,
allProps: { widgetId, tableName, menuObjid, ...props },
});
if (!menuObjid && !props.menuObjid) {
console.warn("⚠️ CategoryWidget: menuObjid가 전달되지 않았습니다", {
component,
props,
allAvailableProps: { widgetId, tableName, menuObjid, ...props }
});
} else {
console.log("✅ CategoryWidget 렌더링", {
widgetId,
tableName,
menuObjid: menuObjid || props.menuObjid
});
}
}, [menuObjid, widgetId, tableName, component, props]);
// menuObjid 우선순위: 직접 전달된 값 > props에서 추출한 값
const effectiveMenuObjid = menuObjid || props.menuObjid;
const [selectedColumn, setSelectedColumn] = useState<{
columnName: string;
columnLabel: string;
tableName: string;
} | null>(null);
const [leftWidth, setLeftWidth] = useState(15); // 초기값 15%
@@ -67,10 +99,10 @@ export function CategoryWidget({ widgetId, tableName, menuObjid }: CategoryWidge
<CategoryColumnList
tableName={tableName}
selectedColumn={selectedColumn?.columnName || null}
onColumnSelect={(columnName, columnLabel) =>
setSelectedColumn({ columnName, columnLabel })
onColumnSelect={(columnName, columnLabel, tableName) =>
setSelectedColumn({ columnName, columnLabel, tableName })
}
menuObjid={menuObjid}
menuObjid={effectiveMenuObjid}
/>
</div>
@@ -86,10 +118,10 @@ export function CategoryWidget({ widgetId, tableName, menuObjid }: CategoryWidge
<div style={{ width: `${100 - leftWidth - 1}%` }} className="pl-3">
{selectedColumn ? (
<CategoryValueManager
tableName={tableName}
tableName={selectedColumn.tableName}
columnName={selectedColumn.columnName}
columnLabel={selectedColumn.columnLabel}
menuObjid={menuObjid}
menuObjid={effectiveMenuObjid}
/>
) : (
<div className="flex h-64 flex-col items-center justify-center rounded-lg border bg-card shadow-sm">