Merge tag 'Abholfach-zubuchen-und-Coveransicht' into develop

Abholfach-zubuchen-und-Coveransicht Abholfach-zubuchen-und-Coveransicht
This commit is contained in:
Lorenz Hilpert
2024-11-19 13:54:23 +01:00
2 changed files with 19 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
import { Component, ChangeDetectionStrategy, inject, OnInit, AfterViewInit, ViewChild } from '@angular/core';
import { Component, ChangeDetectionStrategy, inject, OnInit, AfterViewInit, ViewChild, effect } 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';
@@ -11,7 +11,7 @@ import { OnInitDirective } from '@shared/directives/element-lifecycle';
import { PickupShelfInNavigationService } from '@shared/services/navigation';
import { BehaviorSubject, asapScheduler, combineLatest } from 'rxjs';
import { distinctUntilChanged, map, shareReplay } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
import { DBHOrderItemListItemDTO, KeyValueDTOOfStringAndString } from '@swagger/oms';
import { UiErrorModalComponent, UiModalService } from '@ui/modal';
import { ActivatedRoute } from '@angular/router';
@@ -52,6 +52,8 @@ export class PickupShelfInDetailsComponent extends PickupShelfDetailsBaseCompone
order$ = this.store.order$;
$customerNumber = toSignal(this.store.customerNumber$);
orderItems$ = this.store.orderItems$.pipe(shareReplay(1));
noOrderItemsFound$ = this.store.noOrderItemsFound$;
@@ -105,6 +107,14 @@ export class PickupShelfInDetailsComponent extends PickupShelfDetailsBaseCompone
private _activatedRoute: ActivatedRoute,
) {
super();
effect(() => {
const customerNumber = this.$customerNumber();
if (customerNumber) {
this.store.fetchCoverOrderItems(customerNumber);
}
});
}
ngOnInit() {
@@ -124,11 +134,11 @@ export class PickupShelfInDetailsComponent extends PickupShelfDetailsBaseCompone
});
// Fix #4696 - Always Fetch Cover Order Items
this._activatedRoute.params.pipe(distinctUntilChanged(isEqual), takeUntilDestroyed(this.destroyRef)).subscribe((_) => {
if (!this.store.coverOrderItems || this.store.coverOrderItems.length === 0) {
this.store.fetchCoverOrderItems();
}
});
// this._activatedRoute.params.pipe(distinctUntilChanged(isEqual), takeUntilDestroyed(this.destroyRef)).subscribe((_) => {
// if (!this.store.coverOrderItems || this.store.coverOrderItems.length === 0) {
// this.store.fetchCoverOrderItems();
// }
// });
}
ngAfterViewInit() {

View File

@@ -700,19 +700,10 @@ export class PickupShelfDetailsStore extends ComponentStore<PickupShelfDetailsSt
return this.select(Selectors.selectLatestSmsNotificationDate2(orderItemSubsetId));
};
delayWhenCustomerNumberNotExists = delayWhen(() =>
this.customerNumber$.pipe(
filter((cn) => !!cn),
take(1),
),
);
fetchCoverOrderItems = this.effect((trigger$: Observable<void>) =>
fetchCoverOrderItems = this.effect((trigger$: Observable<string>) =>
trigger$.pipe(
this.delayWhenCustomerNumberNotExists,
tap(() => this.beforeFetchCoverOrderItems()),
withLatestFrom(this.customerNumber$),
switchMap(([_, customerNumber]) =>
switchMap((customerNumber) =>
this._pickupShelfIOService
.getOrderItemsByCustomerNumber({
customerNumber,