mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merge branch 'develop' into release/3.0
This commit is contained in:
@@ -125,11 +125,11 @@ export abstract class PickupShelfBaseComponent implements OnInit {
|
||||
const filterQueryParams = this.listStore.filter.getQueryParams();
|
||||
|
||||
// Only Update QueryParams if the user is already on the details, edit or history page
|
||||
const view: string = this.activatedRoute.snapshot.data.view;
|
||||
if (['filter', 'details', 'edit', 'history'].includes(view)) {
|
||||
await this.router.navigate([], { queryParams: { ...queryParams, ...filterQueryParams }, skipLocationChange: true });
|
||||
return;
|
||||
}
|
||||
// const view: string = this.activatedRoute.snapshot.data.view;
|
||||
// if (['filter', 'details', 'edit', 'history'].includes(view)) {
|
||||
// await this.router.navigate([], { queryParams: { ...queryParams, ...filterQueryParams }, skipLocationChange: true });
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (response.hits === 1) {
|
||||
const detailsPath = await this.getPathForDetail(response.result[0]).pipe(take(1)).toPromise();
|
||||
|
||||
@@ -126,7 +126,7 @@ export class PickUpShelfInListComponent implements OnInit, AfterViewInit {
|
||||
.subscribe(([_, queryParams]) => {
|
||||
if (!this.store.list.length || !isEqual(queryParams, this.cleanupQueryParams(this.store.filter.getQueryParams()))) {
|
||||
this.store.setQueryParams(queryParams);
|
||||
this.store.fetchList();
|
||||
this.store.fetchList({ emitFetchListResponse: false });
|
||||
}
|
||||
|
||||
const scrollPos = this._getScrollPositionFromCache();
|
||||
|
||||
@@ -245,7 +245,7 @@ export class PickupShelfOutListComponent implements OnInit, AfterViewInit {
|
||||
action,
|
||||
items: selectedItems,
|
||||
});
|
||||
this.store.fetchList();
|
||||
this.store.fetchList({ emitFetchListResponse: false });
|
||||
this.store.resetSelectedListItems();
|
||||
this.loadingFetchedActionButton$.next(false);
|
||||
|
||||
|
||||
@@ -491,13 +491,15 @@ export class PickupShelfDetailsStore extends ComponentStore<PickupShelfDetailsSt
|
||||
};
|
||||
|
||||
fetchCustomerSuccess = (res: ListResponseArgsOfCustomerInfoDTO) => {
|
||||
const customers = res.result?.filter((res) => res.customerNumber === this.order.buyer.buyerNumber);
|
||||
|
||||
// check if response contains exactly one customer
|
||||
if (res.result.length > 1) {
|
||||
if (customers.length > 1) {
|
||||
this._modal.error('Fehler beim Laden des Kunden', new Error('Es wurde mehr als ein Kunde gefunden.'));
|
||||
return;
|
||||
}
|
||||
|
||||
const customer = res.result[0];
|
||||
const customer = customers[0];
|
||||
|
||||
if (!customer) {
|
||||
this.patchState({ fetchingCustomer: false });
|
||||
|
||||
@@ -25,7 +25,7 @@ import { ToasterService } from '@shared/shell';
|
||||
import { UiModalService } from '@ui/modal';
|
||||
|
||||
import * as Selectors from './pickup-shelf.selectors';
|
||||
import { Subject, combineLatest } from 'rxjs';
|
||||
import { Observable, Subject, combineLatest } from 'rxjs';
|
||||
import { CacheService } from '@core/cache';
|
||||
import { Filter } from '@shared/components/filter';
|
||||
|
||||
@@ -204,19 +204,21 @@ export class PickupShelfStore extends ComponentStore<PickupShelfState> implement
|
||||
this.patchState({ fetchingQuerySettings: false });
|
||||
};
|
||||
|
||||
delayWhenFilterIsNotReady = delayWhen(() =>
|
||||
delayWhenFilterIsNotReady = delayWhen((value: { emitFetchListResponse: boolean } | void) =>
|
||||
this.filter$.pipe(
|
||||
filter((filter) => !!filter),
|
||||
take(1)
|
||||
)
|
||||
);
|
||||
|
||||
fetchList = this.effect((trigger$) =>
|
||||
fetchList = this.effect((trigger$: Observable<{ emitFetchListResponse: boolean } | void>) =>
|
||||
trigger$.pipe(
|
||||
this.delayWhenFilterIsNotReady,
|
||||
withLatestFrom(this.filter$, this.processId$),
|
||||
map(([_, filter, processId]) => this.beforeFetchList(filter, processId)),
|
||||
switchMap(({ filter, processId, list }) =>
|
||||
map(([{ emitFetchListResponse } = { emitFetchListResponse: true }, filter, processId]) =>
|
||||
this.beforeFetchList(emitFetchListResponse, filter, processId)
|
||||
),
|
||||
switchMap(({ emitFetchListResponse, filter, processId, list }) =>
|
||||
this._pickupShelfIOService
|
||||
.search({
|
||||
...filter.getQueryToken(),
|
||||
@@ -225,7 +227,7 @@ export class PickupShelfStore extends ComponentStore<PickupShelfState> implement
|
||||
.pipe(
|
||||
takeUntil(this._cancelListRequests),
|
||||
tapResponse(
|
||||
(res) => this.fetchListDone({ processId, queryParams: filter.getQueryParams() })(res),
|
||||
(res) => this.fetchListDone({ processId, queryParams: filter.getQueryParams(), emitFetchListResponse })(res),
|
||||
(err) => this.fetchListError(err)
|
||||
)
|
||||
)
|
||||
@@ -233,7 +235,7 @@ export class PickupShelfStore extends ComponentStore<PickupShelfState> implement
|
||||
)
|
||||
);
|
||||
|
||||
private beforeFetchList = (filter: Filter, processId: number) => {
|
||||
private beforeFetchList = (emitFetchListResponse: boolean, filter: Filter, processId: number) => {
|
||||
this.cancelListRequests();
|
||||
const queryToken = filter.getQueryParams();
|
||||
const cachedListResponse = this._cacheService.get<ListResponseArgsOfDBHOrderItemListItemDTO>({ processId, queryToken });
|
||||
@@ -247,14 +249,23 @@ export class PickupShelfStore extends ComponentStore<PickupShelfState> implement
|
||||
this.patchState({ fetchingList: true, list: [], listHits: 0 });
|
||||
}
|
||||
|
||||
return { filter, processId, list };
|
||||
return { emitFetchListResponse, filter, processId, list };
|
||||
};
|
||||
|
||||
private fetchListDone = ({ processId, queryParams }: { processId: number; queryParams: Record<string, string> }) => (
|
||||
response: ListResponseArgsOfDBHOrderItemListItemDTO
|
||||
) => {
|
||||
private fetchListDone = ({
|
||||
processId,
|
||||
queryParams,
|
||||
emitFetchListResponse,
|
||||
}: {
|
||||
processId: number;
|
||||
queryParams: Record<string, string>;
|
||||
emitFetchListResponse: boolean;
|
||||
}) => (response: ListResponseArgsOfDBHOrderItemListItemDTO) => {
|
||||
this.patchState({ fetchingList: false, list: response.result, listHits: response.hits });
|
||||
this._fetchListResponse.next({ processId, response, queryParams });
|
||||
if (emitFetchListResponse) {
|
||||
this._fetchListResponse.next({ processId, response, queryParams });
|
||||
}
|
||||
|
||||
this._cacheService.set<ListResponseArgsOfDBHOrderItemListItemDTO>({ processId, queryToken: queryParams }, response, { persist: true });
|
||||
};
|
||||
|
||||
|
||||
@@ -268,16 +268,16 @@ export function getAvailabilityPriceForPurchaseOption(
|
||||
|
||||
if (purchaseOption === 'delivery') {
|
||||
if (isDigCustomer(state)) {
|
||||
deliveryAvailability = digAvailability;
|
||||
deliveryAvailability = digAvailability ?? deliveryAvailability;
|
||||
} else if (isB2bCustomer(state)) {
|
||||
deliveryAvailability = b2bAvailability;
|
||||
deliveryAvailability = b2bAvailability ?? deliveryAvailability;
|
||||
}
|
||||
}
|
||||
|
||||
deliveryAvailability = deliveryAvailability ?? digAvailability ?? b2bAvailability;
|
||||
|
||||
if (purchaseOption === 'delivery') {
|
||||
availability = deliveryAvailability;
|
||||
availability = deliveryAvailability ?? availability;
|
||||
}
|
||||
|
||||
// Wennn Artkkel nicht Preisgebinden ist, dann den günstigeren Preis nehmen wenn priceMaintained false ist
|
||||
|
||||
Reference in New Issue
Block a user