feat(sort): replace compound sort options with atomic fields and multi-sort support (#2686)
* fix(sidebar): replace routerLinkActive with getter-based route matching to prevent stale highlights * feat(sort): replace compound sort options with atomic fields and add 6 new sort criteria
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<div>
|
||||
<ul class="layout-menu">
|
||||
@if (homeMenu$ | async; as homeMenu) {
|
||||
@for (item of homeMenu; track item; let i = $index) {
|
||||
@for (item of homeMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="home"></li>
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<ul class="layout-menu">
|
||||
@if (libraryMenu$ | async; as libraryMenu) {
|
||||
@for (item of libraryMenu; track item; let i = $index) {
|
||||
@for (item of libraryMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="library"></li>
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<ul class="layout-menu">
|
||||
@if (shelfMenu$ | async; as shelfMenu) {
|
||||
@for (item of shelfMenu; track item; let i = $index) {
|
||||
@for (item of shelfMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="shelf"></li>
|
||||
}
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
<ul class="layout-menu">
|
||||
@if (magicShelfMenu$ | async; as shelfMenu) {
|
||||
@for (item of shelfMenu; track item; let i = $index) {
|
||||
@for (item of shelfMenu; track item.label; let i = $index) {
|
||||
@if (!item.separator) {
|
||||
<li app-menuitem [item]="item" [index]="i" [root]="true" menuKey="magicShelf"></li>
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<div>
|
||||
<div
|
||||
class="menu-item-container"
|
||||
[class.active-route-container]="isRouteActive"
|
||||
(click)="triggerLink()"
|
||||
>
|
||||
@if ((item.routerLink && !item.items)) {
|
||||
@@ -39,9 +40,8 @@
|
||||
(click)="itemClick($event)"
|
||||
[ngClass]="item.class"
|
||||
class="menu-item-link"
|
||||
[class.active-route]="isRouteActive"
|
||||
[routerLink]="item.routerLink"
|
||||
routerLinkActive="active-route"
|
||||
[routerLinkActiveOptions]="item.routerLinkActiveOptions || { paths: 'exact', queryParams: 'ignored', matrixParams: 'ignored', fragment: 'ignored' }"
|
||||
[fragment]="item.fragment"
|
||||
[queryParamsHandling]="item.queryParamsHandling"
|
||||
[preserveFragment]="item.preserveFragment"
|
||||
@@ -94,7 +94,7 @@
|
||||
<div [@children]="isExpanded(key) ? 'expanded' : 'collapsed'" class="submenu-container">
|
||||
@if (item.items) {
|
||||
<ul>
|
||||
@for (child of item.items; track child; let i = $index) {
|
||||
@for (child of item.items; track child.routerLink?.[0] ?? child.label; let i = $index) {
|
||||
<li app-menuitem [item]="child" [index]="i" [parentKey]="key" [class]="child.badgeClass"></li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
:host(.active-menuitem) .menu-item-container {
|
||||
.menu-item-container.active-route-container {
|
||||
background-color: color-mix(in srgb, var(--p-primary-300), transparent 93%);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Component, ElementRef, HostBinding, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
||||
import {NavigationEnd, Router, RouterLink, RouterLinkActive} from '@angular/router';
|
||||
import {NavigationEnd, Router, RouterLink} from '@angular/router';
|
||||
import {animate, state, style, transition, trigger} from '@angular/animations';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {filter} from 'rxjs/operators';
|
||||
@@ -21,7 +21,6 @@ import {IconSelection} from '../../../service/icon-picker.service';
|
||||
styleUrls: ['./app.menuitem.component.scss'],
|
||||
imports: [
|
||||
RouterLink,
|
||||
RouterLinkActive,
|
||||
NgClass,
|
||||
Ripple,
|
||||
AsyncPipe,
|
||||
@@ -55,8 +54,15 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
|
||||
canManipulateLibrary: boolean = false;
|
||||
admin: boolean = false;
|
||||
expandedItems = new Set<string>();
|
||||
|
||||
get isRouteActive(): boolean {
|
||||
if (!this.item?.routerLink?.[0]) return false;
|
||||
return this.router.url.split('?')[0] === this.item.routerLink[0];
|
||||
}
|
||||
|
||||
menuSourceSubscription: Subscription;
|
||||
menuResetSubscription: Subscription;
|
||||
private routerSubscription: Subscription;
|
||||
|
||||
constructor(
|
||||
public router: Router,
|
||||
@@ -88,7 +94,7 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
|
||||
this.active = false;
|
||||
});
|
||||
|
||||
this.router.events.pipe(filter(event => event instanceof NavigationEnd))
|
||||
this.routerSubscription = this.router.events.pipe(filter(event => event instanceof NavigationEnd))
|
||||
.subscribe(() => {
|
||||
if (this.item.routerLink) {
|
||||
this.updateActiveStateFromRoute();
|
||||
@@ -112,6 +118,9 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
|
||||
if (this.menuResetSubscription) {
|
||||
this.menuResetSubscription.unsubscribe();
|
||||
}
|
||||
if (this.routerSubscription) {
|
||||
this.routerSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
toggleExpand(key: string) {
|
||||
@@ -181,8 +190,4 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
}
|
||||
|
||||
@HostBinding('class.active-menuitem')
|
||||
get activeClass() {
|
||||
return this.active && !this.root;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user