Bugfix Navigation and Process Creation

This commit is contained in:
Lorenz Hilpert
2023-10-10 14:03:47 +02:00
parent 5cdbbb995f
commit 25d3adc28c
12 changed files with 79 additions and 42 deletions

View File

@@ -24,7 +24,7 @@ import { BranchSectionResolver, CustomerSectionResolver, ProcessIdResolver } fro
import { TokenLoginComponent, TokenLoginModule } from './token-login';
import { ApplicationService } from '@core/application';
import { ProcessIdGuard } from './guards/process-id.guard';
import { ActivateProcessIdGuard } from './guards/activate-process-id.guard';
import { ActivateProcessIdGuard, ActivateProcessIdWithConfigKeyGuard } from './guards/activate-process-id.guard';
const routes: Routes = [
{
@@ -100,17 +100,6 @@ const routes: Routes = [
canActivate: [ActivateProcessIdGuard],
loadChildren: () => import('@page/pickup-shelf').then((m) => m.PickupShelfOutModule),
},
// {
// path: 'goods/out',
// loadChildren: () => import('@page/goods-out').then((m) => m.GoodsOutModule),
// canActivate: [CanActivateGoodsOutGuard],
// },
// {
// path: ':processId/goods/out',
// loadChildren: () => import('@page/goods-out').then((m) => m.GoodsOutModule),
// canActivate: [CanActivateGoodsOutWithProcessIdGuard],
// resolve: { processId: ProcessIdResolver },
// },
{ path: '**', redirectTo: 'dashboard', pathMatch: 'full' },
],
resolve: { section: CustomerSectionResolver },
@@ -126,15 +115,15 @@ const routes: Routes = [
},
{
path: 'pickup-shelf',
canActivate: [ProcessIdGuard],
canActivate: [ActivateProcessIdWithConfigKeyGuard('pickupShelf')],
// NOTE: This is a workaround for the canActivate guard not being called
loadChildren: () => import('@page/pickup-shelf').then((m) => m.PickupShelfInModule),
},
// {
// path: 'goods/in',
// loadChildren: () => import('@page/goods-in').then((m) => m.GoodsInModule),
// canActivate: [CanActivateGoodsInGuard],
// },
{
path: 'goods/in',
loadChildren: () => import('@page/goods-in').then((m) => m.GoodsInModule),
canActivate: [CanActivateGoodsInGuard],
},
{
path: 'remission',
loadChildren: () => import('@page/remission').then((m) => m.PageRemissionModule),

View File

@@ -1,6 +1,7 @@
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router';
import { ApplicationService } from '@core/application';
import { Config } from '@core/config';
import { take } from 'rxjs/operators';
export const ActivateProcessIdGuard: CanActivateFn = async (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
@@ -25,3 +26,21 @@ export const ActivateProcessIdGuard: CanActivateFn = async (route: ActivatedRout
return true;
};
export const ActivateProcessIdWithConfigKeyGuard: (key: string) => CanActivateFn = (key) => async (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
) => {
const application = inject(ApplicationService);
const config = inject(Config);
const processId = config.get(`process.ids.${key}`);
if (isNaN(processId)) {
return false;
}
application.activateProcess(processId);
return true;
};

View File

@@ -67,7 +67,8 @@
"taskCalendar": 3000,
"remission": 4000,
"packageInspection": 5000,
"assortment": 6000
"assortment": 6000,
"pickupShelf": 7000
}
},
"checkForUpdates": 3600000,

View File

@@ -66,7 +66,8 @@
"taskCalendar": 3000,
"remission": 4000,
"packageInspection": 5000,
"assortment": 6000
"assortment": 6000,
"pickupShelf": 7000
}
},
"checkForUpdates": 900000,

View File

@@ -68,7 +68,8 @@
"taskCalendar": 3000,
"remission": 4000,
"packageInspection": 5000,
"assortment": 6000
"assortment": 6000,
"pickupShelf": 7000
}
},
"checkForUpdates": 3600000,

View File

@@ -67,7 +67,8 @@
"taskCalendar": 3000,
"remission": 4000,
"packageInspection": 5000,
"assortment": 6000
"assortment": 6000,
"pickupShelf": 7000
}
},
"checkForUpdates": 3600000,

View File

@@ -67,7 +67,8 @@
"taskCalendar": 3000,
"remission": 4000,
"packageInspection": 5000,
"assortment": 6000
"assortment": 6000,
"pickupShelf": 7000
}
},
"checkForUpdates": 3600000,

View File

@@ -68,7 +68,8 @@
"taskCalendar": 3000,
"remission": 4000,
"packageInspection": 5000,
"assortment": 6000
"assortment": 6000,
"pickupShelf": 7000
}
},
"checkForUpdates": 3600000,

View File

@@ -81,13 +81,15 @@ export abstract class PickupShelfBaseComponent implements OnInit {
await this._checkAndUpdateHistoryBreadcrumb(data);
}
abstract getProcessId(): number;
abstract getSection(): 'customer' | 'branch';
/**
* Checks if the processId changed and updates the store if necessary.
*/
private _checkAndUpdateProcessId(): number | undefined {
const processIdStr = this.activatedRoute.snapshot.params.processId ?? String(this.config.get('process.ids.goodsIn'));
const processId = Number(processIdStr);
const processId = this.getProcessId();
if (processId !== this.listStore.processId) {
this.listStore.setProcessId(processId);
@@ -168,7 +170,7 @@ export abstract class PickupShelfBaseComponent implements OnInit {
name,
tags: ['pickup-shelf', 'main'],
path: path?.path,
section: 'customer',
section: this.getSection(),
params: { ...queryParams, ...path?.queryParams },
};
this.breadcrumbService.addBreadcrumb(mainBreadcrumb);
@@ -202,7 +204,7 @@ export abstract class PickupShelfBaseComponent implements OnInit {
name,
tags: ['pickup-shelf', 'list'],
path: path?.path,
section: 'customer',
section: this.getSection(),
params: { ...queryParams, ...path?.queryParams },
};
this.breadcrumbService.addOrUpdateBreadcrumbIfNotExists(listBreadcrumb);
@@ -232,7 +234,7 @@ export abstract class PickupShelfBaseComponent implements OnInit {
name,
tags: ['pickup-shelf', 'filter'],
path: path?.path,
section: 'customer',
section: this.getSection(),
params: { ...queryParams, ...path?.queryParams },
};
this.breadcrumbService.addOrUpdateBreadcrumbIfNotExists(filterBreadcrumb);
@@ -264,7 +266,7 @@ export abstract class PickupShelfBaseComponent implements OnInit {
name,
tags: ['pickup-shelf', 'details'],
path: path?.path,
section: 'customer',
section: this.getSection(),
params: { ...queryParams, ...path?.queryParams },
};
this.breadcrumbService.addOrUpdateBreadcrumbIfNotExists(detailBreadcrumb);
@@ -296,7 +298,7 @@ export abstract class PickupShelfBaseComponent implements OnInit {
name,
tags: ['pickup-shelf', 'edit'],
path: path?.path,
section: 'customer',
section: this.getSection(),
params: { ...queryParams, ...path?.queryParams },
};
this.breadcrumbService.addOrUpdateBreadcrumbIfNotExists(editBreadcrumb);
@@ -328,7 +330,7 @@ export abstract class PickupShelfBaseComponent implements OnInit {
name,
tags: ['pickup-shelf', 'history'],
path: path?.path,
section: 'customer',
section: this.getSection(),
params: { ...queryParams, ...path?.queryParams },
};
this.breadcrumbService.addOrUpdateBreadcrumbIfNotExists(historyBreadcrumb);

View File

@@ -13,6 +13,7 @@ import { GetNameForBreadcrumbData, GetPathForBreadcrumbData, PickupShelfBaseComp
import { DBHOrderItemListItemDTO } from '@swagger/oms';
import { Observable, of } from 'rxjs';
import { take } from 'rxjs/operators';
import { ApplicationService } from '@core/application';
@Component({
selector: 'page-pickup-shelf-in',
@@ -31,16 +32,26 @@ import { take } from 'rxjs/operators';
],
})
export class PickupShelfInComponent extends PickupShelfBaseComponent {
application = inject(ApplicationService);
private _pickupShelfInNavigationService = inject(PickupShelfInNavigationService);
get pickUpShelfInKey() {
return this._config.get('process.ids.goodsIn');
return this._config.get('process.ids.pickupShelf');
}
constructor(private _config: Config) {
super();
}
getProcessId(): number {
return this.application.activatedProcessId;
}
getSection(): 'customer' | 'branch' {
return 'branch';
}
getNameForMainBreadcrumb(data: { queryParams: Record<string, string> }): string | Promise<string> {
return 'Einbuchen';
}

View File

@@ -37,6 +37,16 @@ export class PickupShelfOutComponent extends PickupShelfBaseComponent {
super();
}
getProcessId(): number {
const processIdStr = this.activatedRoute.snapshot.params.processId;
return Number(processIdStr);
}
getSection(): 'customer' | 'branch' {
return 'customer';
}
getNameForMainBreadcrumb(data: { processId: number; queryParams: Record<string, string> }): string | Promise<string> {
return 'Warenausgabe';
}

View File

@@ -116,15 +116,15 @@ export class ShellSideMenuComponent {
queryParams: {},
});
pickUpShelfInRoutePath$ = this.getLastNavigationByProcessId(this._config.get('process.ids.goodsIn'), {
path: this._pickUpShelfInNavigation.defaultRoute().path,
queryParams: {},
});
pickUpShelfInRoutePath$ = this.getLastNavigationByProcessId(
this._config.get('process.ids.pickupShelf'),
this._pickUpShelfInNavigation.defaultRoute()
);
pickUpShelfInListRoutePath$ = this.getLastNavigationByProcessId(this._config.get('process.ids.goodsIn'), {
path: this._pickUpShelfInNavigation.listRoute().path,
queryParams: {},
});
pickUpShelfInListRoutePath$ = this.getLastNavigationByProcessId(
this._config.get('process.ids.pickupShelf'),
this._pickUpShelfInNavigation.listRoute()
);
remissionNavigation$ = this.getLastNavigationByProcessId(this._config.get('process.ids.remission'), {
path: ['/filiale', 'remission'],