feat(sidebar): виды пунктов меню (item/divider/group), restore и upsert по id
- схема sidebar_items: колонка kind (item|divider|group), pagenullable, label с дефолтом '', constraint種別 - миграция для существующих БД: ADD COLUMN kind, DROP NOT NULL page, SET DEFAULT label, пересоздание constraint - restore: upsert по id (обновление существующих, вставка новых, удаление отсутствующих вpayload) - normalizeRestoreData: kind валидируется, filter по kind/item требует page+label - фронт: добавление разделителя/группы, удаление по cid, порядок из DOM через _cid, payload с kind/id
This commit is contained in:
+3
-1
@@ -117,13 +117,15 @@ function buildSidebar(active) {
|
||||
if (a.section !== b.section) return a.section === 'base' ? -1 : 1;
|
||||
return (a.sort_order || 0) - (b.sort_order || 0);
|
||||
});
|
||||
const toNav = (i) => ({ page: i.page, label: i.label, icon: i.icon, badge: i.page === 'notifications', chatBadge: i.page === 'chat' });
|
||||
const toNav = (i) => ({ page: i.page, label: i.label, icon: i.icon, kind: i.kind || 'item', badge: i.page === 'notifications', chatBadge: i.page === 'chat' });
|
||||
base = sorted.filter(i => i.section === 'base' && i.enabled !== false).map(toNav);
|
||||
adminNav = sorted.filter(i => i.section === 'admin' && i.enabled !== false).map(toNav);
|
||||
}
|
||||
const userName = currentUser?.name || currentUser?.username || '';
|
||||
const roleLabel = isAdmin() ? 'Администратор' : 'Тутор';
|
||||
const renderItem = n => {
|
||||
if (n.kind === 'divider') return `<div class="nav-divider"></div>`;
|
||||
if (n.kind === 'group') return `<div class="nav-group-title">${esc(n.label)}</div>`;
|
||||
const isAct = n.page === active;
|
||||
const adminOnly = n.section === 'admin' || n.tutorVisible === false;
|
||||
const badgeHtml = n.badge ? `<span class="sidebar-badge" id="sidebarNotifyBadge" ${notifyUnread > 0 ? '' : 'hidden'}>${notifyUnread > 99 ? '99+' : notifyUnread}</span>` : '';
|
||||
|
||||
Reference in New Issue
Block a user