refactor: unify bag and admin layout routing
This commit is contained in:
@@ -2,26 +2,24 @@
|
||||
declare(strict_types=1);
|
||||
helper('admin');
|
||||
$siteNavTree = get_site_nav_tree();
|
||||
$uriObj = service('request')->getUri();
|
||||
$currentPath = trim((string) $uriObj->getPath(), '/');
|
||||
if (str_starts_with($currentPath, 'index.php/')) {
|
||||
$currentPath = substr($currentPath, strlen('index.php/'));
|
||||
}
|
||||
$currentPath = current_nav_request_path();
|
||||
$mbLevel = (int) session()->get('mb_level');
|
||||
$isAdmin = ($mbLevel === \Config\Roles::LEVEL_SUPER_ADMIN || $mbLevel === \Config\Roles::LEVEL_LOCAL_ADMIN);
|
||||
$dashboardPathAliases = ['dashboard', 'dashboard/blend'];
|
||||
$effectiveLgIdx = admin_effective_lg_idx();
|
||||
$effectiveLgName = null;
|
||||
if ($effectiveLgIdx) {
|
||||
$lgRow = model(\App\Models\LocalGovernmentModel::class)->find($effectiveLgIdx);
|
||||
$effectiveLgName = $lgRow ? $lgRow->lg_name : null;
|
||||
}
|
||||
$userNav = session_user_nav_display();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||
<title><?= esc($title ?? '쓰레기봉투 물류시스템') ?></title>
|
||||
<title><?= esc($title ?? '종량제 시스템') ?></title>
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap" rel="stylesheet"/>
|
||||
<script>
|
||||
@@ -64,32 +62,19 @@ body { overflow: hidden; }
|
||||
</head>
|
||||
<body class="bg-gray-100 text-gray-800 flex flex-col h-screen font-sans antialiased select-none">
|
||||
<!-- BEGIN: Top Navigation -->
|
||||
<header class="relative bg-white border-b border-gray-300 h-12 flex items-center justify-between px-4 shrink-0 z-50">
|
||||
<header class="relative bg-white border-b border-gray-300 h-12 flex items-center justify-between px-4 shrink-0 z-[100]">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="w-6 h-6 flex items-center justify-center shrink-0">
|
||||
<svg class="h-5 w-5" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="16" height="16" fill="#2563eb"/><rect x="2" y="2" width="7" height="7" fill="white"/><rect x="5" y="5" width="9" height="9" fill="white"/>
|
||||
</svg>
|
||||
</div>
|
||||
<a href="<?= base_url() ?>" class="text-base font-semibold text-gray-800 tracking-tight hover:text-blue-600">쓰레기봉투 물류시스템</a>
|
||||
</div>
|
||||
<?= view('components/header_brand') ?>
|
||||
</div>
|
||||
<nav class="hidden md:flex gap-5 text-sm font-medium text-gray-600">
|
||||
<?php if (! empty($siteNavTree)): ?>
|
||||
<?php foreach ($siteNavTree as $navItem): ?>
|
||||
<?php
|
||||
$navLink = trim((string) $navItem->mm_link, '/');
|
||||
$isActive = ($currentPath === $navLink);
|
||||
$navLink = menu_link_preferred_href_path($navItem->mm_link ?? null, $currentPath);
|
||||
$isActive = site_nav_link_matches_current($navItem->mm_link ?? null, $currentPath, $dashboardPathAliases);
|
||||
if (! $isActive && ! empty($navItem->children)) {
|
||||
foreach ($navItem->children as $ch) {
|
||||
$childPath = trim((string) $ch->mm_link, '/');
|
||||
if ($currentPath === $childPath) {
|
||||
$isActive = true;
|
||||
break;
|
||||
}
|
||||
// 기본코드 세부는 메뉴에 직접 링크 없음 → 기본코드관리(bag/code-kinds)와 동일 메뉴군으로 표시
|
||||
if ($childPath === 'bag/code-kinds' && str_starts_with($currentPath, 'bag/code-details')) {
|
||||
if (site_nav_link_matches_current($ch->mm_link ?? null, $currentPath, $dashboardPathAliases)) {
|
||||
$isActive = true;
|
||||
break;
|
||||
}
|
||||
@@ -98,20 +83,21 @@ body { overflow: hidden; }
|
||||
?>
|
||||
<div class="relative group">
|
||||
<a class="<?= $isActive ? 'text-blue-700 font-bold border-b-2 border-blue-700 pb-3 -mb-3' : 'hover:text-blue-600' ?>"
|
||||
href="<?= base_url($navItem->mm_link) ?>">
|
||||
href="<?= $navLink !== '' ? base_url($navLink) : '#' ?>">
|
||||
<?= esc($navItem->mm_name) ?>
|
||||
</a>
|
||||
<?php if (! empty($navItem->children)): ?>
|
||||
<?php /* pt-1: 부모와 패널 사이 호버 끊김 방지. z-50: 제목 바보다 위 */ ?>
|
||||
<div class="absolute left-0 top-full z-50 hidden pt-1 min-w-[12rem] group-hover:block group-focus-within:block">
|
||||
<?php /* -mt-1 + pt-2: 부모 링크와 패널이 살짝 겹쳐 호버가 끊기지 않게 함. z-index: 드롭다운 클릭 우선 */ ?>
|
||||
<div class="absolute left-0 top-full z-[200] -mt-1 pt-2 min-w-[12rem] hidden group-hover:block group-focus-within:block">
|
||||
<div class="bg-white border border-gray-200 rounded shadow-lg py-1">
|
||||
<?php foreach ($navItem->children as $child): ?>
|
||||
<?php
|
||||
$childLink = trim((string) ($child->mm_link ?? ''));
|
||||
$childLink = menu_link_preferred_href_path($child->mm_link ?? null, $currentPath);
|
||||
$childCurrent = menu_link_matches_request($child->mm_link ?? null, $currentPath, $dashboardPathAliases);
|
||||
?>
|
||||
<?php if ($childLink !== ''): ?>
|
||||
<a href="<?= base_url($childLink) ?>"
|
||||
class="block px-3 py-1.5 text-sm text-gray-700 hover:bg-blue-50 whitespace-nowrap">
|
||||
class="block px-3 py-1.5 text-sm hover:bg-blue-50 whitespace-nowrap <?= $childCurrent ? 'text-blue-700 font-semibold bg-blue-50' : 'text-gray-700' ?>">
|
||||
<?= esc($child->mm_name) ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
@@ -127,17 +113,12 @@ body { overflow: hidden; }
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<div class="flex items-center gap-2">
|
||||
<?php if ($effectiveLgName !== null): ?>
|
||||
<span class="text-sm text-gray-600" title="현재 작업 지자체"><?= esc($effectiveLgName) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ($isAdmin): ?>
|
||||
<a href="<?= base_url('admin') ?>" class="text-gray-500 hover:text-blue-600 text-sm">관리자</a>
|
||||
<?php endif; ?>
|
||||
<a href="<?= base_url('logout') ?>" class="text-gray-500 hover:text-red-600 transition-colors inline-block p-1 rounded hover:bg-red-50" title="로그아웃">
|
||||
<svg class="h-5 w-5 inline" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M6 18L18 6M6 6l12 12" stroke-linecap="round" stroke-linejoin="round"/></svg> 종료
|
||||
</a>
|
||||
</div>
|
||||
<?= view('components/header_user_tools', [
|
||||
'userNav' => $userNav,
|
||||
'effectiveLgName' => $effectiveLgName,
|
||||
'showSiteLink' => false,
|
||||
'showAdminLink' => $isAdmin,
|
||||
]) ?>
|
||||
</header>
|
||||
<!-- END: Top Navigation -->
|
||||
<div class="bg-title-bar text-white px-4 py-2 text-sm font-medium shrink-0">
|
||||
@@ -153,7 +134,7 @@ body { overflow: hidden; }
|
||||
<?= $content ?>
|
||||
</main>
|
||||
<footer class="bg-gray-200 border-t border-gray-300 px-4 py-1 text-xs text-gray-600 flex items-center justify-between shrink-0">
|
||||
<span>쓰레기봉투 물류시스템</span>
|
||||
<span>종량제 시스템</span>
|
||||
<span><?= date('Y.m.d (D) g:i:sA') ?></span>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user