mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
#3272 Refactoring WA, Revert Changes - No multiple WA processes possible
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
|||||||
CanActivateCustomerWithProcessIdGuard,
|
CanActivateCustomerWithProcessIdGuard,
|
||||||
CanActivateGoodsInGuard,
|
CanActivateGoodsInGuard,
|
||||||
CanActivateGoodsOutGuard,
|
CanActivateGoodsOutGuard,
|
||||||
CanActivateGoodsOutWithProcessIdGuard,
|
|
||||||
CanActivateProductGuard,
|
CanActivateProductGuard,
|
||||||
CanActivateProductWithProcessIdGuard,
|
CanActivateProductWithProcessIdGuard,
|
||||||
CanActivateRemissionGuard,
|
CanActivateRemissionGuard,
|
||||||
@@ -79,12 +78,6 @@ const routes: Routes = [
|
|||||||
loadChildren: () => import('@page/goods-out').then((m) => m.GoodsOutModule),
|
loadChildren: () => import('@page/goods-out').then((m) => m.GoodsOutModule),
|
||||||
canActivate: [CanActivateGoodsOutGuard],
|
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' },
|
{ path: '**', redirectTo: 'dashboard', pathMatch: 'full' },
|
||||||
],
|
],
|
||||||
resolve: { section: CustomerSectionResolver },
|
resolve: { section: CustomerSectionResolver },
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
|
|
||||||
import { ApplicationProcess, ApplicationService } from '@core/application';
|
|
||||||
import { first } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
|
||||||
export class CanActivateGoodsOutWithProcessIdGuard implements CanActivate {
|
|
||||||
constructor(private readonly _applicationService: ApplicationService) {}
|
|
||||||
|
|
||||||
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
|
||||||
const process = await this._applicationService
|
|
||||||
.getProcessById$(+route.params.processId)
|
|
||||||
.pipe(first())
|
|
||||||
.toPromise();
|
|
||||||
|
|
||||||
if (!process) {
|
|
||||||
const processes = await this._applicationService.getProcesses$('customer').pipe(first()).toPromise();
|
|
||||||
await this._applicationService.createProcess({
|
|
||||||
id: +route.params.processId,
|
|
||||||
type: 'goods-out',
|
|
||||||
section: 'customer',
|
|
||||||
name: `Warenausgabe ${this.processNumber(processes)}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this._applicationService.activateProcess(+route.params.processId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
processNumber(processes: ApplicationProcess[]) {
|
|
||||||
const processNumbers = processes?.map((process) => Number(process?.name?.replace(/\D/g, '')));
|
|
||||||
return !!processNumbers && processNumbers?.length > 0 ? Math.max(...processNumbers) + 1 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,44 +6,19 @@ import { first, map } from 'rxjs/operators';
|
|||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class CanActivateGoodsOutGuard implements CanActivate {
|
export class CanActivateGoodsOutGuard implements CanActivate {
|
||||||
constructor(private readonly _applicationService: ApplicationService, private readonly _router: Router) {}
|
constructor(private readonly _applicationService: ApplicationService, private readonly _config: Config) {}
|
||||||
|
|
||||||
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||||
const processesIds = await this._applicationService
|
const process = await this._applicationService.getProcessById$(this._config.get('process.ids.goodsOut')).pipe(first()).toPromise();
|
||||||
.getProcesses$('customer')
|
if (!process) {
|
||||||
.pipe(
|
await this._applicationService.createProcess({
|
||||||
first(),
|
id: this._config.get('process.ids.goodsOut'),
|
||||||
map((p) => {
|
type: 'goods-out',
|
||||||
return p.filter((process) => process.type === 'goods-out').map((process) => +process.name.replace('Warenausgabe', '').trim());
|
section: 'customer',
|
||||||
})
|
name: 'Warenausgabe',
|
||||||
)
|
});
|
||||||
.toPromise();
|
|
||||||
|
|
||||||
let lastActivatedProcessId = (
|
|
||||||
await this._applicationService.getLastActivatedProcessWithSectionAndType$('customer', 'goods-out').pipe(first()).toPromise()
|
|
||||||
)?.id;
|
|
||||||
|
|
||||||
console.log(processesIds);
|
|
||||||
|
|
||||||
// if (!lastActivatedProcessId) {
|
|
||||||
lastActivatedProcessId = Date.now();
|
|
||||||
await this._applicationService.createProcess({
|
|
||||||
id: lastActivatedProcessId,
|
|
||||||
type: 'goods-out',
|
|
||||||
section: 'customer',
|
|
||||||
name: `Warenausgabe ${Math.max(...processesIds, 0) + 1}`,
|
|
||||||
});
|
|
||||||
// }
|
|
||||||
|
|
||||||
await this._router.navigate(this.getUrlFromSnapshot(route, ['/kunde', String(lastActivatedProcessId)]));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
getUrlFromSnapshot(route: ActivatedRouteSnapshot, url: string[] = []): string[] {
|
|
||||||
url.push(...route.url.map((segment) => segment.path));
|
|
||||||
if (route.firstChild) {
|
|
||||||
return this.getUrlFromSnapshot(route.firstChild, url);
|
|
||||||
}
|
}
|
||||||
return url.filter((segment) => !!segment);
|
this._applicationService.activateProcess(this._config.get('process.ids.goodsOut'));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ export * from './can-activate-cart.guard';
|
|||||||
export * from './can-activate-customer-with-process-id.guard';
|
export * from './can-activate-customer-with-process-id.guard';
|
||||||
export * from './can-activate-customer.guard';
|
export * from './can-activate-customer.guard';
|
||||||
export * from './can-activate-goods-in.guard';
|
export * from './can-activate-goods-in.guard';
|
||||||
export * from './can-activate-goods-out-with-process-id.guard';
|
|
||||||
export * from './can-activate-goods-out.guard';
|
export * from './can-activate-goods-out.guard';
|
||||||
export * from './can-activate-product-with-process-id.guard';
|
export * from './can-activate-product-with-process-id.guard';
|
||||||
export * from './can-activate-product.guard';
|
export * from './can-activate-product.guard';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { BreadcrumbService } from '@core/breadcrumb';
|
import { BreadcrumbService } from '@core/breadcrumb';
|
||||||
|
import { Config } from '@core/config';
|
||||||
import { DomainGoodsService, DomainOmsService, OrderItemsContext } from '@domain/oms';
|
import { DomainGoodsService, DomainOmsService, OrderItemsContext } from '@domain/oms';
|
||||||
import { ComponentStore, tapResponse } from '@ngrx/component-store';
|
import { ComponentStore, tapResponse } from '@ngrx/component-store';
|
||||||
import { ListResponseArgsOfOrderItemListItemDTO, OrderItemListItemDTO, OrderItemProcessingStatusValue } from '@swagger/oms';
|
import { ListResponseArgsOfOrderItemListItemDTO, OrderItemListItemDTO, OrderItemProcessingStatusValue } from '@swagger/oms';
|
||||||
@@ -47,12 +48,6 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
|
|||||||
shareReplay()
|
shareReplay()
|
||||||
);
|
);
|
||||||
|
|
||||||
get processId() {
|
|
||||||
return +this._activatedRoute.snapshot.parent.data.processId;
|
|
||||||
}
|
|
||||||
|
|
||||||
processId$ = this._activatedRoute.parent.data.pipe(map((params) => +params.processId));
|
|
||||||
|
|
||||||
private _onDestroy$ = new Subject();
|
private _onDestroy$ = new Subject();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -60,7 +55,8 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
|
|||||||
private _domainGoodsInService: DomainGoodsService,
|
private _domainGoodsInService: DomainGoodsService,
|
||||||
private _omsService: DomainOmsService,
|
private _omsService: DomainOmsService,
|
||||||
private _breadcrumb: BreadcrumbService,
|
private _breadcrumb: BreadcrumbService,
|
||||||
private _router: Router
|
private _router: Router,
|
||||||
|
private readonly _config: Config
|
||||||
) {
|
) {
|
||||||
super({
|
super({
|
||||||
fetching: false,
|
fetching: false,
|
||||||
@@ -89,7 +85,7 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
|
|||||||
async updateBreadcrumb(item: OrderItemListItemDTO) {
|
async updateBreadcrumb(item: OrderItemListItemDTO) {
|
||||||
if (item) {
|
if (item) {
|
||||||
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
||||||
key: this.processId,
|
key: this._config.get('process.ids.goodsOut'),
|
||||||
name: item?.compartmentCode || item?.orderNumber,
|
name: item?.compartmentCode || item?.orderNumber,
|
||||||
path: this.getDetailsPath(item),
|
path: this.getDetailsPath(item),
|
||||||
section: 'customer',
|
section: 'customer',
|
||||||
@@ -99,7 +95,10 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
|
|||||||
}
|
}
|
||||||
|
|
||||||
async removeBreadcrumbs() {
|
async removeBreadcrumbs() {
|
||||||
const editCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(this.processId, ['goods-out', 'edit']).pipe(first()).toPromise();
|
const editCrumbs = await this._breadcrumb
|
||||||
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'edit'])
|
||||||
|
.pipe(first())
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
editCrumbs.forEach((crumb) => {
|
editCrumbs.forEach((crumb) => {
|
||||||
this._breadcrumb.removeBreadcrumb(crumb.id, true);
|
this._breadcrumb.removeBreadcrumb(crumb.id, true);
|
||||||
@@ -108,7 +107,7 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
|
|||||||
|
|
||||||
async removeDetailsCrumbs() {
|
async removeDetailsCrumbs() {
|
||||||
const detailsCrumbs = await this._breadcrumb
|
const detailsCrumbs = await this._breadcrumb
|
||||||
.getBreadcrumbsByKeyAndTags$(this.processId, ['goods-out', 'details'])
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'details'])
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.toPromise();
|
.toPromise();
|
||||||
|
|
||||||
@@ -159,7 +158,7 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigateToLandingPage() {
|
navigateToLandingPage() {
|
||||||
this._router.navigate([`/kunde/${this.processId}/goods/out`]);
|
this._router.navigate([`/kunde/goods/out`]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async actionHandled(handler: { orderItemsContext: OrderItemsContext; command: string; navigation: 'details' | 'main' | 'reservation' }) {
|
async actionHandled(handler: { orderItemsContext: OrderItemsContext; command: string; navigation: 'details' | 'main' | 'reservation' }) {
|
||||||
@@ -174,13 +173,13 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
|
|||||||
|
|
||||||
getDetailsPath(item: OrderItemListItemDTO) {
|
getDetailsPath(item: OrderItemListItemDTO) {
|
||||||
return item?.compartmentCode
|
return item?.compartmentCode
|
||||||
? `/kunde/${this.processId}/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
|
? `/kunde/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
|
||||||
: `/kunde/${this.processId}/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
|
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEditPath(item: OrderItemListItemDTO) {
|
getEditPath(item: OrderItemListItemDTO) {
|
||||||
return item?.compartmentCode
|
return item?.compartmentCode
|
||||||
? `/kunde/${this.processId}/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}/edit`
|
? `/kunde/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}/edit`
|
||||||
: `/kunde/${this.processId}/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}/edit`;
|
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}/edit`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { BreadcrumbService } from '@core/breadcrumb';
|
import { BreadcrumbService } from '@core/breadcrumb';
|
||||||
|
import { Config } from '@core/config';
|
||||||
import { DomainGoodsService } from '@domain/oms';
|
import { DomainGoodsService } from '@domain/oms';
|
||||||
import { combineLatest, Observable } from 'rxjs';
|
import { combineLatest, Observable } from 'rxjs';
|
||||||
import { map, shareReplay, switchMap, withLatestFrom } from 'rxjs/operators';
|
import { map, shareReplay, switchMap, withLatestFrom } from 'rxjs/operators';
|
||||||
@@ -12,12 +13,6 @@ import { map, shareReplay, switchMap, withLatestFrom } from 'rxjs/operators';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class GoodsOutEditComponent implements OnInit {
|
export class GoodsOutEditComponent implements OnInit {
|
||||||
get processId() {
|
|
||||||
return +this._activatedRoute.snapshot.parent.data.processId;
|
|
||||||
}
|
|
||||||
|
|
||||||
processId$ = this._activatedRoute.parent.data.pipe(map((params) => +params.processId));
|
|
||||||
|
|
||||||
orderNumber$: Observable<string> = this._activatedRoute.params.pipe(
|
orderNumber$: Observable<string> = this._activatedRoute.params.pipe(
|
||||||
map((params) => decodeURIComponent(params.orderNumber ?? '') || undefined)
|
map((params) => decodeURIComponent(params.orderNumber ?? '') || undefined)
|
||||||
);
|
);
|
||||||
@@ -43,7 +38,8 @@ export class GoodsOutEditComponent implements OnInit {
|
|||||||
private _activatedRoute: ActivatedRoute,
|
private _activatedRoute: ActivatedRoute,
|
||||||
private _breadcrumb: BreadcrumbService,
|
private _breadcrumb: BreadcrumbService,
|
||||||
private _domainGoodsInService: DomainGoodsService,
|
private _domainGoodsInService: DomainGoodsService,
|
||||||
private _router: Router
|
private _router: Router,
|
||||||
|
private readonly _config: Config
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -55,11 +51,11 @@ export class GoodsOutEditComponent implements OnInit {
|
|||||||
const compartmentCode = this._activatedRoute.snapshot.params.compartmentCode;
|
const compartmentCode = this._activatedRoute.snapshot.params.compartmentCode;
|
||||||
const processingStatus = this._activatedRoute.snapshot.params.processingStatus;
|
const processingStatus = this._activatedRoute.snapshot.params.processingStatus;
|
||||||
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
||||||
key: this.processId,
|
key: this._config.get('process.ids.goodsOut'),
|
||||||
name: 'Bearbeiten',
|
name: 'Bearbeiten',
|
||||||
path: compartmentCode
|
path: compartmentCode
|
||||||
? `/kunde/${this.processId}/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}/edit`
|
? `/kunde/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}/edit`
|
||||||
: `/kunde/${this.processId}/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}/edit`,
|
: `/kunde/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}/edit`,
|
||||||
section: 'customer',
|
section: 'customer',
|
||||||
tags: ['goods-out', 'edit', compartmentCode || orderNumber],
|
tags: ['goods-out', 'edit', compartmentCode || orderNumber],
|
||||||
});
|
});
|
||||||
@@ -70,9 +66,7 @@ export class GoodsOutEditComponent implements OnInit {
|
|||||||
const compartmentCode = this._activatedRoute.snapshot.params.compartmentCode;
|
const compartmentCode = this._activatedRoute.snapshot.params.compartmentCode;
|
||||||
const processingStatus = options?.processingStatus ? options.processingStatus : this._activatedRoute.snapshot.params.processingStatus;
|
const processingStatus = options?.processingStatus ? options.processingStatus : this._activatedRoute.snapshot.params.processingStatus;
|
||||||
compartmentCode
|
compartmentCode
|
||||||
? this._router.navigate([
|
? this._router.navigate([`/kunde/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`])
|
||||||
`/kunde/${this.processId}/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`,
|
: this._router.navigate([`/kunde/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}`]);
|
||||||
])
|
|
||||||
: this._router.navigate([`/kunde/${this.processId}/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}`]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, ChangeDetectionStrategy, Output, EventEmitter, ChangeDetectorRef, OnInit, OnDestroy, Input } from '@angular/core';
|
import { Component, ChangeDetectionStrategy, Output, EventEmitter, ChangeDetectorRef, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { BreadcrumbService } from '@core/breadcrumb';
|
import { BreadcrumbService } from '@core/breadcrumb';
|
||||||
import { Config } from '@core/config';
|
import { Config } from '@core/config';
|
||||||
@@ -24,9 +24,6 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
message: string;
|
message: string;
|
||||||
|
|
||||||
@Input()
|
|
||||||
processId: number;
|
|
||||||
|
|
||||||
private _onDestroy$ = new Subject();
|
private _onDestroy$ = new Subject();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -77,7 +74,7 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
|
|||||||
const orderItem = result.result[0];
|
const orderItem = result.result[0];
|
||||||
this._router.navigate([this.getDetailsPath(orderItem)]);
|
this._router.navigate([this.getDetailsPath(orderItem)]);
|
||||||
} else {
|
} else {
|
||||||
this._router.navigate(['/kunde', this.processId, 'goods', 'out', 'results'], {
|
this._router.navigate(['/kunde', 'goods', 'out', 'results'], {
|
||||||
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
|
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -91,14 +88,14 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this._goodsOutSearchStore.search({});
|
this._goodsOutSearchStore.search();
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateBreadcrumb() {
|
async updateBreadcrumb() {
|
||||||
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
||||||
key: this.processId,
|
key: this._config.get('process.ids.goodsOut'),
|
||||||
name: 'Warenausgabe',
|
name: 'Warenausgabe',
|
||||||
path: `/kunde/${this.processId}/goods/out`,
|
path: `/kunde/goods/out`,
|
||||||
tags: ['goods-out', 'main', 'filter'],
|
tags: ['goods-out', 'main', 'filter'],
|
||||||
section: 'customer',
|
section: 'customer',
|
||||||
params: this._goodsOutSearchStore.filter?.getQueryParams(),
|
params: this._goodsOutSearchStore.filter?.getQueryParams(),
|
||||||
@@ -112,7 +109,7 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
getDetailsPath(item: OrderItemListItemDTO) {
|
getDetailsPath(item: OrderItemListItemDTO) {
|
||||||
return item?.compartmentCode
|
return item?.compartmentCode
|
||||||
? `/kunde/${this.processId}/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
|
? `/kunde/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
|
||||||
: `/kunde/${this.processId}/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
|
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
<shell-filter-overlay #shellFilterOverlay>
|
<shell-filter-overlay #shellFilterOverlay>
|
||||||
<page-goods-out-search-filter
|
<page-goods-out-search-filter
|
||||||
[processId]="processId$ | async"
|
|
||||||
*ngIf="showFilterOverlay"
|
*ngIf="showFilterOverlay"
|
||||||
(close)="toggleFilterOverlay(); shellFilterOverlay.close()"
|
(close)="toggleFilterOverlay(); shellFilterOverlay.close()"
|
||||||
></page-goods-out-search-filter>
|
></page-goods-out-search-filter>
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ export class GoodsOutSearchComponent implements OnInit, OnDestroy {
|
|||||||
map(([filter, initialFilter]) => !isEqual(filter?.getQueryParams(), initialFilter?.getQueryParams()))
|
map(([filter, initialFilter]) => !isEqual(filter?.getQueryParams(), initialFilter?.getQueryParams()))
|
||||||
);
|
);
|
||||||
|
|
||||||
processId$ = this._activatedRoute.data.pipe(map((data) => +data.processId));
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _goodsOutSearchStore: GoodsOutSearchStore,
|
private _goodsOutSearchStore: GoodsOutSearchStore,
|
||||||
private _breadcrumb: BreadcrumbService,
|
private _breadcrumb: BreadcrumbService,
|
||||||
@@ -55,22 +53,20 @@ export class GoodsOutSearchComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._goodsOutSearchStore.loadSettings();
|
this._goodsOutSearchStore.loadSettings();
|
||||||
|
this._activatedRoute.queryParams.pipe(takeUntil(this._onDestroy$)).subscribe((params) => {
|
||||||
this.processId$.pipe(takeUntil(this._onDestroy$), withLatestFrom(this._activatedRoute.queryParams)).subscribe(([processId, params]) => {
|
// Reset Filter when query params are empty
|
||||||
if (params && Object.keys(params).length === 0) {
|
if (params && Object.keys(params).length === 0) {
|
||||||
this._goodsOutSearchStore.setQueryParams(params);
|
this._goodsOutSearchStore.setQueryParams(params);
|
||||||
this._goodsOutSearchStore.loadSettings();
|
this._goodsOutSearchStore.loadSettings();
|
||||||
} else {
|
|
||||||
// this._goodsOutSearchStore.resetFilter(params);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
||||||
key: processId,
|
key: this._config.get('process.ids.goodsOut'),
|
||||||
name: 'Warenausgabe',
|
name: 'Warenausgabe',
|
||||||
path: `/kunde/${processId}/goods/out`,
|
path: `/kunde/goods/out`,
|
||||||
tags: ['goods-out', 'main', 'filter'],
|
tags: ['goods-out', 'main', 'filter'],
|
||||||
section: 'customer',
|
section: 'customer',
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CacheService } from '@core/cache';
|
|
||||||
import { DomainGoodsService } from '@domain/oms';
|
import { DomainGoodsService } from '@domain/oms';
|
||||||
import { ComponentStore, tapResponse } from '@ngrx/component-store';
|
import { ComponentStore, tapResponse } from '@ngrx/component-store';
|
||||||
import { ListResponseArgsOfOrderItemListItemDTO, OrderItemListItemDTO, QuerySettingsDTO } from '@swagger/oms';
|
import { ListResponseArgsOfOrderItemListItemDTO, OrderItemListItemDTO, QuerySettingsDTO } from '@swagger/oms';
|
||||||
import { UiFilter } from '@ui/filter';
|
import { UiFilter } from '@ui/filter';
|
||||||
import { isResponseArgs } from '@utils/object';
|
import { isResponseArgs } from '@utils/object';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { switchMap, mergeMap, withLatestFrom, filter, take, tap } from 'rxjs/operators';
|
import { switchMap, mergeMap, withLatestFrom, filter, take, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
export interface GoodsOutSearchState {
|
export interface GoodsOutSearchState {
|
||||||
@@ -73,7 +72,7 @@ export class GoodsOutSearchStore extends ComponentStore<GoodsOutSearchState> {
|
|||||||
|
|
||||||
readonly searchResultCleared = this._searchResultClearedSubject.asObservable();
|
readonly searchResultCleared = this._searchResultClearedSubject.asObservable();
|
||||||
|
|
||||||
constructor(private _domainGoodsInService: DomainGoodsService, private _cache: CacheService) {
|
constructor(private _domainGoodsInService: DomainGoodsService) {
|
||||||
super({
|
super({
|
||||||
fetching: false,
|
fetching: false,
|
||||||
hits: 0,
|
hits: 0,
|
||||||
@@ -143,46 +142,29 @@ export class GoodsOutSearchStore extends ComponentStore<GoodsOutSearchState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchRequest(options?: { take?: number; skip?: number; reload?: boolean }) {
|
searchRequest(options?: { take?: number; skip?: number }) {
|
||||||
return this.filter$.pipe(
|
return this.filter$.pipe(
|
||||||
filter((f) => f instanceof UiFilter),
|
filter((f) => f instanceof UiFilter),
|
||||||
take(1),
|
take(1),
|
||||||
mergeMap((filter) =>
|
mergeMap((filter) =>
|
||||||
this._domainGoodsInService.searchWarenausgabe({
|
this._domainGoodsInService.searchWarenausgabe({
|
||||||
...filter.getQueryToken(),
|
...filter.getQueryToken(),
|
||||||
skip: options.reload ? 0 : options?.skip ?? this.results.length,
|
skip: options?.skip ?? this.results.length,
|
||||||
take: options.reload ? this.results.length : options?.take ?? 50,
|
take: options?.take ?? 50,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
search = this.effect((options$: Observable<{ siletReload?: boolean }>) =>
|
search = this.effect(($) =>
|
||||||
options$.pipe(
|
$.pipe(
|
||||||
tap((options) => {
|
tap((_) => this.patchState({ fetching: true })),
|
||||||
if (!options?.siletReload) {
|
|
||||||
this.patchState({ fetching: true });
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
withLatestFrom(this.results$),
|
withLatestFrom(this.results$),
|
||||||
switchMap(([_options, _results]) => {
|
switchMap(([_, _results]) => {
|
||||||
const queryToken = this.filter?.getQueryToken();
|
return this.searchRequest(this.searchOptions).pipe(
|
||||||
|
|
||||||
if (queryToken && this._cache.get(queryToken)) {
|
|
||||||
const cached = this._cache.get(queryToken);
|
|
||||||
|
|
||||||
this.patchState(cached);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.searchRequest({ ...this.searchOptions, reload: _options.siletReload }).pipe(
|
|
||||||
tapResponse(
|
tapResponse(
|
||||||
(res) => {
|
(res) => {
|
||||||
let results: OrderItemListItemDTO[] = [];
|
const results = [...(_results ?? []), ...(res.result ?? [])];
|
||||||
if (_options.siletReload) {
|
|
||||||
results = res.result;
|
|
||||||
} else {
|
|
||||||
results = [...(_results ?? []), ...(res.result ?? [])];
|
|
||||||
}
|
|
||||||
|
|
||||||
this.patchState({
|
this.patchState({
|
||||||
hits: res.hits,
|
hits: res.hits,
|
||||||
@@ -190,14 +172,6 @@ export class GoodsOutSearchStore extends ComponentStore<GoodsOutSearchState> {
|
|||||||
fetching: false,
|
fetching: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (queryToken) {
|
|
||||||
this._cache.set(queryToken, {
|
|
||||||
hits: res.hits,
|
|
||||||
results,
|
|
||||||
fetching: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this._searchResultSubject.next(res);
|
this._searchResultSubject.next(res);
|
||||||
},
|
},
|
||||||
(err: Error) => {
|
(err: Error) => {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Component, ChangeDetectionStrategy, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
import { Component, ChangeDetectionStrategy, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { BreadcrumbService } from '@core/breadcrumb';
|
import { BreadcrumbService } from '@core/breadcrumb';
|
||||||
|
import { Config } from '@core/config';
|
||||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { combineLatest, Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { debounceTime, first, map } from 'rxjs/operators';
|
import { first } from 'rxjs/operators';
|
||||||
import { GoodsOutSearchStore } from '../goods-out-search.store';
|
import { GoodsOutSearchStore } from '../goods-out-search.store';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -24,18 +25,13 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private _subscriptions = new Subscription();
|
private _subscriptions = new Subscription();
|
||||||
|
|
||||||
get processId() {
|
|
||||||
return +this._activatedRoute.snapshot.data.processId;
|
|
||||||
}
|
|
||||||
|
|
||||||
processId$ = this._activatedRoute.data.pipe(map((data) => +data.processId));
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _goodsOutSearchStore: GoodsOutSearchStore,
|
private _goodsOutSearchStore: GoodsOutSearchStore,
|
||||||
private _cdr: ChangeDetectorRef,
|
private _cdr: ChangeDetectorRef,
|
||||||
private _router: Router,
|
private _router: Router,
|
||||||
private _activatedRoute: ActivatedRoute,
|
private _activatedRoute: ActivatedRoute,
|
||||||
private _breadcrumb: BreadcrumbService
|
private _breadcrumb: BreadcrumbService,
|
||||||
|
private readonly _config: Config
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -45,25 +41,27 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this._subscriptions.add(
|
this._goodsOutSearchStore.setQueryParams(this._activatedRoute.snapshot.queryParams);
|
||||||
combineLatest([this.processId$, this._activatedRoute.queryParams])
|
this.removeBreadcrumbs();
|
||||||
.pipe(debounceTime(50))
|
|
||||||
.subscribe(([processId, queryParams]) => {
|
|
||||||
this._goodsOutSearchStore.setQueryParams(queryParams);
|
|
||||||
this.removeBreadcrumbs(processId);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this._subscriptions.unsubscribe();
|
this._subscriptions.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeBreadcrumbs(processId: number) {
|
async removeBreadcrumbs() {
|
||||||
const resultCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'results']).pipe(first()).toPromise();
|
const resultCrumbs = await this._breadcrumb
|
||||||
const detailsCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'details']).pipe(first()).toPromise();
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'results'])
|
||||||
|
.pipe(first())
|
||||||
const editCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'edit']).pipe(first()).toPromise();
|
.toPromise();
|
||||||
|
const detailsCrumbs = await this._breadcrumb
|
||||||
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'details'])
|
||||||
|
.pipe(first())
|
||||||
|
.toPromise();
|
||||||
|
const editCrumbs = await this._breadcrumb
|
||||||
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'edit'])
|
||||||
|
.pipe(first())
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
editCrumbs.forEach((crumb) => {
|
editCrumbs.forEach((crumb) => {
|
||||||
this._breadcrumb.removeBreadcrumb(crumb.id, true);
|
this._breadcrumb.removeBreadcrumb(crumb.id, true);
|
||||||
@@ -80,7 +78,7 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
async search() {
|
async search() {
|
||||||
this._goodsOutSearchStore.clearResults();
|
this._goodsOutSearchStore.clearResults();
|
||||||
await this.updateQueryParams(this.processId);
|
await this.updateQueryParams();
|
||||||
this.message = undefined;
|
this.message = undefined;
|
||||||
|
|
||||||
this._goodsOutSearchStore.searchResult$.pipe(first()).subscribe((result) => {
|
this._goodsOutSearchStore.searchResult$.pipe(first()).subscribe((result) => {
|
||||||
@@ -89,9 +87,9 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
|
|||||||
if (result.hits > 0) {
|
if (result.hits > 0) {
|
||||||
if (result.hits === 1) {
|
if (result.hits === 1) {
|
||||||
const orderItem = result.result[0];
|
const orderItem = result.result[0];
|
||||||
this._router.navigate([this.getDetailsPath(orderItem, this.processId)]);
|
this._router.navigate([this.getDetailsPath(orderItem)]);
|
||||||
} else {
|
} else {
|
||||||
this._router.navigate(['/kunde', this.processId, 'goods', 'out', 'results'], {
|
this._router.navigate(['/kunde', 'goods', 'out', 'results'], {
|
||||||
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
|
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -102,34 +100,32 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this._cdr.markForCheck();
|
this._cdr.markForCheck();
|
||||||
});
|
});
|
||||||
|
this._goodsOutSearchStore.search();
|
||||||
this._goodsOutSearchStore.searchOptions = { take: 50, skip: 0 };
|
|
||||||
this._goodsOutSearchStore.search({});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateBreadcrumb(processId: number, params: Record<string, string>) {
|
async updateBreadcrumb(params: Record<string, string>) {
|
||||||
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
||||||
key: processId,
|
key: this._config.get('process.ids.goodsOut'),
|
||||||
name: 'Warenausgabe',
|
name: 'Warenausgabe',
|
||||||
path: `/kunde/${processId}/goods/out`,
|
path: `/kunde/goods/out`,
|
||||||
tags: ['goods-out', 'main', 'filter'],
|
tags: ['goods-out', 'main', 'filter'],
|
||||||
section: 'customer',
|
section: 'customer',
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateQueryParams(processId: number) {
|
async updateQueryParams() {
|
||||||
const queryParams = { ...this._goodsOutSearchStore.filter?.getQueryParams() };
|
const queryParams = { ...this._goodsOutSearchStore.filter?.getQueryParams() };
|
||||||
queryParams.main_qs = queryParams.main_qs ?? '';
|
queryParams.main_qs = queryParams.main_qs ?? '';
|
||||||
await this._router.navigate([], { queryParams });
|
await this._router.navigate([], { queryParams });
|
||||||
this.updateBreadcrumb(processId, queryParams);
|
this.updateBreadcrumb(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDetailsPath(item: OrderItemListItemDTO, processId: number) {
|
getDetailsPath(item: OrderItemListItemDTO) {
|
||||||
return item?.compartmentCode
|
return item?.compartmentCode
|
||||||
? `/kunde/${processId}/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
|
? `/kunde/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
|
||||||
: `/kunde/${processId}/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
|
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
queryChangeDebounce = debounce(() => this.updateQueryParams(this.processId), 500);
|
queryChangeDebounce = debounce(() => this.updateQueryParams(), 500);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,32 +6,30 @@
|
|||||||
[deltaEnd]="150"
|
[deltaEnd]="150"
|
||||||
[itemLength]="itemLength$ | async"
|
[itemLength]="itemLength$ | async"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="processId$ | async; let processId">
|
<shared-goods-in-out-order-group *ngFor="let bueryNumberGroup of items$ | async | groupBy: byBuyerNumberFn">
|
||||||
<shared-goods-in-out-order-group *ngFor="let bueryNumberGroup of items$ | async | groupBy: byBuyerNumberFn">
|
<ng-container *ngFor="let orderNumberGroup of bueryNumberGroup.items | groupBy: byOrderNumberFn; let lastOrderNumber = last">
|
||||||
<ng-container *ngFor="let orderNumberGroup of bueryNumberGroup.items | groupBy: byOrderNumberFn; let lastOrderNumber = last">
|
<ng-container
|
||||||
|
*ngFor="let processingStatusGroup of orderNumberGroup.items | groupBy: byProcessingStatusFn; let lastProcessingStatus = last"
|
||||||
|
>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngFor="let processingStatusGroup of orderNumberGroup.items | groupBy: byProcessingStatusFn; let lastProcessingStatus = last"
|
*ngFor="let compartmentCodeGroup of processingStatusGroup.items | groupBy: byCompartmentCodeFn; let lastCompartmentCode = last"
|
||||||
>
|
>
|
||||||
<ng-container
|
<shared-goods-in-out-order-group-item
|
||||||
*ngFor="let compartmentCodeGroup of processingStatusGroup.items | groupBy: byCompartmentCodeFn; let lastCompartmentCode = last"
|
*ngFor="let item of compartmentCodeGroup.items; let firstItem = first; trackBy: trackByFn"
|
||||||
>
|
[item]="item"
|
||||||
<shared-goods-in-out-order-group-item
|
[showCompartmentCode]="firstItem"
|
||||||
*ngFor="let item of compartmentCodeGroup.items; let firstItem = first; trackBy: trackByFn"
|
(click)="navigateToDetails(item)"
|
||||||
[item]="item"
|
[selectable]="item | goodsOutItemSelectable: selectionRules:selectedItems"
|
||||||
[showCompartmentCode]="firstItem"
|
[selected]="item | goodsOutItemSelected: selectedOrderItemSubsetIds"
|
||||||
(click)="navigateToDetails(processId, item)"
|
(selectedChange)="setSelectedItem(item, $event)"
|
||||||
[selectable]="item | goodsOutItemSelectable: selectionRules:selectedItems"
|
></shared-goods-in-out-order-group-item>
|
||||||
[selected]="item | goodsOutItemSelected: selectedOrderItemSubsetIds"
|
<div class="divider" *ngIf="!lastCompartmentCode"></div>
|
||||||
(selectedChange)="setSelectedItem(item, $event)"
|
|
||||||
></shared-goods-in-out-order-group-item>
|
|
||||||
<div class="divider" *ngIf="!lastCompartmentCode"></div>
|
|
||||||
</ng-container>
|
|
||||||
<div class="divider" *ngIf="!lastProcessingStatus"></div>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div class="divider" *ngIf="!lastOrderNumber"></div>
|
<div class="divider" *ngIf="!lastProcessingStatus"></div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</shared-goods-in-out-order-group>
|
<div class="divider" *ngIf="!lastOrderNumber"></div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
</shared-goods-in-out-order-group>
|
||||||
</ui-scroll-container>
|
</ui-scroll-container>
|
||||||
|
|
||||||
<ng-template #emptyMessage>
|
<ng-template #emptyMessage>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { CommandService } from '@core/command';
|
|||||||
import { OrderItemsContext } from '@domain/oms';
|
import { OrderItemsContext } from '@domain/oms';
|
||||||
import { UiErrorModalComponent, UiModalService } from '@ui/modal';
|
import { UiErrorModalComponent, UiModalService } from '@ui/modal';
|
||||||
import { UiScrollContainerComponent } from '@ui/scroll-container';
|
import { UiScrollContainerComponent } from '@ui/scroll-container';
|
||||||
|
import { Config } from '@core/config';
|
||||||
|
|
||||||
export interface GoodsOutSearchResultsState {
|
export interface GoodsOutSearchResultsState {
|
||||||
selectedOrderItemSubsetIds: number[];
|
selectedOrderItemSubsetIds: number[];
|
||||||
@@ -66,10 +67,6 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
|
|
||||||
byCompartmentCodeFn = (item: OrderItemListItemDTO) => item.compartmentCode;
|
byCompartmentCodeFn = (item: OrderItemListItemDTO) => item.compartmentCode;
|
||||||
|
|
||||||
processId$ = this._activatedRoute.parent.data.pipe(map((data) => +data.processId));
|
|
||||||
|
|
||||||
previousProcessId: undefined | number;
|
|
||||||
|
|
||||||
private _onDestroy$ = new Subject();
|
private _onDestroy$ = new Subject();
|
||||||
|
|
||||||
trackByFn = (item: OrderItemListItemDTO) => `${item.orderId}${item.orderItemId}${item.orderItemSubsetId}`;
|
trackByFn = (item: OrderItemListItemDTO) => `${item.orderId}${item.orderItemId}${item.orderItemSubsetId}`;
|
||||||
@@ -80,7 +77,8 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
private _activatedRoute: ActivatedRoute,
|
private _activatedRoute: ActivatedRoute,
|
||||||
private _breadcrumb: BreadcrumbService,
|
private _breadcrumb: BreadcrumbService,
|
||||||
private _commandService: CommandService,
|
private _commandService: CommandService,
|
||||||
private _modal: UiModalService
|
private _modal: UiModalService,
|
||||||
|
private readonly _config: Config
|
||||||
) {
|
) {
|
||||||
super({
|
super({
|
||||||
selectedOrderItemSubsetIds: [],
|
selectedOrderItemSubsetIds: [],
|
||||||
@@ -88,23 +86,14 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.processId$
|
this._goodsOutSearchStore.setQueryParams(this._activatedRoute.snapshot.queryParams);
|
||||||
.pipe(takeUntil(this._onDestroy$), debounceTime(1), withLatestFrom(this._activatedRoute.queryParams))
|
this._activatedRoute.queryParams.pipe(takeUntil(this._onDestroy$)).subscribe((queryParams) => {
|
||||||
.subscribe(([processId, params]) => {
|
this.updateBreadcrumb(queryParams);
|
||||||
this._goodsOutSearchStore.setQueryParams(params);
|
});
|
||||||
this.updateBreadcrumb(processId, params);
|
|
||||||
|
|
||||||
this.initInitialSearch(processId, params);
|
this.initInitialSearch();
|
||||||
this.createBreadcrumb(processId, params);
|
this.createBreadcrumb();
|
||||||
this.removeBreadcrumbs(processId);
|
this.removeBreadcrumbs();
|
||||||
|
|
||||||
if (this.previousProcessId && processId !== this.previousProcessId) {
|
|
||||||
this._goodsOutSearchStore.clearResults();
|
|
||||||
this._goodsOutSearchStore.search({ siletReload: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
this.previousProcessId = processId;
|
|
||||||
});
|
|
||||||
|
|
||||||
this._goodsOutSearchStore.searchResultCleared.pipe(takeUntil(this._onDestroy$)).subscribe((_) => this.clearSelectedItems());
|
this._goodsOutSearchStore.searchResultCleared.pipe(takeUntil(this._onDestroy$)).subscribe((_) => this.clearSelectedItems());
|
||||||
}
|
}
|
||||||
@@ -113,13 +102,19 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
this._onDestroy$.next();
|
this._onDestroy$.next();
|
||||||
this._onDestroy$.complete();
|
this._onDestroy$.complete();
|
||||||
|
|
||||||
// this.updateBreadcrumb(this._goodsOutSearchStore.filter?.getQueryParams());
|
this.updateBreadcrumb(this._goodsOutSearchStore.filter?.getQueryParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeBreadcrumbs(processId: number) {
|
async removeBreadcrumbs() {
|
||||||
const detailsCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'details']).pipe(first()).toPromise();
|
const detailsCrumbs = await this._breadcrumb
|
||||||
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'details'])
|
||||||
|
.pipe(first())
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
const editCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'edit']).pipe(first()).toPromise();
|
const editCrumbs = await this._breadcrumb
|
||||||
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'edit'])
|
||||||
|
.pipe(first())
|
||||||
|
.toPromise();
|
||||||
|
|
||||||
editCrumbs.forEach((crumb) => {
|
editCrumbs.forEach((crumb) => {
|
||||||
this._breadcrumb.removeBreadcrumb(crumb.id, true);
|
this._breadcrumb.removeBreadcrumb(crumb.id, true);
|
||||||
@@ -130,24 +125,24 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async createBreadcrumb(processId: number, params: Record<string, string>) {
|
async createBreadcrumb() {
|
||||||
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
|
||||||
key: processId,
|
key: this._config.get('process.ids.goodsOut'),
|
||||||
name: this.getBreadcrumbName(params),
|
name: this.getBreadcrumbName(),
|
||||||
path: `/kunde/${processId}/goods/out/results`,
|
path: `/kunde/goods/out/results`,
|
||||||
section: 'customer',
|
section: 'customer',
|
||||||
params,
|
params: this._goodsOutSearchStore.filter?.getQueryParams(),
|
||||||
tags: ['goods-out', 'results', 'filter'],
|
tags: ['goods-out', 'results', 'filter'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateBreadcrumb(processId: number, queryParams: Record<string, string>) {
|
async updateBreadcrumb(queryParams: Record<string, string> = this._goodsOutSearchStore.filter?.getQueryParams()) {
|
||||||
const scroll_position = this.scrollContainer?.scrollPos;
|
const scroll_position = this.scrollContainer?.scrollPos;
|
||||||
const take = this._goodsOutSearchStore.results?.length;
|
const take = this._goodsOutSearchStore.results?.length;
|
||||||
|
|
||||||
if (queryParams) {
|
if (queryParams) {
|
||||||
const crumbs = await this._breadcrumb
|
const crumbs = await this._breadcrumb
|
||||||
.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'results', 'filter'])
|
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'results', 'filter'])
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
.toPromise();
|
.toPromise();
|
||||||
|
|
||||||
@@ -163,23 +158,23 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getBreadcrumbName(params: Record<string, string>) {
|
getBreadcrumbName() {
|
||||||
const input = params?.main_qs;
|
const input = this._goodsOutSearchStore.filter?.getQueryParams()?.main_qs;
|
||||||
|
|
||||||
return input?.replace('ORD:', '') ?? 'Alle';
|
return input?.replace('ORD:', '') ?? 'Alle';
|
||||||
}
|
}
|
||||||
|
|
||||||
initInitialSearch(processId: number, params: Record<string, string>) {
|
initInitialSearch() {
|
||||||
if (this._goodsOutSearchStore.hits === 0) {
|
if (this._goodsOutSearchStore.hits === 0) {
|
||||||
this._goodsOutSearchStore.searchResult$.pipe(takeUntil(this._onDestroy$)).subscribe(async (result) => {
|
this._goodsOutSearchStore.searchResult$.pipe(takeUntil(this._onDestroy$)).subscribe(async (result) => {
|
||||||
if (result.hits === 0) {
|
if (result.hits === 0) {
|
||||||
await this._router.navigate([`/kunde/${processId}/goods/out`], {
|
await this._router.navigate([`/kunde/goods/out`], {
|
||||||
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
|
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await this.createBreadcrumb(processId, params);
|
await this.createBreadcrumb();
|
||||||
if (result.hits === 1) {
|
if (result.hits === 1) {
|
||||||
await this.navigateToDetails(processId, result.result[0]);
|
await this.navigateToDetails(result.result[0]);
|
||||||
} else {
|
} else {
|
||||||
if (!!this._goodsOutSearchStore.searchOptions?.take) {
|
if (!!this._goodsOutSearchStore.searchOptions?.take) {
|
||||||
this._goodsOutSearchStore.searchOptions = undefined;
|
this._goodsOutSearchStore.searchOptions = undefined;
|
||||||
@@ -188,7 +183,7 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this._goodsOutSearchStore.search({});
|
this._goodsOutSearchStore.search();
|
||||||
}
|
}
|
||||||
|
|
||||||
const { scroll_position, take } = this._goodsOutSearchStore.queryParams;
|
const { scroll_position, take } = this._goodsOutSearchStore.queryParams;
|
||||||
@@ -199,21 +194,19 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
|
|||||||
|
|
||||||
async loadMore() {
|
async loadMore() {
|
||||||
if (this._goodsOutSearchStore.hits > this._goodsOutSearchStore.results.length && !this._goodsOutSearchStore.fetching) {
|
if (this._goodsOutSearchStore.hits > this._goodsOutSearchStore.results.length && !this._goodsOutSearchStore.fetching) {
|
||||||
this._goodsOutSearchStore.search({});
|
this._goodsOutSearchStore.search();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToDetails(processId: number, orderItem: OrderItemListItemDTO) {
|
async navigateToDetails(orderItem: OrderItemListItemDTO) {
|
||||||
const orderNumber = orderItem.orderNumber;
|
const orderNumber = orderItem.orderNumber;
|
||||||
const processingStatus = orderItem.processingStatus;
|
const processingStatus = orderItem.processingStatus;
|
||||||
const compartmentCode = orderItem.compartmentCode;
|
const compartmentCode = orderItem.compartmentCode;
|
||||||
|
|
||||||
if (compartmentCode) {
|
if (compartmentCode) {
|
||||||
this._router.navigate([
|
await this._router.navigate([`/kunde/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`]);
|
||||||
`/kunde/${processId}/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`,
|
|
||||||
]);
|
|
||||||
} else {
|
} else {
|
||||||
this._router.navigate([`/kunde/${processId}/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}`]);
|
await this._router.navigate([`/kunde/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}`]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<shell-breadcrumb [key]="processId$ | async" [includesTags]="['goods-out']"></shell-breadcrumb>
|
<shell-breadcrumb [key]="goodsOutKey" [includesTags]="['goods-out']"></shell-breadcrumb>
|
||||||
|
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { Config } from '@core/config';
|
||||||
import { map } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-goods-out',
|
selector: 'page-goods-out',
|
||||||
@@ -9,7 +8,7 @@ import { map } from 'rxjs/operators';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class GoodsOutComponent {
|
export class GoodsOutComponent {
|
||||||
processId$ = this._activatedRoute.data.pipe(map((data) => +data.processId));
|
goodsOutKey = this._config.get('process.ids.goodsOut');
|
||||||
|
|
||||||
constructor(private _activatedRoute: ActivatedRoute) {}
|
constructor(private readonly _config: Config) {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user