feat: 기본정보관리 사이드바 소메뉴에 아이콘 추가

- 이름 키워드 기반 Font Awesome 아이콘 매핑(서버 렌더 + JS 재구성 양쪽 반영)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
taekyoungc
2026-07-13 12:27:13 +09:00
parent e9f1cf2b49
commit 794d34635b
2 changed files with 58 additions and 4 deletions

View File

@@ -6,6 +6,29 @@
var listEl = document.getElementById('portalSidebarList'); var listEl = document.getElementById('portalSidebarList');
var titleEl = document.getElementById('portalSidebarTitle'); var titleEl = document.getElementById('portalSidebarTitle');
// 기본정보관리 소메뉴 아이콘(Font Awesome solid) — 이름 키워드 기준(구체적인 것 먼저)
function sidebarIcon(name) {
var n = String(name || '');
var rules = [
['바코드', 'fa-barcode'], ['조회', 'fa-magnifying-glass'],
['신규', 'fa-chart-column'], ['현황', 'fa-chart-column'],
['판매소', 'fa-store'], ['대행소', 'fa-handshake'],
['담당자', 'fa-user-tie'], ['업체', 'fa-building'],
['무료', 'fa-gift'], ['포장', 'fa-box'],
['단가', 'fa-won-sign'], ['코드', 'fa-list-ol'],
['비밀번호', 'fa-key'], ['설정', 'fa-gear']
];
for (var i = 0; i < rules.length; i++) {
if (n.indexOf(rules[i][0]) !== -1) return rules[i][1];
}
if (n.toLowerCase().indexOf('password') !== -1) return 'fa-key';
return 'fa-angle-right';
}
function iconHtml(parentName, childName) {
if (String(parentName || '').replace(/\s/g, '') !== '기본정보관리') return '';
return '<i class="fa-solid ' + sidebarIcon(childName) + '" style="width:1.15em;margin-right:.45em;opacity:.85;"></i>';
}
if (listEl && navData.length) { if (listEl && navData.length) {
function renderSidebar(idx, overrideHref) { function renderSidebar(idx, overrideHref) {
var parent = navData[idx]; var parent = navData[idx];
@@ -29,10 +52,11 @@
var li = document.createElement('li'); var li = document.createElement('li');
var chHref = (child.href || '').toLowerCase().replace(/^\//, ''); var chHref = (child.href || '').toLowerCase().replace(/^\//, '');
var on = activeHref ? (chHref === activeHref) : (hasOverride ? false : ci === 0); var on = activeHref ? (chHref === activeHref) : (hasOverride ? false : ci === 0);
var ic = iconHtml(parent.name, child.name);
if (child.href) { if (child.href) {
li.innerHTML = '<a href="' + child.url + '" class="' + (on ? 'active' : '') + '">' + child.name + '</a>'; li.innerHTML = '<a href="' + child.url + '" class="' + (on ? 'active' : '') + '">' + ic + child.name + '</a>';
} else { } else {
li.innerHTML = '<span class="menu-sub" style="opacity:.65;">' + child.name + '</span>'; li.innerHTML = '<span class="menu-sub" style="opacity:.65;">' + ic + child.name + '</span>';
} }
listEl.appendChild(li); listEl.appendChild(li);
}); });

View File

@@ -6,6 +6,36 @@ declare(strict_types=1);
$activeParent = $govNavItems[$govActiveParentIdx] ?? $govNavItems[0] ?? null; $activeParent = $govNavItems[$govActiveParentIdx] ?? $govNavItems[0] ?? null;
$sidebarTitle = $activeParent['name'] ?? 'MY MENU'; $sidebarTitle = $activeParent['name'] ?? 'MY MENU';
$activeChildHref = strtolower(ltrim((string) ($govActiveChildHref ?? ''), '/')); $activeChildHref = strtolower(ltrim((string) ($govActiveChildHref ?? ''), '/'));
// 기본정보관리 소메뉴에 어울리는 아이콘(Font Awesome solid) 매핑 — 이름 키워드 기준(구체적인 것 먼저)
$showSidebarIcons = (str_replace(' ', '', (string) $sidebarTitle) === '기본정보관리');
$sidebarIconFor = static function (string $name): string {
$rules = [
'바코드' => 'fa-barcode', // 지정판매소 바코드 출력
'조회' => 'fa-magnifying-glass', // 지정 판매소 조회
'신규' => 'fa-chart-column', // 지정 판매소 신규/취소 현황
'현황' => 'fa-chart-column',
'판매소' => 'fa-store', // 지정 판매소 관리
'대행소' => 'fa-handshake',
'담당자' => 'fa-user-tie',
'업체' => 'fa-building',
'무료' => 'fa-gift',
'포장' => 'fa-box',
'단가' => 'fa-won-sign',
'코드' => 'fa-list-ol',
'비밀번호' => 'fa-key',
'설정' => 'fa-gear',
];
foreach ($rules as $kw => $icon) {
if (mb_stripos($name, $kw) !== false) {
return $icon;
}
}
if (stripos($name, 'password') !== false) {
return 'fa-key';
}
return 'fa-angle-right';
};
?> ?>
<aside class="sidebar"> <aside class="sidebar">
<div class="my-menu-hd" id="portalSidebarTitle"><?= esc($sidebarTitle) ?></div> <div class="my-menu-hd" id="portalSidebarTitle"><?= esc($sidebarTitle) ?></div>
@@ -22,11 +52,11 @@ $activeChildHref = strtolower(ltrim((string) ($govActiveChildHref ?? ''), '/'));
<li> <li>
<?php if ($child['href'] !== ''): ?> <?php if ($child['href'] !== ''): ?>
<a href="<?= esc($child['url']) ?>" class="<?= $isChildActive ? 'active' : '' ?>"> <a href="<?= esc($child['url']) ?>" class="<?= $isChildActive ? 'active' : '' ?>">
<?= esc($child['name']) ?> <?php if ($showSidebarIcons): ?><i class="fa-solid <?= esc($sidebarIconFor((string) $child['name']), 'attr') ?>" style="width:1.15em;margin-right:.45em;opacity:.85;"></i><?php endif; ?><?= esc($child['name']) ?>
</a> </a>
<?php else: ?> <?php else: ?>
<span class="menu-sub" style="opacity:.65;cursor:default;"> <span class="menu-sub" style="opacity:.65;cursor:default;">
<?= esc($child['name']) ?> <?php if ($showSidebarIcons): ?><i class="fa-solid <?= esc($sidebarIconFor((string) $child['name']), 'attr') ?>" style="width:1.15em;margin-right:.45em;opacity:.85;"></i><?php endif; ?><?= esc($child['name']) ?>
</span> </span>
<?php endif; ?> <?php endif; ?>
</li> </li>