Update Navigation behaviour for Filial-Navigation

This commit is contained in:
Lorenz Hilpert
2023-05-31 15:58:19 +02:00
parent 31164befc9
commit d2e16ca256
3 changed files with 76 additions and 15 deletions

View File

@@ -96,9 +96,11 @@
</span>
<nav class="side-menu-group-nav">
<a
*ngIf="taskCalenderNavigation$ | async; let taskCalenderNavigation"
class="side-menu-group-item"
(click)="closeSideMenu(); focusSearchBox()"
[routerLink]="['/filiale', 'task-calendar']"
[routerLink]="taskCalenderNavigation.path"
[queryParams]="taskCalenderNavigation.queryParams"
routerLinkActive="active"
>
<span class="side-menu-group-item-icon">
@@ -108,7 +110,14 @@
Kalender
</span>
</a>
<a class="side-menu-group-item" (click)="closeSideMenu()" [routerLink]="['/filiale', 'assortment']" routerLinkActive="active">
<a
class="side-menu-group-item"
(click)="closeSideMenu()"
*ngIf="assortmentNavigation$ | async; let assortmentNavigation"
[routerLink]="assortmentNavigation.path"
[queryParams]="assortmentNavigation.queryParams"
routerLinkActive="active"
>
<span class="side-menu-group-item-icon">
<ui-svg-icon icon="shape-outline"></ui-svg-icon>
</span>
@@ -121,7 +130,9 @@
<a
class="side-menu-group-item"
(click)="closeSideMenu(); focusSearchBox()"
[routerLink]="['/filiale', 'goods', 'in']"
*ngIf="goodsInNavigation$ | async; let goodsInNavigation"
[routerLink]="goodsInNavigation.path"
[queryParams]="goodsInNavigation.queryParams"
routerLinkActive="active"
>
<span class="side-menu-group-item-icon">
@@ -193,7 +204,14 @@
</div>
</div>
<a class="side-menu-group-item" (click)="closeSideMenu()" [routerLink]="['/filiale', 'remission']" routerLinkActive="active">
<a
class="side-menu-group-item"
(click)="closeSideMenu()"
*ngIf="remissionNavigation$ | async; let remissionNavigation"
[routerLink]="remissionNavigation.path"
[queryParams]="remissionNavigation.queryParams"
routerLinkActive="active"
>
<span class="side-menu-group-item-icon">
<ui-svg-icon icon="assignment-return"></ui-svg-icon>
</span>
@@ -204,8 +222,10 @@
<a
class="side-menu-group-item"
*ngIf="packageInspectionNavigation$ | async; let packageInspectionNavigation"
(click)="closeSideMenu(); fetchAndOpenPackages()"
[routerLink]="['/filiale', 'package-inspection']"
[routerLink]="packageInspectionNavigation.path"
[queryParams]="packageInspectionNavigation.queryParams"
routerLinkActive="active"
>
<span class="side-menu-group-item-icon">

View File

@@ -10,6 +10,8 @@ import { RouterTestingModule } from '@angular/router/testing';
import { IconRegistry } from '@ui/icon';
import { Router } from '@angular/router';
import { ProductCatalogNavigationService } from '@shared/services';
import { Config } from '@core/config';
import { BreadcrumbService } from '@core/breadcrumb';
describe('ShellSideMenuComponent', () => {
let spectator: Spectator<ShellSideMenuComponent>;
@@ -17,7 +19,7 @@ describe('ShellSideMenuComponent', () => {
const createComponent = createComponentFactory({
component: ShellSideMenuComponent,
imports: [RouterTestingModule],
mocks: [ShellService, AuthService, WrongDestinationModalService, IconRegistry],
mocks: [ShellService, AuthService, WrongDestinationModalService, IconRegistry, Config, BreadcrumbService],
providers: [
{
provide: ApplicationService,

View File

@@ -10,6 +10,8 @@ import { EnvironmentService } from '@core/environment';
import { ProductCatalogNavigationService } from '@shared/services';
import { CommonModule, DOCUMENT } from '@angular/common';
import { UiIconModule } from '@ui/icon';
import { Config } from '@core/config';
import { BreadcrumbService } from '@core/breadcrumb';
@Component({
selector: 'shell-side-menu',
@@ -61,15 +63,30 @@ export class ShellSideMenuComponent {
})
);
// customerOrdersPath$ = this.customerBasePath$.pipe(
// map((basePath) => {
// if (this.isTablet) {
// return [basePath, 'order'];
// } else {
// return [basePath, 'order', { outlets: { main: null, left: 'search', right: 'filter' } }];
// }
// })
// );
taskCalenderNavigation$ = this.getLastNavigationByProcessId(this._config.get('process.ids.task-calendar'), {
path: ['/filiale', 'task-calendar'],
queryParams: {},
});
assortmentNavigation$ = this.getLastNavigationByProcessId(this._config.get('process.ids.assortment'), {
path: ['/filiale', 'assortment'],
queryParams: {},
});
goodsInNavigation$ = this.getLastNavigationByProcessId(this._config.get('process.ids.goodsIin'), {
path: ['/filiale', 'goods', 'in'],
queryParams: {},
});
remissionNavigation$ = this.getLastNavigationByProcessId(this._config.get('process.ids.remission'), {
path: ['/filiale', 'remission'],
queryParams: {},
});
packageInspectionNavigation$ = this.getLastNavigationByProcessId(this._config.get('process.ids.packageInspection'), {
path: ['/filiale', 'package-inspection'],
queryParams: {},
});
constructor(
private _shellService: ShellService,
@@ -80,9 +97,31 @@ export class ShellSideMenuComponent {
private readonly _wrongDestinationModalService: WrongDestinationModalService,
private _environment: EnvironmentService,
private _catalogNavigationService: ProductCatalogNavigationService,
private _config: Config,
private _breadcrumbService: BreadcrumbService,
@Inject(DOCUMENT) private readonly _document: Document
) {}
getLastNavigationByProcessId(id: number, fallback?: { path: string[]; queryParams: any }) {
return this._breadcrumbService.getBreadcrumbByKey$(id)?.pipe(
map((breadcrumbs) => {
if (!breadcrumbs.length) {
return fallback;
}
const lastCrumb = breadcrumbs.reduce((last, current) => {
if (last.changed > current.changed) {
return last;
} else {
return current;
}
}, breadcrumbs[0]);
return { path: lastCrumb.path, queryParams: lastCrumb.params };
})
);
}
closeSideMenu() {
this._shellService.closeSideMenu();
}