Compare commits

...

1 Commits

Author SHA1 Message Date
Nino Righi
4f3308c17f #3272 Refactoring WA, Revert Changes - No multiple WA processes possible 2022-07-11 15:09:36 +02:00
15 changed files with 155 additions and 277 deletions

View File

@@ -7,7 +7,6 @@ import {
CanActivateCustomerWithProcessIdGuard,
CanActivateGoodsInGuard,
CanActivateGoodsOutGuard,
CanActivateGoodsOutWithProcessIdGuard,
CanActivateProductGuard,
CanActivateProductWithProcessIdGuard,
CanActivateRemissionGuard,
@@ -79,12 +78,6 @@ const routes: Routes = [
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 },

View File

@@ -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;
}
}

View File

@@ -6,44 +6,19 @@ import { first, map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
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) {
const processesIds = await this._applicationService
.getProcesses$('customer')
.pipe(
first(),
map((p) => {
return p.filter((process) => process.type === 'goods-out').map((process) => +process.name.replace('Warenausgabe', '').trim());
})
)
.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);
const process = await this._applicationService.getProcessById$(this._config.get('process.ids.goodsOut')).pipe(first()).toPromise();
if (!process) {
await this._applicationService.createProcess({
id: this._config.get('process.ids.goodsOut'),
type: 'goods-out',
section: 'customer',
name: 'Warenausgabe',
});
}
return url.filter((segment) => !!segment);
this._applicationService.activateProcess(this._config.get('process.ids.goodsOut'));
return true;
}
}

View File

@@ -3,7 +3,6 @@ export * from './can-activate-cart.guard';
export * from './can-activate-customer-with-process-id.guard';
export * from './can-activate-customer.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-product-with-process-id.guard';
export * from './can-activate-product.guard';

View File

@@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { BreadcrumbService } from '@core/breadcrumb';
import { Config } from '@core/config';
import { DomainGoodsService, DomainOmsService, OrderItemsContext } from '@domain/oms';
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ListResponseArgsOfOrderItemListItemDTO, OrderItemListItemDTO, OrderItemProcessingStatusValue } from '@swagger/oms';
@@ -47,12 +48,6 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
shareReplay()
);
get processId() {
return +this._activatedRoute.snapshot.parent.data.processId;
}
processId$ = this._activatedRoute.parent.data.pipe(map((params) => +params.processId));
private _onDestroy$ = new Subject();
constructor(
@@ -60,7 +55,8 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
private _domainGoodsInService: DomainGoodsService,
private _omsService: DomainOmsService,
private _breadcrumb: BreadcrumbService,
private _router: Router
private _router: Router,
private readonly _config: Config
) {
super({
fetching: false,
@@ -89,7 +85,7 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
async updateBreadcrumb(item: OrderItemListItemDTO) {
if (item) {
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
key: this.processId,
key: this._config.get('process.ids.goodsOut'),
name: item?.compartmentCode || item?.orderNumber,
path: this.getDetailsPath(item),
section: 'customer',
@@ -99,7 +95,10 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
}
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) => {
this._breadcrumb.removeBreadcrumb(crumb.id, true);
@@ -108,7 +107,7 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
async removeDetailsCrumbs() {
const detailsCrumbs = await this._breadcrumb
.getBreadcrumbsByKeyAndTags$(this.processId, ['goods-out', 'details'])
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'details'])
.pipe(first())
.toPromise();
@@ -159,7 +158,7 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
}
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' }) {
@@ -174,13 +173,13 @@ export class GoodsOutDetailsComponent extends ComponentStore<GoodsOutDetailsComp
getDetailsPath(item: OrderItemListItemDTO) {
return item?.compartmentCode
? `/kunde/${this.processId}/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/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
}
getEditPath(item: OrderItemListItemDTO) {
return item?.compartmentCode
? `/kunde/${this.processId}/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/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}/edit`
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}/edit`;
}
}

View File

@@ -1,6 +1,7 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { BreadcrumbService } from '@core/breadcrumb';
import { Config } from '@core/config';
import { DomainGoodsService } from '@domain/oms';
import { combineLatest, Observable } from 'rxjs';
import { map, shareReplay, switchMap, withLatestFrom } from 'rxjs/operators';
@@ -12,12 +13,6 @@ import { map, shareReplay, switchMap, withLatestFrom } from 'rxjs/operators';
changeDetection: ChangeDetectionStrategy.OnPush,
})
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(
map((params) => decodeURIComponent(params.orderNumber ?? '') || undefined)
);
@@ -43,7 +38,8 @@ export class GoodsOutEditComponent implements OnInit {
private _activatedRoute: ActivatedRoute,
private _breadcrumb: BreadcrumbService,
private _domainGoodsInService: DomainGoodsService,
private _router: Router
private _router: Router,
private readonly _config: Config
) {}
ngOnInit() {
@@ -55,11 +51,11 @@ export class GoodsOutEditComponent implements OnInit {
const compartmentCode = this._activatedRoute.snapshot.params.compartmentCode;
const processingStatus = this._activatedRoute.snapshot.params.processingStatus;
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
key: this.processId,
key: this._config.get('process.ids.goodsOut'),
name: 'Bearbeiten',
path: compartmentCode
? `/kunde/${this.processId}/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}/edit`
: `/kunde/${this.processId}/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}/edit`,
? `/kunde/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}/edit`
: `/kunde/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}/edit`,
section: 'customer',
tags: ['goods-out', 'edit', compartmentCode || orderNumber],
});
@@ -70,9 +66,7 @@ export class GoodsOutEditComponent implements OnInit {
const compartmentCode = this._activatedRoute.snapshot.params.compartmentCode;
const processingStatus = options?.processingStatus ? options.processingStatus : this._activatedRoute.snapshot.params.processingStatus;
compartmentCode
? this._router.navigate([
`/kunde/${this.processId}/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`,
])
: this._router.navigate([`/kunde/${this.processId}/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}`]);
? this._router.navigate([`/kunde/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`])
: this._router.navigate([`/kunde/goods/out/details/order/${encodeURIComponent(orderNumber)}/${processingStatus}`]);
}
}

View File

@@ -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 { BreadcrumbService } from '@core/breadcrumb';
import { Config } from '@core/config';
@@ -24,9 +24,6 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
message: string;
@Input()
processId: number;
private _onDestroy$ = new Subject();
constructor(
@@ -77,7 +74,7 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
const orderItem = result.result[0];
this._router.navigate([this.getDetailsPath(orderItem)]);
} else {
this._router.navigate(['/kunde', this.processId, 'goods', 'out', 'results'], {
this._router.navigate(['/kunde', 'goods', 'out', 'results'], {
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
});
}
@@ -91,14 +88,14 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
}
});
this._goodsOutSearchStore.search({});
this._goodsOutSearchStore.search();
}
async updateBreadcrumb() {
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
key: this.processId,
key: this._config.get('process.ids.goodsOut'),
name: 'Warenausgabe',
path: `/kunde/${this.processId}/goods/out`,
path: `/kunde/goods/out`,
tags: ['goods-out', 'main', 'filter'],
section: 'customer',
params: this._goodsOutSearchStore.filter?.getQueryParams(),
@@ -112,7 +109,7 @@ export class GoodsOutSearchFilterComponent implements OnInit, OnDestroy {
getDetailsPath(item: OrderItemListItemDTO) {
return item?.compartmentCode
? `/kunde/${this.processId}/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/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
}
}

View File

@@ -7,7 +7,6 @@
<shell-filter-overlay #shellFilterOverlay>
<page-goods-out-search-filter
[processId]="processId$ | async"
*ngIf="showFilterOverlay"
(close)="toggleFilterOverlay(); shellFilterOverlay.close()"
></page-goods-out-search-filter>

View File

@@ -44,8 +44,6 @@ export class GoodsOutSearchComponent implements OnInit, OnDestroy {
map(([filter, initialFilter]) => !isEqual(filter?.getQueryParams(), initialFilter?.getQueryParams()))
);
processId$ = this._activatedRoute.data.pipe(map((data) => +data.processId));
constructor(
private _goodsOutSearchStore: GoodsOutSearchStore,
private _breadcrumb: BreadcrumbService,
@@ -55,22 +53,20 @@ export class GoodsOutSearchComponent implements OnInit, OnDestroy {
ngOnInit() {
this._goodsOutSearchStore.loadSettings();
this.processId$.pipe(takeUntil(this._onDestroy$), withLatestFrom(this._activatedRoute.queryParams)).subscribe(([processId, params]) => {
this._activatedRoute.queryParams.pipe(takeUntil(this._onDestroy$)).subscribe((params) => {
// Reset Filter when query params are empty
if (params && Object.keys(params).length === 0) {
this._goodsOutSearchStore.setQueryParams(params);
this._goodsOutSearchStore.loadSettings();
} else {
// this._goodsOutSearchStore.resetFilter(params);
}
});
this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
key: processId,
name: 'Warenausgabe',
path: `/kunde/${processId}/goods/out`,
tags: ['goods-out', 'main', 'filter'],
section: 'customer',
});
this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
key: this._config.get('process.ids.goodsOut'),
name: 'Warenausgabe',
path: `/kunde/goods/out`,
tags: ['goods-out', 'main', 'filter'],
section: 'customer',
});
}

View File

@@ -1,12 +1,11 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { CacheService } from '@core/cache';
import { DomainGoodsService } from '@domain/oms';
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ListResponseArgsOfOrderItemListItemDTO, OrderItemListItemDTO, QuerySettingsDTO } from '@swagger/oms';
import { UiFilter } from '@ui/filter';
import { isResponseArgs } from '@utils/object';
import { Observable, Subject } from 'rxjs';
import { Subject } from 'rxjs';
import { switchMap, mergeMap, withLatestFrom, filter, take, tap } from 'rxjs/operators';
export interface GoodsOutSearchState {
@@ -73,7 +72,7 @@ export class GoodsOutSearchStore extends ComponentStore<GoodsOutSearchState> {
readonly searchResultCleared = this._searchResultClearedSubject.asObservable();
constructor(private _domainGoodsInService: DomainGoodsService, private _cache: CacheService) {
constructor(private _domainGoodsInService: DomainGoodsService) {
super({
fetching: false,
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(
filter((f) => f instanceof UiFilter),
take(1),
mergeMap((filter) =>
this._domainGoodsInService.searchWarenausgabe({
...filter.getQueryToken(),
skip: options.reload ? 0 : options?.skip ?? this.results.length,
take: options.reload ? this.results.length : options?.take ?? 50,
skip: options?.skip ?? this.results.length,
take: options?.take ?? 50,
})
)
);
}
search = this.effect((options$: Observable<{ siletReload?: boolean }>) =>
options$.pipe(
tap((options) => {
if (!options?.siletReload) {
this.patchState({ fetching: true });
}
}),
search = this.effect(($) =>
$.pipe(
tap((_) => this.patchState({ fetching: true })),
withLatestFrom(this.results$),
switchMap(([_options, _results]) => {
const queryToken = this.filter?.getQueryToken();
if (queryToken && this._cache.get(queryToken)) {
const cached = this._cache.get(queryToken);
this.patchState(cached);
}
return this.searchRequest({ ...this.searchOptions, reload: _options.siletReload }).pipe(
switchMap(([_, _results]) => {
return this.searchRequest(this.searchOptions).pipe(
tapResponse(
(res) => {
let results: OrderItemListItemDTO[] = [];
if (_options.siletReload) {
results = res.result;
} else {
results = [...(_results ?? []), ...(res.result ?? [])];
}
const results = [...(_results ?? []), ...(res.result ?? [])];
this.patchState({
hits: res.hits,
@@ -190,14 +172,6 @@ export class GoodsOutSearchStore extends ComponentStore<GoodsOutSearchState> {
fetching: false,
});
if (queryToken) {
this._cache.set(queryToken, {
hits: res.hits,
results,
fetching: false,
});
}
this._searchResultSubject.next(res);
},
(err: Error) => {

View File

@@ -1,10 +1,11 @@
import { Component, ChangeDetectionStrategy, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { BreadcrumbService } from '@core/breadcrumb';
import { Config } from '@core/config';
import { OrderItemListItemDTO } from '@swagger/oms';
import { debounce } from 'lodash';
import { combineLatest, Subscription } from 'rxjs';
import { debounceTime, first, map } from 'rxjs/operators';
import { Subscription } from 'rxjs';
import { first } from 'rxjs/operators';
import { GoodsOutSearchStore } from '../goods-out-search.store';
@Component({
@@ -24,18 +25,13 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
private _subscriptions = new Subscription();
get processId() {
return +this._activatedRoute.snapshot.data.processId;
}
processId$ = this._activatedRoute.data.pipe(map((data) => +data.processId));
constructor(
private _goodsOutSearchStore: GoodsOutSearchStore,
private _cdr: ChangeDetectorRef,
private _router: Router,
private _activatedRoute: ActivatedRoute,
private _breadcrumb: BreadcrumbService
private _breadcrumb: BreadcrumbService,
private readonly _config: Config
) {}
ngOnInit() {
@@ -45,25 +41,27 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
})
);
this._subscriptions.add(
combineLatest([this.processId$, this._activatedRoute.queryParams])
.pipe(debounceTime(50))
.subscribe(([processId, queryParams]) => {
this._goodsOutSearchStore.setQueryParams(queryParams);
this.removeBreadcrumbs(processId);
})
);
this._goodsOutSearchStore.setQueryParams(this._activatedRoute.snapshot.queryParams);
this.removeBreadcrumbs();
}
ngOnDestroy() {
this._subscriptions.unsubscribe();
}
async removeBreadcrumbs(processId: number) {
const resultCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'results']).pipe(first()).toPromise();
const detailsCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'details']).pipe(first()).toPromise();
const editCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'edit']).pipe(first()).toPromise();
async removeBreadcrumbs() {
const resultCrumbs = await this._breadcrumb
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'results'])
.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$(this._config.get('process.ids.goodsOut'), ['goods-out', 'edit'])
.pipe(first())
.toPromise();
editCrumbs.forEach((crumb) => {
this._breadcrumb.removeBreadcrumb(crumb.id, true);
@@ -80,7 +78,7 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
async search() {
this._goodsOutSearchStore.clearResults();
await this.updateQueryParams(this.processId);
await this.updateQueryParams();
this.message = undefined;
this._goodsOutSearchStore.searchResult$.pipe(first()).subscribe((result) => {
@@ -89,9 +87,9 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
if (result.hits > 0) {
if (result.hits === 1) {
const orderItem = result.result[0];
this._router.navigate([this.getDetailsPath(orderItem, this.processId)]);
this._router.navigate([this.getDetailsPath(orderItem)]);
} else {
this._router.navigate(['/kunde', this.processId, 'goods', 'out', 'results'], {
this._router.navigate(['/kunde', 'goods', 'out', 'results'], {
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
});
}
@@ -102,34 +100,32 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
this._cdr.markForCheck();
});
this._goodsOutSearchStore.searchOptions = { take: 50, skip: 0 };
this._goodsOutSearchStore.search({});
this._goodsOutSearchStore.search();
}
async updateBreadcrumb(processId: number, params: Record<string, string>) {
async updateBreadcrumb(params: Record<string, string>) {
await this._breadcrumb.addOrUpdateBreadcrumbIfNotExists({
key: processId,
key: this._config.get('process.ids.goodsOut'),
name: 'Warenausgabe',
path: `/kunde/${processId}/goods/out`,
path: `/kunde/goods/out`,
tags: ['goods-out', 'main', 'filter'],
section: 'customer',
params,
});
}
async updateQueryParams(processId: number) {
async updateQueryParams() {
const queryParams = { ...this._goodsOutSearchStore.filter?.getQueryParams() };
queryParams.main_qs = queryParams.main_qs ?? '';
await this._router.navigate([], { queryParams });
this.updateBreadcrumb(processId, queryParams);
this.updateBreadcrumb(queryParams);
}
getDetailsPath(item: OrderItemListItemDTO, processId: number) {
getDetailsPath(item: OrderItemListItemDTO) {
return item?.compartmentCode
? `/kunde/${processId}/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
: `/kunde/${processId}/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
? `/kunde/goods/out/details/compartment/${encodeURIComponent(item?.compartmentCode)}/${item?.processingStatus}`
: `/kunde/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
}
queryChangeDebounce = debounce(() => this.updateQueryParams(this.processId), 500);
queryChangeDebounce = debounce(() => this.updateQueryParams(), 500);
}

View File

@@ -6,32 +6,30 @@
[deltaEnd]="150"
[itemLength]="itemLength$ | async"
>
<ng-container *ngIf="processId$ | async; let processId">
<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">
<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 processingStatusGroup of orderNumberGroup.items | groupBy: byProcessingStatusFn; let lastProcessingStatus = last"
>
<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
*ngFor="let compartmentCodeGroup of processingStatusGroup.items | groupBy: byCompartmentCodeFn; let lastCompartmentCode = last"
>
<shared-goods-in-out-order-group-item
*ngFor="let item of compartmentCodeGroup.items; let firstItem = first; trackBy: trackByFn"
[item]="item"
[showCompartmentCode]="firstItem"
(click)="navigateToDetails(processId, item)"
[selectable]="item | goodsOutItemSelectable: selectionRules:selectedItems"
[selected]="item | goodsOutItemSelected: selectedOrderItemSubsetIds"
(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>
<shared-goods-in-out-order-group-item
*ngFor="let item of compartmentCodeGroup.items; let firstItem = first; trackBy: trackByFn"
[item]="item"
[showCompartmentCode]="firstItem"
(click)="navigateToDetails(item)"
[selectable]="item | goodsOutItemSelectable: selectionRules:selectedItems"
[selected]="item | goodsOutItemSelected: selectedOrderItemSubsetIds"
(selectedChange)="setSelectedItem(item, $event)"
></shared-goods-in-out-order-group-item>
<div class="divider" *ngIf="!lastCompartmentCode"></div>
</ng-container>
<div class="divider" *ngIf="!lastOrderNumber"></div>
<div class="divider" *ngIf="!lastProcessingStatus"></div>
</ng-container>
</shared-goods-in-out-order-group>
</ng-container>
<div class="divider" *ngIf="!lastOrderNumber"></div>
</ng-container>
</shared-goods-in-out-order-group>
</ui-scroll-container>
<ng-template #emptyMessage>

View File

@@ -10,6 +10,7 @@ import { CommandService } from '@core/command';
import { OrderItemsContext } from '@domain/oms';
import { UiErrorModalComponent, UiModalService } from '@ui/modal';
import { UiScrollContainerComponent } from '@ui/scroll-container';
import { Config } from '@core/config';
export interface GoodsOutSearchResultsState {
selectedOrderItemSubsetIds: number[];
@@ -66,10 +67,6 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
byCompartmentCodeFn = (item: OrderItemListItemDTO) => item.compartmentCode;
processId$ = this._activatedRoute.parent.data.pipe(map((data) => +data.processId));
previousProcessId: undefined | number;
private _onDestroy$ = new Subject();
trackByFn = (item: OrderItemListItemDTO) => `${item.orderId}${item.orderItemId}${item.orderItemSubsetId}`;
@@ -80,7 +77,8 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
private _activatedRoute: ActivatedRoute,
private _breadcrumb: BreadcrumbService,
private _commandService: CommandService,
private _modal: UiModalService
private _modal: UiModalService,
private readonly _config: Config
) {
super({
selectedOrderItemSubsetIds: [],
@@ -88,23 +86,14 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
}
ngOnInit() {
this.processId$
.pipe(takeUntil(this._onDestroy$), debounceTime(1), withLatestFrom(this._activatedRoute.queryParams))
.subscribe(([processId, params]) => {
this._goodsOutSearchStore.setQueryParams(params);
this.updateBreadcrumb(processId, params);
this._goodsOutSearchStore.setQueryParams(this._activatedRoute.snapshot.queryParams);
this._activatedRoute.queryParams.pipe(takeUntil(this._onDestroy$)).subscribe((queryParams) => {
this.updateBreadcrumb(queryParams);
});
this.initInitialSearch(processId, params);
this.createBreadcrumb(processId, params);
this.removeBreadcrumbs(processId);
if (this.previousProcessId && processId !== this.previousProcessId) {
this._goodsOutSearchStore.clearResults();
this._goodsOutSearchStore.search({ siletReload: true });
}
this.previousProcessId = processId;
});
this.initInitialSearch();
this.createBreadcrumb();
this.removeBreadcrumbs();
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$.complete();
// this.updateBreadcrumb(this._goodsOutSearchStore.filter?.getQueryParams());
this.updateBreadcrumb(this._goodsOutSearchStore.filter?.getQueryParams());
}
async removeBreadcrumbs(processId: number) {
const detailsCrumbs = await this._breadcrumb.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'details']).pipe(first()).toPromise();
async removeBreadcrumbs() {
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) => {
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({
key: processId,
name: this.getBreadcrumbName(params),
path: `/kunde/${processId}/goods/out/results`,
key: this._config.get('process.ids.goodsOut'),
name: this.getBreadcrumbName(),
path: `/kunde/goods/out/results`,
section: 'customer',
params,
params: this._goodsOutSearchStore.filter?.getQueryParams(),
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 take = this._goodsOutSearchStore.results?.length;
if (queryParams) {
const crumbs = await this._breadcrumb
.getBreadcrumbsByKeyAndTags$(processId, ['goods-out', 'results', 'filter'])
.getBreadcrumbsByKeyAndTags$(this._config.get('process.ids.goodsOut'), ['goods-out', 'results', 'filter'])
.pipe(first())
.toPromise();
@@ -163,23 +158,23 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
}
}
getBreadcrumbName(params: Record<string, string>) {
const input = params?.main_qs;
getBreadcrumbName() {
const input = this._goodsOutSearchStore.filter?.getQueryParams()?.main_qs;
return input?.replace('ORD:', '') ?? 'Alle';
}
initInitialSearch(processId: number, params: Record<string, string>) {
initInitialSearch() {
if (this._goodsOutSearchStore.hits === 0) {
this._goodsOutSearchStore.searchResult$.pipe(takeUntil(this._onDestroy$)).subscribe(async (result) => {
if (result.hits === 0) {
await this._router.navigate([`/kunde/${processId}/goods/out`], {
await this._router.navigate([`/kunde/goods/out`], {
queryParams: this._goodsOutSearchStore.filter.getQueryParams(),
});
} else {
await this.createBreadcrumb(processId, params);
await this.createBreadcrumb();
if (result.hits === 1) {
await this.navigateToDetails(processId, result.result[0]);
await this.navigateToDetails(result.result[0]);
} else {
if (!!this._goodsOutSearchStore.searchOptions?.take) {
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;
@@ -199,21 +194,19 @@ export class GoodsOutSearchResultsComponent extends ComponentStore<GoodsOutSearc
async loadMore() {
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 processingStatus = orderItem.processingStatus;
const compartmentCode = orderItem.compartmentCode;
if (compartmentCode) {
this._router.navigate([
`/kunde/${processId}/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`,
]);
await this._router.navigate([`/kunde/goods/out/details/compartment/${encodeURIComponent(compartmentCode)}/${processingStatus}`]);
} 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}`]);
}
}

View File

@@ -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>

View File

@@ -1,6 +1,5 @@
import { Component, ChangeDetectionStrategy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { map } from 'rxjs/operators';
import { Config } from '@core/config';
@Component({
selector: 'page-goods-out',
@@ -9,7 +8,7 @@ import { map } from 'rxjs/operators';
changeDetection: ChangeDetectionStrategy.OnPush,
})
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) {}
}