Updated app menu grouping structure
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Mats Paul Tončik
2026-06-30 08:46:15 +02:00
parent 9388ad9bdb
commit 05eb9a3b50
2 changed files with 67 additions and 53 deletions
@@ -41,49 +41,51 @@
</div>
<mat-nav-list class="nav-list">
@for (item of navItems; track item.label) {
@if (
(!item.adminOnly ||
credentialService.isEffectiveSuperAdmin() ||
credentialService.isEffectiveAdmin()) &&
(!item.superAdminOnly || credentialService.isEffectiveSuperAdmin())
) {
@if (item.type === 'link') {
@if (collapsed()) {
<a
mat-icon-button
class="nav-icon-button"
[routerLink]="item.disabled ? null : item.route"
[queryParams]="item.queryParams || null"
routerLinkActive="active"
[routerLinkActiveOptions]="navLinkActiveOptions"
[class.disabled]="item.disabled"
[matTooltip]="item.label"
matTooltipPosition="right"
[attr.aria-label]="item.label">
<mat-icon>{{ item.icon }}</mat-icon>
</a>
} @else {
<a
mat-list-item
[routerLink]="item.disabled ? null : item.route"
[queryParams]="item.queryParams || null"
routerLinkActive="active"
[routerLinkActiveOptions]="navLinkActiveOptions"
[class.disabled]="item.disabled">
<mat-icon matListItemIcon>{{ item.icon }}</mat-icon>
<span matListItemTitle>{{ item.label }}</span>
</a>
}
} @else if (item.type === 'separator') {
@for (itemGroup of navItemGroups; track $index) {
<div>
@if (
(!itemGroup.adminOnly ||
credentialService.isEffectiveSuperAdmin() ||
credentialService.isEffectiveAdmin()) &&
(!itemGroup.superAdminOnly ||
credentialService.isEffectiveSuperAdmin())
) {
<mat-divider></mat-divider>
@if (!collapsed()) {
<div class="nav-separator">
<span>{{ item.label }}</span>
<span>{{ itemGroup.label }}</span>
</div>
}
@for (item of itemGroup.items; track item.label) {
@if (collapsed()) {
<a
mat-icon-button
class="nav-icon-button"
[routerLink]="item.disabled ? null : item.route"
[queryParams]="item.queryParams || null"
routerLinkActive="active"
[routerLinkActiveOptions]="navLinkActiveOptions"
[class.disabled]="item.disabled"
[matTooltip]="item.label"
matTooltipPosition="right"
[attr.aria-label]="item.label">
<mat-icon>{{ item.icon }}</mat-icon>
</a>
} @else {
<a
mat-list-item
[routerLink]="item.disabled ? null : item.route"
[queryParams]="item.queryParams || null"
routerLinkActive="active"
[routerLinkActiveOptions]="navLinkActiveOptions"
[class.disabled]="item.disabled">
<mat-icon matListItemIcon>{{ item.icon }}</mat-icon>
<span matListItemTitle>{{ item.label }}</span>
</a>
}
}
}
}
</div>
}
</mat-nav-list>
@@ -16,7 +16,6 @@ import { MatDialog } from '@angular/material/dialog';
import { ConfirmationDialogComponent } from '../confirmation-dialog/confirmation-dialog.component';
type NavItem = {
type: 'link' | 'separator';
label: string;
icon: string;
route: string;
@@ -26,6 +25,13 @@ type NavItem = {
superAdminOnly?: boolean;
};
type NavItemGroup = {
label: string;
items: NavItem[];
adminOnly?: boolean;
superAdminOnly?: boolean;
};
@Component({
selector: 'app-menu',
imports: [
@@ -52,16 +58,15 @@ export class AppMenuComponent {
matrixParams: 'ignored',
fragment: 'ignored',
};
navItems: NavItem[] = [
{
type: 'link',
label: 'Dashboard',
icon: 'dashboard',
route: '/dashboard',
disabled: false,
},
{
type: 'link',
label: 'Personen',
icon: 'groups',
route: '/persons',
@@ -71,14 +76,12 @@ export class AppMenuComponent {
disabled: false,
},
{
type: 'link',
label: 'News',
icon: 'newspaper',
route: '/news',
disabled: false,
},
{
type: 'link',
label: 'Institutionen',
icon: 'apartment',
route: '/institutions',
@@ -92,7 +95,6 @@ export class AppMenuComponent {
},
},
{
type: 'link',
label: 'Projekte',
icon: 'work',
route: '/projects',
@@ -107,15 +109,6 @@ export class AppMenuComponent {
},
},
{
type: 'separator',
label: 'Verwaltung',
icon: '',
route: '',
disabled: false,
adminOnly: true,
},
{
type: 'link',
label: 'Accounts',
icon: 'manage_accounts',
route: '/accounts',
@@ -123,7 +116,6 @@ export class AppMenuComponent {
adminOnly: true,
},
{
type: 'link',
label: 'Organisationen',
icon: 'domain',
route: '/organizations',
@@ -131,6 +123,26 @@ export class AppMenuComponent {
superAdminOnly: true,
},
];
navItemGroups: NavItemGroup[] = [
{
label: 'Navigation',
items: this.navItems.filter(
(item) => !item.adminOnly && !item.superAdminOnly,
),
},
{
label: 'Administration',
items: this.navItems.filter(
(item) => item.adminOnly && !item.superAdminOnly,
),
adminOnly: true,
},
{
label: 'Super Administration',
items: this.navItems.filter((item) => item.superAdminOnly),
superAdminOnly: true,
},
];
constructor(
public credentialService: CredentialService,