From cb254cf138489db49158c018c1a4b67ea7a6b683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 13 Mar 2026 21:18:54 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[tenant]=20=EC=BB=A8=ED=85=8D=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=A9=94=EB=89=B4=20=ED=85=8C=EB=84=8C=ED=8A=B8=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20+=20=EC=BD=98=EC=86=94=20=EC=82=AC?= =?UTF-8?q?=EC=9D=B4=EB=93=9C=EB=B0=94=20DB=20=EB=A9=94=EB=89=B4=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 컨텍스트 메뉴 "이 테넌트로 전환" → "테넌트 설정" (보라색, 설정 아이콘) - context-menu.js에서 직접 window.open 처리 (openTenantConsole 의존 제거) - 테넌트 콘솔 사이드바 하드코딩 → DB 기반 메뉴 시스템 전환 - SidebarMenuService에 getTenantMenusBySection() 추가 - AppServiceProvider에 tenant-console-sidebar View Composer 추가 --- app/Providers/AppServiceProvider.php | 13 ++ app/Services/SidebarMenuService.php | 29 +++ public/js/context-menu.js | 7 +- .../views/components/context-menu.blade.php | 7 +- .../partials/tenant-console-sidebar.blade.php | 196 ++++++++++-------- 5 files changed, 165 insertions(+), 87 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2d148c76..5ed1910c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -64,5 +64,18 @@ public function boot(): void 'favoriteMenuIds' => $menuService->getFavoriteMenuIds(), ]); }); + + // 테넌트 콘솔 사이드바에 해당 테넌트의 메뉴 데이터 전달 + View::composer('partials.tenant-console-sidebar', function ($view) { + $tenantId = $view->getData()['consoleTenantId'] ?? request()->route('tenantId'); + if ($tenantId) { + $menuService = app(SidebarMenuService::class); + $menusBySection = $menuService->getTenantMenusBySection((int) $tenantId); + + $view->with([ + 'tenantMainMenus' => $menusBySection['main'], + ]); + } + }); } } diff --git a/app/Services/SidebarMenuService.php b/app/Services/SidebarMenuService.php index 0b51a208..505cb0bf 100644 --- a/app/Services/SidebarMenuService.php +++ b/app/Services/SidebarMenuService.php @@ -131,6 +131,35 @@ public function getMenusBySection(?User $user = null): array ]; } + /** + * 특정 테넌트의 전체 메뉴 트리 조회 (권한 필터 없음, 관리 콘솔용) + */ + public function getTenantMenuTree(int $tenantId): Collection + { + $allMenus = Menu::withoutGlobalScopes() + ->where('tenant_id', $tenantId) + ->where('is_active', true) + ->where('hidden', false) + ->orderBy('sort_order') + ->get(); + + return $this->buildMenuTree($allMenus); + } + + /** + * 특정 테넌트의 섹션별 메뉴 조회 (관리 콘솔용) + */ + public function getTenantMenusBySection(int $tenantId): array + { + $menuTree = $this->getTenantMenuTree($tenantId); + + return [ + 'main' => $menuTree->filter(fn ($m) => $m->getSection() === 'main')->values(), + 'tools' => $menuTree->filter(fn ($m) => $m->getSection() === 'tools')->values(), + 'labs' => $menuTree->filter(fn ($m) => $m->getSection() === 'labs')->values(), + ]; + } + /** * 메뉴 트리 구성 */ diff --git a/public/js/context-menu.js b/public/js/context-menu.js index 5d351b14..6ed7723d 100644 --- a/public/js/context-menu.js +++ b/public/js/context-menu.js @@ -121,8 +121,11 @@ class ContextMenu { window.location.href = `/tenants/${id}/edit`; break; case 'switch-tenant': - if (typeof openTenantConsole === 'function') { - openTenantConsole(id, name); + { + const w = 1400, h = 900; + const l = (screen.width - w) / 2, t = (screen.height - h) / 2; + window.open(`/tenant-console/${id}`, `tenant_${id}`, + `width=${w},height=${h},left=${l},top=${t},resizable=yes,scrollbars=yes`); } break; case 'view-user': diff --git a/resources/views/components/context-menu.blade.php b/resources/views/components/context-menu.blade.php index 315908bb..f5bd7c5e 100644 --- a/resources/views/components/context-menu.blade.php +++ b/resources/views/components/context-menu.blade.php @@ -28,11 +28,12 @@ class="w-full px-4 py-2 text-left text-sm text-gray-700 hover:bg-gray-100 flex i {{-- 사용자 관련 메뉴 --}} diff --git a/resources/views/partials/tenant-console-sidebar.blade.php b/resources/views/partials/tenant-console-sidebar.blade.php index d3c83351..aaa9afd0 100644 --- a/resources/views/partials/tenant-console-sidebar.blade.php +++ b/resources/views/partials/tenant-console-sidebar.blade.php @@ -1,51 +1,8 @@ -{{-- 테넌트 콘솔 전용 사이드바 (메인 사이드바 스타일 통일) --}} +{{-- 테넌트 콘솔 전용 사이드바 (DB 기반 메뉴 시스템) --}} @php $tenantId = $consoleTenantId ?? 0; - $currentUrl = request()->url(); $baseUrl = "/tenant-console/{$tenantId}"; - - $menuGroups = [ - [ - 'title' => '권한 관리', - 'icon' => 'ri-shield-keyhole-line', - 'items' => [ - ['name' => '권한 관리', 'url' => "{$baseUrl}/permissions", 'icon' => 'ri-key-2-line'], - ['name' => '역할 관리', 'url' => "{$baseUrl}/roles", 'icon' => 'ri-user-settings-line'], - ['name' => '역할-권한 매핑', 'url' => "{$baseUrl}/role-permissions", 'icon' => 'ri-links-line'], - ['name' => '부서-권한 매핑', 'url' => "{$baseUrl}/department-permissions", 'icon' => 'ri-building-2-line'], - ['name' => '사용자-권한 매핑', 'url' => "{$baseUrl}/user-permissions", 'icon' => 'ri-user-star-line'], - ], - ], - [ - 'title' => '시스템 관리', - 'icon' => 'ri-settings-3-line', - 'items' => [ - ['name' => 'AI 설정', 'url' => "{$baseUrl}/system/ai-config", 'icon' => 'ri-robot-line'], - ['name' => '휴일 관리', 'url' => "{$baseUrl}/system/holidays", 'icon' => 'ri-calendar-event-line'], - ['name' => '시스템 알림', 'url' => "{$baseUrl}/system/alerts", 'icon' => 'ri-notification-3-line'], - ['name' => '공통코드', 'url' => "{$baseUrl}/common-codes", 'icon' => 'ri-code-s-slash-line'], - ['name' => '카테고리', 'url' => "{$baseUrl}/categories", 'icon' => 'ri-node-tree'], - ['name' => '감사 로그', 'url' => "{$baseUrl}/audit-logs", 'icon' => 'ri-file-list-3-line'], - ], - ], - [ - 'title' => '생산관리', - 'icon' => 'ri-instance-line', - 'items' => [ - ['name' => '품목관리', 'url' => "{$baseUrl}/production/items", 'icon' => 'ri-box-3-line'], - ['name' => '품목필드', 'url' => "{$baseUrl}/production/item-fields", 'icon' => 'ri-list-settings-line'], - ['name' => '견적수식', 'url' => "{$baseUrl}/production/quote-formulas", 'icon' => 'ri-calculator-line'], - ['name' => '카테고리', 'url' => "{$baseUrl}/production/categories", 'icon' => 'ri-node-tree'], - ], - ], - [ - 'title' => '게시판관리', - 'icon' => 'ri-article-line', - 'items' => [ - ['name' => '게시판 목록', 'url' => "{$baseUrl}/boards", 'icon' => 'ri-layout-grid-line'], - ], - ], - ]; + $menus = $tenantMainMenus ?? collect(); @endphp + \ No newline at end of file