Merged PR 1328: #3272 Beim Wechsel zwischen WA und Artikelrecherche den Warenkorb nicht mehr...

#3272 Beim Wechsel zwischen WA und Artikelrecherche den Warenkorb nicht mehr verwerfen

Related work items: #3272
This commit is contained in:
Andreas Schickinger
2022-07-18 10:18:10 +00:00
committed by Nino Righi
parent 8e32b15f26
commit 94d5892cf1
3 changed files with 40 additions and 10 deletions

View File

@@ -79,13 +79,22 @@ export class CanActivateCustomerGuard implements CanActivate {
// Bei offener Warenausgabe und Klick auf Footer Kundensuche
async fromGoodsOutProcess(processes: ApplicationProcess[], processId: number) {
const buyer = await this._checkoutService.getBuyer({ processId }).pipe(first()).toPromise();
const customerFeatures = await this._checkoutService.getCustomerFeatures({ processId }).pipe(first()).toPromise();
const name = buyer
? customerFeatures?.b2b
? buyer.organisation?.name
? buyer.organisation?.name
: buyer.lastName
: buyer.lastName
: `Vorgang ${this.processNumber(processes.filter((process) => process.type === 'cart'))}`;
// Ändere type goods-out zu cart
this._applicationService.patchProcess(processId, {
id: processId,
type: 'cart',
section: 'customer',
name: `Vorgang ${this.processNumber(processes.filter((process) => process.type === 'cart'))}`,
data: {},
name,
});
// Navigation

View File

@@ -8,7 +8,7 @@ import { first } from 'rxjs/operators';
export class CanActivateGoodsOutGuard implements CanActivate {
constructor(
private readonly _applicationService: ApplicationService,
private _checkoutService: DomainCheckoutService,
private readonly _checkoutService: DomainCheckoutService,
private readonly _router: Router
) {}
@@ -31,10 +31,10 @@ export class CanActivateGoodsOutGuard implements CanActivate {
// Darf nur reinkommen wenn der aktuell aktive Tab ein Bestellabschluss Tab ist
if (!!lastActivatedCartProcessId && lastActivatedCartProcessId === activatedProcessId) {
await this.fromCartOrCheckoutProcess(processes, route, lastActivatedCartProcessId);
await this.fromCartProcess(processes, route, lastActivatedCartProcessId);
return false;
} else if (!!lastActivatedCartCheckoutProcessId && lastActivatedCartCheckoutProcessId === activatedProcessId) {
await this.fromCartOrCheckoutProcess(processes, route, lastActivatedCartCheckoutProcessId);
await this.fromCartCheckoutProcess(processes, route, lastActivatedCartCheckoutProcessId);
return false;
}
@@ -61,8 +61,22 @@ export class CanActivateGoodsOutGuard implements CanActivate {
await this._router.navigate(this.getUrlFromSnapshot(route, ['/kunde', String(newProcessId)]));
}
// Bei offener Artikelsuche/Kundensuche und Klick auf Footer Warenausgabe
async fromCartProcess(processes: ApplicationProcess[], route: ActivatedRouteSnapshot, processId: number) {
// Ändere type cart zu goods-out
this._applicationService.patchProcess(processId, {
id: processId,
type: 'goods-out',
section: 'customer',
name: `Warenausgabe ${this.processNumber(processes.filter((process) => process.type === 'goods-out'))}`,
});
// Navigation
await this._router.navigate(this.getUrlFromSnapshot(route, ['/kunde', String(processId)]));
}
// Bei offener Bestellbestätigung, Artikelsuche/Kundensuche und Klick auf Footer Warenausgabe
async fromCartOrCheckoutProcess(processes: ApplicationProcess[], route: ActivatedRouteSnapshot, processId: number) {
async fromCartCheckoutProcess(processes: ApplicationProcess[], route: ActivatedRouteSnapshot, processId: number) {
// Um alle Checkout Daten zu resetten die mit dem Prozess assoziiert sind
this._checkoutService.removeProcess({ processId });

View File

@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { ApplicationProcess, ApplicationService } from '@core/application';
import { BreadcrumbService } from '@core/breadcrumb';
import { DomainCheckoutService } from '@domain/checkout';
import { first } from 'rxjs/operators';
@@ -63,14 +62,22 @@ export class CanActivateProductGuard implements CanActivate {
// Bei offener Warenausgabe und Klick auf Footer Artikelsuche
async fromGoodsOutProcess(processes: ApplicationProcess[], route: ActivatedRouteSnapshot, processId: number) {
console.log(processes.filter((process) => process.type === 'cart').length + 1);
const buyer = await this._checkoutService.getBuyer({ processId }).pipe(first()).toPromise();
const customerFeatures = await this._checkoutService.getCustomerFeatures({ processId }).pipe(first()).toPromise();
const name = buyer
? customerFeatures?.b2b
? buyer.organisation?.name
? buyer.organisation?.name
: buyer.lastName
: buyer.lastName
: `Vorgang ${this.processNumber(processes.filter((process) => process.type === 'cart'))}`;
// Ändere type goods-out zu cart
this._applicationService.patchProcess(processId, {
id: processId,
type: 'cart',
section: 'customer',
name: `Vorgang ${this.processNumber(processes.filter((process) => process.type === 'cart'))}`,
data: {},
name,
});
// Navigation