mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 1640: #4348 #4366 Multiple Bugfixes Shelf Edit with changing CompartmentInfo or CompartmentCode
#4348 #4366 Multiple Bugfixes Shelf Edit with changing CompartmentInfo or CompartmentCode
This commit is contained in:
committed by
Lorenz Hilpert
parent
4d669731fb
commit
ade3800568
@@ -4,7 +4,7 @@ import { BreadcrumbService } from '@core/breadcrumb';
|
||||
import { EnvironmentService } from '@core/environment';
|
||||
import { DomainCustomerOrderService, DomainGoodsService, DomainOmsService } from '@domain/oms';
|
||||
import { CustomerOrdersNavigationService } from '@shared/services';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { DBHOrderItemListItemDTO, OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { UiMessageModalComponent, UiModalService } from '@ui/modal';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { map, shareReplay, switchMap, tap, withLatestFrom } from 'rxjs/operators';
|
||||
@@ -87,10 +87,10 @@ export class CustomerOrderEditComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
async navigateToDetailsPage({ options }: { options?: { processingStatus?: number } }) {
|
||||
async navigateToDetailsPage(changes?: Partial<DBHOrderItemListItemDTO>) {
|
||||
const orderId = this._activatedRoute.snapshot.params.orderId;
|
||||
const compartmentCode = this._activatedRoute.snapshot.params.compartmentCode;
|
||||
const processingStatus = options?.processingStatus ? options.processingStatus : this._activatedRoute.snapshot.params.processingStatus;
|
||||
const processingStatus = changes?.processingStatus ? changes.processingStatus : this._activatedRoute.snapshot.params.processingStatus;
|
||||
|
||||
await this._navigation
|
||||
.getCustomerOrdersDetailsPath({
|
||||
|
||||
@@ -3,10 +3,8 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { PickupShelfDetailsStore, PickupShelfStore } from './store';
|
||||
import { ActionHandlerService } from './services/action-handler.service';
|
||||
import { DBHOrderItemListItemDTO, KeyValueDTOOfStringAndString, OrderItemProcessingStatusValue } from '@swagger/oms';
|
||||
import { DBHOrderItemListItemDTO, KeyValueDTOOfStringAndString } from '@swagger/oms';
|
||||
import { OrderItemsContext } from '@domain/oms';
|
||||
import { mergeMap, take } from 'rxjs/operators';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
export abstract class PickupShelfDetailsBaseComponent {
|
||||
protected destroyRef = inject(DestroyRef);
|
||||
@@ -73,8 +71,6 @@ export abstract class PickupShelfDetailsBaseComponent {
|
||||
|
||||
if (!updatedItem) return;
|
||||
|
||||
console.log('updatedItem', updatedItem);
|
||||
|
||||
this.listStore.patchOrderItem({
|
||||
orderItemSubsetId: item.orderItemSubsetId,
|
||||
changes: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, ChangeDetectionStrategy, ContentChild, inject, OnInit, AfterViewInit } from '@angular/core';
|
||||
import { Component, ChangeDetectionStrategy, inject, OnInit, AfterViewInit, ViewChild } from '@angular/core';
|
||||
import { PickupShelfDetailsBaseComponent } from '../../pickup-shelf-details-base.component';
|
||||
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
|
||||
import { PickUpShelfDetailsHeaderComponent } from '../../shared/pickup-shelf-details-header/pickup-shelf-details-header.component';
|
||||
@@ -37,7 +37,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
],
|
||||
})
|
||||
export class PickupShelfInDetailsComponent extends PickupShelfDetailsBaseComponent implements OnInit, AfterViewInit {
|
||||
@ContentChild(PickUpShelfDetailsTagsComponent, { static: false })
|
||||
@ViewChild(PickUpShelfDetailsTagsComponent, { static: false })
|
||||
pickUpShelfDetailsTags: PickUpShelfDetailsTagsComponent;
|
||||
|
||||
private _pickupShelfInNavigationService = inject(PickupShelfInNavigationService);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { SharedGoodsInOutOrderEditModule } from '@shared/components/goods-in-out
|
||||
import { first } from 'rxjs/operators';
|
||||
import { AsyncPipe, NgIf } from '@angular/common';
|
||||
import { PickupShelfInNavigationService } from '@shared/services';
|
||||
import { DBHOrderItemListItemDTO } from '@swagger/oms';
|
||||
|
||||
@Component({
|
||||
selector: 'page-pickup-shelf-in-edit',
|
||||
@@ -22,15 +23,12 @@ export class PickupShelfInEditComponent extends PickupShelfDetailsBaseComponent
|
||||
|
||||
this.listStore;
|
||||
}
|
||||
|
||||
async navigateToShelfInDetailsPage({ options }: { options?: { processingStatus?: number } }) {
|
||||
async navigateToShelfInDetailsPage(changes?: Partial<DBHOrderItemListItemDTO>) {
|
||||
const orderId = (await this.store.orderItems$.pipe(first()).toPromise())?.find((_) => true)?.orderId;
|
||||
const compartmentCode = this.activatedRoute?.snapshot?.params?.compartmentCode;
|
||||
const orderNumber = this.activatedRoute?.snapshot?.params?.orderNumber;
|
||||
const processingStatus = options?.processingStatus
|
||||
? options.processingStatus
|
||||
: this.activatedRoute.snapshot.params.orderItemProcessingStatus;
|
||||
const compartmentInfo = this.activatedRoute.snapshot.params.compartmentInfo;
|
||||
const compartmentCode = changes?.compartmentCode ?? this.activatedRoute?.snapshot?.params?.compartmentCode;
|
||||
const processingStatus = changes?.processingStatus ?? this.activatedRoute.snapshot.params.orderItemProcessingStatus;
|
||||
const compartmentInfo = changes?.compartmentInfo ?? this.activatedRoute.snapshot.params.compartmentInfo;
|
||||
|
||||
await this.router.navigate(
|
||||
this.shelfInNavigation.detailRoute({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, ChangeDetectionStrategy, inject, ContentChild } from '@angular/core';
|
||||
import { Component, ChangeDetectionStrategy, inject, ViewChild } from '@angular/core';
|
||||
import { PickupShelfDetailsBaseComponent } from '../../pickup-shelf-details-base.component';
|
||||
import { AsyncPipe, NgFor, NgIf } from '@angular/common';
|
||||
import { PickUpShelfDetailsHeaderComponent } from '../../shared/pickup-shelf-details-header/pickup-shelf-details-header.component';
|
||||
@@ -34,7 +34,7 @@ import { FormsModule } from '@angular/forms';
|
||||
providers: [],
|
||||
})
|
||||
export class PickupShelfOutDetailsComponent extends PickupShelfDetailsBaseComponent {
|
||||
@ContentChild(PickUpShelfDetailsTagsComponent, { static: false })
|
||||
@ViewChild(PickUpShelfDetailsTagsComponent, { static: false })
|
||||
pickUpShelfDetailsTags: PickUpShelfDetailsTagsComponent;
|
||||
|
||||
private _pickupShelfOutNavigationService = inject(PickUpShelfOutNavigationService);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { SharedGoodsInOutOrderEditModule } from '@shared/components/goods-in-out
|
||||
import { first } from 'rxjs/operators';
|
||||
import { PickUpShelfOutNavigationService } from '@shared/services';
|
||||
import { AsyncPipe, NgIf } from '@angular/common';
|
||||
import { DBHOrderItemListItemDTO } from '@swagger/oms';
|
||||
|
||||
@Component({
|
||||
selector: 'page-pickup-shelf-out-edit',
|
||||
@@ -23,14 +24,12 @@ export class PickupShelfOutEditComponent extends PickupShelfDetailsBaseComponent
|
||||
this.listStore;
|
||||
}
|
||||
|
||||
async navigateToShelfOutDetailsPage({ options }: { options?: { processingStatus?: number } }) {
|
||||
async navigateToShelfOutDetailsPage(changes: Partial<DBHOrderItemListItemDTO>) {
|
||||
const orderId = (await this.store.orderItems$.pipe(first()).toPromise())?.find((_) => true)?.orderId;
|
||||
const compartmentCode = this.activatedRoute?.snapshot?.params?.compartmentCode;
|
||||
const orderNumber = this.activatedRoute?.snapshot?.params?.orderNumber;
|
||||
const processingStatus = options?.processingStatus
|
||||
? options.processingStatus
|
||||
: this.activatedRoute.snapshot.params.orderItemProcessingStatus;
|
||||
const compartmentInfo = this.activatedRoute.snapshot.params.compartmentInfo;
|
||||
const compartmentCode = changes?.compartmentCode ?? this.activatedRoute?.snapshot?.params?.compartmentCode;
|
||||
const processingStatus = changes?.processingStatus ?? this.activatedRoute.snapshot.params.orderItemProcessingStatus;
|
||||
const compartmentInfo = changes?.compartmentInfo ?? this.activatedRoute.snapshot.params.compartmentInfo;
|
||||
|
||||
await this.router.navigate(
|
||||
this.shelfOutNavigation.detailRoute({
|
||||
|
||||
@@ -46,13 +46,13 @@ export class PickUpShelfHistoryComponent {
|
||||
|
||||
customerName$ = this.historyItem$.pipe(
|
||||
map((historyItem) =>
|
||||
[historyItem?.organisation ?? historyItem.organisation, historyItem.lastName, historyItem.firstName].filter((i) => !!i).join(', ')
|
||||
[historyItem?.organisation ?? historyItem?.organisation, historyItem?.lastName, historyItem?.firstName].filter((i) => !!i).join(', ')
|
||||
)
|
||||
);
|
||||
|
||||
customerNumber$ = this.historyItem$.pipe(map((historyItem) => historyItem.buyerNumber));
|
||||
customerNumber$ = this.historyItem$.pipe(map((historyItem) => historyItem?.buyerNumber));
|
||||
|
||||
history$ = this.historyItem$.pipe(switchMap((historyItem) => this._omsService.getHistory(historyItem.orderItemSubsetId).pipe(take(1))));
|
||||
history$ = this.historyItem$.pipe(switchMap((historyItem) => this._omsService.getHistory(historyItem?.orderItemSubsetId).pipe(take(1))));
|
||||
|
||||
constructor(
|
||||
private _activatedRoute: ActivatedRoute,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
class="page-pickup-shelf-list-item__item-card hover p-4 bg-white border border-solid border-transparent rounded"
|
||||
[routerLink]="itemDetailsLink"
|
||||
[routerLinkActive]="!isTablet && !primaryOutletActive ? 'active' : ''"
|
||||
[queryParams]="queryParams"
|
||||
queryParamsHandling="preserve"
|
||||
(click)="isDesktopLarge ? scrollIntoView() : ''"
|
||||
>
|
||||
|
||||
@@ -62,20 +62,6 @@ export class PickUpShelfListItemComponent {
|
||||
return this.item?.product?.contributors?.split(';').map((val) => val.trim());
|
||||
}
|
||||
|
||||
get queryParams() {
|
||||
const queryParams = this.store.filter?.getQueryParams();
|
||||
if (this.item?.compartmentCode) {
|
||||
return {
|
||||
...queryParams,
|
||||
buyerNumber: this.item?.buyerNumber,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
...queryParams,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
get showChangeDate() {
|
||||
return [256, 512, 1024, 2048, 4069].includes(this.item?.processingStatus);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@ export const selectDisplayedCompartmentInfo = (s: PickupShelfDetailsState) => s.
|
||||
export const selectOrderItems = (s: PickupShelfDetailsState): DBHOrderItemListItemDTO[] => {
|
||||
let items = selectOrderItemsRaw(s);
|
||||
|
||||
const orderId = selectOrder(s)?.id;
|
||||
if (!orderId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Ticket #4348 - Möglicherweise sollte hier stattdessen auf die Buyernumber gefiltert werden, falls nicht alle OrderItems angezeigt werden die angezeigt werden sollten
|
||||
items = items?.filter((oi) => oi.orderId === orderId);
|
||||
|
||||
const processingStatus = selectDisplayedOrderItemProcessingStatus(s);
|
||||
if (processingStatus) {
|
||||
items = items?.filter((oi) => oi.processingStatus === processingStatus);
|
||||
|
||||
@@ -137,7 +137,6 @@ export class PickupShelfDetailsStore extends ComponentStore<PickupShelfDetailsSt
|
||||
return this.get(Selectors.selectSelectedCompartmentInfo);
|
||||
}
|
||||
set selectedCompartmentInfo(selectedCompartmentInfo: string) {
|
||||
console.log('set selectedCompartmentInfo', selectedCompartmentInfo);
|
||||
if (this.selectedCompartmentInfo !== selectedCompartmentInfo) {
|
||||
this.patchState({ selectedCompartmentInfo });
|
||||
}
|
||||
@@ -413,12 +412,12 @@ export class PickupShelfDetailsStore extends ComponentStore<PickupShelfDetailsSt
|
||||
},
|
||||
resolve?: (items: DBHOrderItemListItemDTO[]) => void
|
||||
) => (res: ListResponseArgsOfDBHOrderItemListItemDTO) => {
|
||||
// // Ticket #4348
|
||||
// check if order items belong to the same customer
|
||||
const buyerNumbers = uniq(res.result.map((i) => i.buyerNumber));
|
||||
if (buyerNumbers.length > 1) {
|
||||
this._modal.error('Fehler beim Laden der Bestellpositionen', new Error('Die Bestellpositionen gehören zu unterschiedlichen Kunden.'));
|
||||
return;
|
||||
}
|
||||
// if (buyerNumbers.length > 1) {
|
||||
// this._modal.error('Fehler beim Laden der Bestellpositionen', new Error('Die Bestellpositionen gehören zu unterschiedlichen Kunden.'));
|
||||
// return;
|
||||
// }
|
||||
|
||||
this._cacheService.set<DBHOrderItemListItemDTO[]>(
|
||||
{
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="cta-close" (click)="navigateBack({})" type="button">Abbrechen</button>
|
||||
<button class="cta-close" (click)="navigation.emit({})" type="button">Abbrechen</button>
|
||||
<button class="cta-save" [disabled]="control.invalid || control.disabled" type="submit">Speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -16,7 +16,15 @@ import {
|
||||
import { UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { DomainOmsService } from '@domain/oms';
|
||||
import { emailNotificationValidator, mobileNotificationValidator } from '@shared/components/notification-channel-control';
|
||||
import { NotificationChannel, OrderItemListItemDTO, StockStatusCodeDTO, VATDTO } from '@swagger/oms';
|
||||
import {
|
||||
DBHOrderItemListItemDTO,
|
||||
NotificationChannel,
|
||||
OrderItemListItemDTO,
|
||||
OrderItemProcessingStatusValue,
|
||||
OrderItemSubsetDTO,
|
||||
StockStatusCodeDTO,
|
||||
VATDTO,
|
||||
} from '@swagger/oms';
|
||||
import { DateAdapter } from '@ui/common';
|
||||
import { UiErrorModalComponent, UiModalService } from '@ui/modal';
|
||||
import { UiSelectOptionComponent } from '@ui/select';
|
||||
@@ -37,7 +45,7 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
@ViewChildren('autosize') autosize: QueryList<CdkTextareaAutosize>;
|
||||
|
||||
@Output()
|
||||
navigation = new EventEmitter<{ options?: { processingStatus?: number } }>();
|
||||
navigation = new EventEmitter<Partial<DBHOrderItemListItemDTO>>();
|
||||
|
||||
@Input()
|
||||
items: OrderItemListItemDTO[];
|
||||
@@ -216,10 +224,6 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
item.pickUpDeadline = deadline;
|
||||
}
|
||||
|
||||
navigateBack({ processingStatus }: { processingStatus?: number }) {
|
||||
processingStatus ? this.navigation.emit({ options: { processingStatus } }) : this.navigation.emit({});
|
||||
}
|
||||
|
||||
async generateNotification(notificationChannels: NotificationChannel[]) {
|
||||
if (!notificationChannels || notificationChannels.length === 0) {
|
||||
return;
|
||||
@@ -270,7 +274,8 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
}
|
||||
}
|
||||
|
||||
let newProcessingStatus: number;
|
||||
let newProcessingStatus: OrderItemProcessingStatusValue;
|
||||
let changedOrderItemSubsets: OrderItemSubsetDTO[] = [];
|
||||
for (let itemCtrl of control.items) {
|
||||
const orderItemId = itemCtrl.orderItemId;
|
||||
const orderItemSubsetId = itemCtrl.orderItemSubsetId;
|
||||
@@ -318,34 +323,53 @@ export class SharedGoodsInOutOrderEditComponent implements OnChanges, OnDestroy
|
||||
|
||||
try {
|
||||
if (this.isOrderItemSubsetDirty(formGroup)) {
|
||||
await this.omsService
|
||||
.patchOrderItemSubset({
|
||||
orderId,
|
||||
orderItemId,
|
||||
orderItemSubsetId,
|
||||
orderItemSubset: {
|
||||
compartmentCode:
|
||||
itemCtrl.compartmentInfo && itemCtrl.compartmentCode
|
||||
? itemCtrl.compartmentCode.replace('_' + itemCtrl.compartmentInfo, '')
|
||||
: itemCtrl.compartmentCode,
|
||||
compartmentInfo: itemCtrl.compartmentInfo || '',
|
||||
estimatedShippingDate: itemCtrl.estimatedShippingDate || null,
|
||||
compartmentStop: itemCtrl.pickUpDeadline || null,
|
||||
specialComment: itemCtrl.specialComment || '',
|
||||
ssc: itemCtrl.ssc,
|
||||
sscText: itemCtrl.sscText !== '' ? itemCtrl.sscText.substring(3) : '',
|
||||
isPrebooked: itemCtrl.isPrebooked,
|
||||
},
|
||||
})
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
changedOrderItemSubsets.push(
|
||||
await this.omsService
|
||||
.patchOrderItemSubset({
|
||||
orderId,
|
||||
orderItemId,
|
||||
orderItemSubsetId,
|
||||
orderItemSubset: {
|
||||
compartmentCode:
|
||||
itemCtrl.compartmentInfo && itemCtrl.compartmentCode
|
||||
? itemCtrl.compartmentCode.replace('_' + itemCtrl.compartmentInfo, '')
|
||||
: itemCtrl.compartmentCode,
|
||||
compartmentInfo: itemCtrl.compartmentInfo || '',
|
||||
estimatedShippingDate: itemCtrl.estimatedShippingDate || null,
|
||||
compartmentStop: itemCtrl.pickUpDeadline || null,
|
||||
specialComment: itemCtrl.specialComment || '',
|
||||
ssc: itemCtrl.ssc,
|
||||
sscText: itemCtrl.sscText !== '' ? itemCtrl.sscText.substring(3) : '',
|
||||
isPrebooked: itemCtrl.isPrebooked,
|
||||
},
|
||||
})
|
||||
.pipe(first())
|
||||
.toPromise()
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
this._modal.open({ content: UiErrorModalComponent, data: error, title: 'Fehler beim Aktualisieren des Bestellpostens' });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
this.navigateBack({ processingStatus: newProcessingStatus });
|
||||
|
||||
if (changedOrderItemSubsets.length === 0) {
|
||||
this.navigation.emit({});
|
||||
return;
|
||||
}
|
||||
|
||||
if (changedOrderItemSubsets.length === 1) {
|
||||
this.navigation.emit({
|
||||
processingStatus: newProcessingStatus,
|
||||
compartmentCode: changedOrderItemSubsets[0].compartmentCode,
|
||||
compartmentInfo: changedOrderItemSubsets[0].compartmentInfo,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.navigation.emit({
|
||||
processingStatus: newProcessingStatus,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
this.enableControlFields();
|
||||
|
||||
Reference in New Issue
Block a user