fix(dashboard): page key를 DB 실제 key와 일치시켜 카드 표시 수정

s1. 접두어 제거, 크로스시스템 key를 accessKey/minRole로 전환하여
admin 계정에서 모든 시스템 카드가 정상 표시되도록 수정

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-13 19:59:52 +09:00
parent 12367dd3a1
commit 0fd202dcbb

View File

@@ -430,7 +430,7 @@
subdomain: 'tkfb',
path: '/pages/work/tbm.html',
color: '#d97706',
requirePageKey: 's1.work.tbm'
requirePageKey: 'work.tbm'
},
{
id: 'vacation',
@@ -444,7 +444,7 @@
subdomain: 'tkfb',
path: '/pages/attendance/vacation-management.html',
color: '#7c3aed',
requirePageKey: 's1.attendance.vacation_management'
requirePageKey: 'attendance.vacation_management'
}
];
@@ -489,13 +489,13 @@
// ===== Card Definitions =====
var SYSTEM_CARDS = [
{ id: 'factory', name: '공장관리', desc: '작업장 현황, TBM, 설비관리', icon: '\uD83C\uDFED', subdomain: 'tkfb', path: '/pages/dashboard.html', pageKey: 's1.dashboard', color: '#1a56db' },
{ id: 'factory', name: '공장관리', desc: '작업장 현황, TBM, 설비관리', icon: '\uD83C\uDFED', subdomain: 'tkfb', path: '/pages/dashboard.html', pageKey: 'dashboard', color: '#1a56db' },
{ id: 'report_sys', name: '신고', desc: '사건·사고 신고 접수', icon: '\uD83D\uDEA8', subdomain: 'tkreport', accessKey: 'system2', color: '#dc2626' },
{ id: 'quality', name: '부적합관리', desc: '부적합 이슈 추적·처리', icon: '\uD83D\uDCCA', subdomain: 'tkqc', pageKey: 'issues_dashboard', color: '#059669' },
{ id: 'purchase', name: '구매관리', desc: '자재 구매, 일용직 관리', icon: '\uD83D\uDED2', subdomain: 'tkpurchase', pageKey: 'purchasing_schedule', color: '#d97706' },
{ id: 'safety', name: '안전관리', desc: '안전 점검, 방문 관리', icon: '\uD83E\uDDBA', subdomain: 'tksafety', pageKey: 'safety_visit_management', color: '#7c3aed' },
{ id: 'quality', name: '부적합관리', desc: '부적합 이슈 추적·처리', icon: '\uD83D\uDCCA', subdomain: 'tkqc', accessKey: 'system3', color: '#059669' },
{ id: 'purchase', name: '구매관리', desc: '자재 구매, 일용직 관리', icon: '\uD83D\uDED2', subdomain: 'tkpurchase', color: '#d97706' },
{ id: 'safety', name: '안전관리', desc: '안전 점검, 방문 관리', icon: '\uD83E\uDDBA', subdomain: 'tksafety', color: '#7c3aed' },
{ id: 'support', name: '행정지원', desc: '전사 행정 업무 지원', icon: '\uD83C\uDFE2', subdomain: 'tksupport', comingSoon: true, color: '#6b7280' },
{ id: 'admin', name: '통합관리', desc: '사용자·권한 관리', icon: '\u2699\uFE0F', subdomain: 'tkuser', pageKey: 'tkuser.users', color: '#0891b2' }
{ id: 'admin', name: '통합관리', desc: '사용자·권한 관리', icon: '\u2699\uFE0F', subdomain: 'tkuser', minRole: 'admin', color: '#0891b2' }
];
// ===== Rendering =====
@@ -556,15 +556,21 @@
return a;
}
function isCardVisible(card, allowed, systemAccess) {
function isCardVisible(card, allowed, systemAccess, userRole) {
if (card.comingSoon) return true;
if (card.minRole) {
var roleOrder = ['user','leader','support_team','admin','system'];
var userIdx = roleOrder.indexOf(userRole);
var minIdx = roleOrder.indexOf(card.minRole);
if (userIdx < minIdx) return false;
}
if (card.pageKey && !allowed.has(card.pageKey)) return false;
if (card.accessKey && systemAccess[card.accessKey] === false) return false;
return true;
}
function renderSection(sectionId, gridId, cards, allowed, systemAccess, isSystem) {
var visible = cards.filter(function(c) { return isCardVisible(c, allowed, systemAccess); });
function renderSection(sectionId, gridId, cards, allowed, systemAccess, isSystem, userRole) {
var visible = cards.filter(function(c) { return isCardVisible(c, allowed, systemAccess, userRole); });
if (visible.length === 0) return;
var grid = document.getElementById(gridId);
@@ -601,11 +607,10 @@
// Fallback: show cards based on system_access
console.warn('page-access API error:', e);
if (systemAccess.system1 !== false) {
['s1.work.tbm', 's1.work.report_create', 's1.inspection.checkin',
's1.attendance.my_vacation_info', 's1.attendance.vacation_request',
's1.dashboard'].forEach(function(k) { allowed.add(k); });
['work.tbm', 'work.report_create', 'inspection.checkin',
'attendance.my_vacation_info', 'attendance.vacation_request',
'dashboard'].forEach(function(k) { allowed.add(k); });
}
if (systemAccess.system3 !== false) allowed.add('issues_dashboard');
}
// A: Welcome section
@@ -615,8 +620,9 @@
loadTodayStats(token, allowed);
// Render banners + system cards
var userRole = user.role || 'user';
loadBanners(token, allowed);
renderSection('systemSection', 'systemGrid', SYSTEM_CARDS, allowed, systemAccess, true);
renderSection('systemSection', 'systemGrid', SYSTEM_CARDS, allowed, systemAccess, true, userRole);
}
// ===== A: Welcome =====
@@ -678,7 +684,7 @@
var fetches = [];
// Attendance
if (allowed.has('s1.attendance.daily_status') || allowed.has('s1.attendance.vacation_management') || allowed.has('s1.dashboard')) {
if (allowed.has('attendance.daily') || allowed.has('attendance.vacation_management') || allowed.has('dashboard')) {
var idx = cards.length;
cards.push({ icon: '\uD83D\uDC77', label: '출근', value: '\u2013', color: '#1a56db', visible: true });
fetches.push(
@@ -695,7 +701,7 @@
}
// Work reports
if (allowed.has('s1.dashboard')) {
if (allowed.has('dashboard')) {
var idx2 = cards.length;
cards.push({ icon: '\uD83D\uDD27', label: '작업', value: '\u2013', color: '#059669', visible: true });
fetches.push(