mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
fix(domain-oms, page-pickup-shelf): Fixed Reorder Logic flow, early exit if Modal gets closed to maintain the Data in the Store
Ref: #5537
This commit is contained in:
@@ -4,7 +4,10 @@ import { OrderItemsContext } from './order-items.context';
|
|||||||
import { UiModalService } from '@ui/modal';
|
import { UiModalService } from '@ui/modal';
|
||||||
import { ReorderModalComponent, ReorderResult } from '@modal/reorder';
|
import { ReorderModalComponent, ReorderResult } from '@modal/reorder';
|
||||||
import { DomainCheckoutService } from '@domain/checkout';
|
import { DomainCheckoutService } from '@domain/checkout';
|
||||||
import { AvailabilityDTO2, OrderItemListItemDTO } from '@generated/swagger/oms-api';
|
import {
|
||||||
|
AvailabilityDTO2,
|
||||||
|
OrderItemListItemDTO,
|
||||||
|
} from '@generated/swagger/oms-api';
|
||||||
import { ToasterService } from '@shared/shell';
|
import { ToasterService } from '@shared/shell';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -22,18 +25,36 @@ export class ReOrderActionHandler extends ActionHandler<OrderItemsContext> {
|
|||||||
const updatedItems: OrderItemListItemDTO[] = [];
|
const updatedItems: OrderItemListItemDTO[] = [];
|
||||||
for (const orderItem of data.items) {
|
for (const orderItem of data.items) {
|
||||||
const result = await this._uiModal
|
const result = await this._uiModal
|
||||||
.open<ReorderResult, { item: OrderItemListItemDTO; showReasons: boolean }>({
|
.open<
|
||||||
|
ReorderResult,
|
||||||
|
{ item: OrderItemListItemDTO; showReasons: boolean }
|
||||||
|
>({
|
||||||
content: ReorderModalComponent,
|
content: ReorderModalComponent,
|
||||||
title: 'Artikel nachbestellen',
|
title: 'Artikel nachbestellen',
|
||||||
data: {
|
data: {
|
||||||
item: { ...orderItem, quantity: data.itemQuantity?.get(orderItem.orderItemSubsetId) ?? orderItem.quantity },
|
item: {
|
||||||
|
...orderItem,
|
||||||
|
quantity:
|
||||||
|
data.itemQuantity?.get(orderItem.orderItemSubsetId) ??
|
||||||
|
orderItem.quantity,
|
||||||
|
},
|
||||||
showReasons: true,
|
showReasons: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.afterClosed$.toPromise();
|
.afterClosed$.toPromise();
|
||||||
|
|
||||||
|
// #5537 - If no result or no data, skip to next item
|
||||||
|
if (!result || !result.data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
if (result.data.action === 'REORDER') {
|
if (result.data.action === 'REORDER') {
|
||||||
const reorderResult = await this.reorder(result.data.item, result.data.availability, result.data.comment);
|
const reorderResult = await this.reorder(
|
||||||
|
result.data.item,
|
||||||
|
result.data.availability,
|
||||||
|
result.data.comment,
|
||||||
|
);
|
||||||
const resItem = reorderResult.item1;
|
const resItem = reorderResult.item1;
|
||||||
|
|
||||||
this.createToast(result?.data?.comment);
|
this.createToast(result?.data?.comment);
|
||||||
@@ -57,8 +78,6 @@ export class ReOrderActionHandler extends ActionHandler<OrderItemsContext> {
|
|||||||
context = await this._command.handleCommand('NOTAVAILABLE', context);
|
context = await this._command.handleCommand('NOTAVAILABLE', context);
|
||||||
updatedItems.push(...context.items);
|
updatedItems.push(...context.items);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,24 +96,33 @@ export class ReOrderActionHandler extends ActionHandler<OrderItemsContext> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async reorder(orderItem: OrderItemListItemDTO, availability: AvailabilityDTO2, comment: string) {
|
async reorder(
|
||||||
|
orderItem: OrderItemListItemDTO,
|
||||||
|
availability: AvailabilityDTO2,
|
||||||
|
comment: string,
|
||||||
|
) {
|
||||||
return await this._domainCheckoutService
|
return await this._domainCheckoutService
|
||||||
.reorder(orderItem.orderId, orderItem.orderItemId, orderItem.orderItemSubsetId, {
|
.reorder(
|
||||||
quantity: orderItem.quantity,
|
orderItem.orderId,
|
||||||
comment,
|
orderItem.orderItemId,
|
||||||
availability: {
|
orderItem.orderItemSubsetId,
|
||||||
availabilityType: availability.status,
|
{
|
||||||
ssc: availability.ssc,
|
quantity: orderItem.quantity,
|
||||||
sscText: availability.sscText,
|
comment,
|
||||||
supplier: {
|
availability: {
|
||||||
id: availability.supplierId,
|
availabilityType: availability.status,
|
||||||
|
ssc: availability.ssc,
|
||||||
|
sscText: availability.sscText,
|
||||||
|
supplier: {
|
||||||
|
id: availability.supplierId,
|
||||||
|
},
|
||||||
|
isPrebooked: availability.isPrebooked,
|
||||||
|
estimatedShippingDate: availability.at,
|
||||||
|
price: availability.price,
|
||||||
|
inStock: availability.qty,
|
||||||
},
|
},
|
||||||
isPrebooked: availability.isPrebooked,
|
|
||||||
estimatedShippingDate: availability.at,
|
|
||||||
price: availability.price,
|
|
||||||
inStock: availability.qty,
|
|
||||||
},
|
},
|
||||||
})
|
)
|
||||||
.toPromise();
|
.toPromise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { PickupShelfDetailsStore, PickupShelfStore } from './store';
|
import { PickupShelfDetailsStore, PickupShelfStore } from './store';
|
||||||
import { ActionHandlerService } from './services/action-handler.service';
|
import { ActionHandlerService } from './services/action-handler.service';
|
||||||
import { DBHOrderItemListItemDTO, KeyValueDTOOfStringAndString } from '@generated/swagger/oms-api';
|
import {
|
||||||
|
DBHOrderItemListItemDTO,
|
||||||
|
KeyValueDTOOfStringAndString,
|
||||||
|
} from '@generated/swagger/oms-api';
|
||||||
import { OrderItemsContext } from '@domain/oms';
|
import { OrderItemsContext } from '@domain/oms';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
||||||
@@ -22,7 +25,9 @@ export abstract class PickupShelfDetailsBaseComponent {
|
|||||||
|
|
||||||
get side() {
|
get side() {
|
||||||
if (this.activatedRoute.snapshot.queryParams.side !== undefined) {
|
if (this.activatedRoute.snapshot.queryParams.side !== undefined) {
|
||||||
return coerceBooleanProperty(this.activatedRoute.snapshot.queryParams.side);
|
return coerceBooleanProperty(
|
||||||
|
this.activatedRoute.snapshot.queryParams.side,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -37,23 +42,33 @@ export abstract class PickupShelfDetailsBaseComponent {
|
|||||||
);
|
);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.activatedRoute.params.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((params) => {
|
this.activatedRoute.params
|
||||||
// // Fix #4508 - Always Reset Cover Items before fetching new ones inside pickup-shelf-in-details.component
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||||
if (this.store.coverOrderItems?.length) {
|
.subscribe((params) => {
|
||||||
this.store.resetCoverItems();
|
// // Fix #4508 - Always Reset Cover Items before fetching new ones inside pickup-shelf-in-details.component
|
||||||
}
|
if (this.store.coverOrderItems?.length) {
|
||||||
this.store.fetchOrder({ orderId: Number(params.orderId) });
|
this.store.resetCoverItems();
|
||||||
|
}
|
||||||
|
this.store.fetchOrder({ orderId: Number(params.orderId) });
|
||||||
|
|
||||||
this.store.fetchOrderItems({
|
this.store.fetchOrderItems({
|
||||||
orderNumber: params.orderNumber ? decodeURIComponent(params.orderNumber) : undefined,
|
orderNumber: params.orderNumber
|
||||||
compartmentCode: params.compartmentCode ? decodeURIComponent(params.compartmentCode) : undefined,
|
? decodeURIComponent(params.orderNumber)
|
||||||
compartmentInfo: params.compartmentInfo ? decodeURIComponent(params.compartmentInfo) : undefined,
|
: undefined,
|
||||||
orderItemProcessingStatus: (params.orderItemProcessingStatus
|
compartmentCode: params.compartmentCode
|
||||||
? +params.orderItemProcessingStatus
|
? decodeURIComponent(params.compartmentCode)
|
||||||
: undefined) as any,
|
: undefined,
|
||||||
orderItemSubsetId: params.orderItemSubsetId ? +params.orderItemSubsetId : undefined,
|
compartmentInfo: params.compartmentInfo
|
||||||
|
? decodeURIComponent(params.compartmentInfo)
|
||||||
|
: undefined,
|
||||||
|
orderItemProcessingStatus: (params.orderItemProcessingStatus
|
||||||
|
? +params.orderItemProcessingStatus
|
||||||
|
: undefined) as any,
|
||||||
|
orderItemSubsetId: params.orderItemSubsetId
|
||||||
|
? +params.orderItemSubsetId
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,23 +93,19 @@ export abstract class PickupShelfDetailsBaseComponent {
|
|||||||
action,
|
action,
|
||||||
items: this.store.selectedOrderItems,
|
items: this.store.selectedOrderItems,
|
||||||
compartmentCode: latestCompartmentCode ?? undefined, // Ticket #4391 - if undefined, assign new compartmentCode to item (bei eingetroffen und drucken)
|
compartmentCode: latestCompartmentCode ?? undefined, // Ticket #4391 - if undefined, assign new compartmentCode to item (bei eingetroffen und drucken)
|
||||||
compartmentInfo: latestCompartmentInfo ?? (this.store.selectedCompartmentInfo || this.store.compartmentInfo), // Ticket #4397
|
compartmentInfo:
|
||||||
|
latestCompartmentInfo ??
|
||||||
|
(this.store.selectedCompartmentInfo || this.store.compartmentInfo), // Ticket #4397
|
||||||
order: this.store.order,
|
order: this.store.order,
|
||||||
itemQuantity: this.store.selectedOrderItemQuantity,
|
itemQuantity: this.store.selectedOrderItemQuantity,
|
||||||
});
|
});
|
||||||
|
|
||||||
const ctxItem = ctx?.items[0];
|
const ctxItem = ctx?.items[0];
|
||||||
|
|
||||||
// Ticket #4466 - Nach der nachbestellung wurde der Artikel in den Details nicht mehr angezeigt - änderung #4459 rückgängig gemacht
|
// #5537 - If REORDER action and no context item, return early to avoid unnecessary clearing and fetching
|
||||||
// Ticket #4459 - Usecase Abholfach Nachbestellen - Wenn das selektierte Item nicht verändert wurde z.B. beim schließen des nachbestellen Modals
|
if (action.command.includes('REORDER') && !ctxItem) {
|
||||||
// soll hier returned werden, da der unveränderte Stand angezeigt werden soll
|
return;
|
||||||
// if (
|
}
|
||||||
// !ctxItem ||
|
|
||||||
// (action.command.includes('REORDER') &&
|
|
||||||
// ctxItem.orderItemSubsetId === this.store.selectedOrderItems.find((_) => true).orderItemSubsetId)
|
|
||||||
// ) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
this.store.setFetchPartial(false);
|
this.store.setFetchPartial(false);
|
||||||
this.store.resetSelectedOrderItems();
|
this.store.resetSelectedOrderItems();
|
||||||
@@ -104,20 +115,29 @@ export abstract class PickupShelfDetailsBaseComponent {
|
|||||||
|
|
||||||
if (!ctxItem) return;
|
if (!ctxItem) return;
|
||||||
|
|
||||||
const updatedDetailsItems = await new Promise<DBHOrderItemListItemDTO[]>((resolve, reject) => {
|
const updatedDetailsItems = await new Promise<DBHOrderItemListItemDTO[]>(
|
||||||
this.store.fetchOrderItems({
|
(resolve, reject) => {
|
||||||
orderNumber: ctxItem.orderNumber,
|
this.store.fetchOrderItems({
|
||||||
compartmentCode: ctxItem.processingStatus === 128 ? ctxItem.compartmentCode : undefined,
|
orderNumber: ctxItem.orderNumber,
|
||||||
compartmentInfo: ctxItem.processingStatus === 128 ? ctxItem.compartmentInfo : undefined,
|
compartmentCode:
|
||||||
orderItemProcessingStatus: ctxItem.processingStatus,
|
ctxItem.processingStatus === 128
|
||||||
orderItemSubsetId: ctxItem.orderItemSubsetId,
|
? ctxItem.compartmentCode
|
||||||
done: { resolve, reject },
|
: undefined,
|
||||||
});
|
compartmentInfo:
|
||||||
});
|
ctxItem.processingStatus === 128
|
||||||
|
? ctxItem.compartmentInfo
|
||||||
|
: undefined,
|
||||||
|
orderItemProcessingStatus: ctxItem.processingStatus,
|
||||||
|
orderItemSubsetId: ctxItem.orderItemSubsetId,
|
||||||
|
done: { resolve, reject },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
ctx.items.forEach((item) => {
|
ctx.items.forEach((item) => {
|
||||||
const updatedItem = updatedDetailsItems?.find(
|
const updatedItem = updatedDetailsItems?.find(
|
||||||
(detailsItem) => detailsItem?.orderItemSubsetId === item?.orderItemSubsetId,
|
(detailsItem) =>
|
||||||
|
detailsItem?.orderItemSubsetId === item?.orderItemSubsetId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!updatedItem) return;
|
if (!updatedItem) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user