mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Shelf State Data FetchResults
This commit is contained in:
@@ -24,22 +24,26 @@ export class SearchEffects {
|
||||
this.initRemoveProcess();
|
||||
}
|
||||
|
||||
fetchResult$ = createEffect(() =>
|
||||
fetchResults$ = createEffect(() =>
|
||||
this.actions$.pipe(
|
||||
ofType(actions.fetchResult),
|
||||
withLatestFrom(((a) => this.searchStateFacade.getProcess$(a.id))()),
|
||||
switchMap(([a, process]) =>
|
||||
this.orderService
|
||||
.OrderWarenausgabeResponse({
|
||||
branchNumber: this.branchService.getCurrentBranchNumber(),
|
||||
input: process.input,
|
||||
skip: process.hits || 0,
|
||||
take: 20,
|
||||
})
|
||||
.pipe(
|
||||
catchError((err) => of<StrictHttpResponse<ListResponseArgsOfOrderItemListItemDTO>>(err)),
|
||||
map((response) => actions.fetchResultDone({ id: a.id, response }))
|
||||
switchMap((a) =>
|
||||
of(a).pipe(
|
||||
withLatestFrom(this.searchStateFacade.getProcess$(a.id)),
|
||||
flatMap(([_, process]) =>
|
||||
this.orderService
|
||||
.OrderWarenausgabeResponse({
|
||||
branchNumber: this.branchService.getCurrentBranchNumber(),
|
||||
input: process.input,
|
||||
skip: process.result.length || 0,
|
||||
take: 20,
|
||||
})
|
||||
.pipe(
|
||||
catchError((err) => of<StrictHttpResponse<ListResponseArgsOfOrderItemListItemDTO>>(err)),
|
||||
map((response) => actions.fetchResultDone({ id: a.id, response }))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Store as NgxsStore } from '@ngxs/store';
|
||||
import * as actions from './search.actions';
|
||||
import * as selectors from './search.selectors';
|
||||
import { SharedSelectors } from 'apps/sales/src/app/core/store/selectors/shared.selectors';
|
||||
import { map, first, switchMap } from 'rxjs/operators';
|
||||
import { map, first, switchMap, filter } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { OrderItemListItemDTO } from '@swagger/oms';
|
||||
import { GroupedByCustomer } from './defs';
|
||||
@@ -38,7 +38,10 @@ export class SearchStateFacade {
|
||||
constructor(private store: Store<any>, private ngxsStore: NgxsStore) {}
|
||||
|
||||
getProcessId$() {
|
||||
return this.ngxsStore.select(SharedSelectors.getCurrentProcess).pipe(map((currentProcess) => currentProcess.id));
|
||||
return this.ngxsStore.select(SharedSelectors.getCurrentProcess).pipe(
|
||||
filter((process) => !!process && !!process.id),
|
||||
map((currentProcess) => currentProcess.id)
|
||||
);
|
||||
}
|
||||
|
||||
getProcessId() {
|
||||
@@ -105,4 +108,12 @@ export class SearchStateFacade {
|
||||
}
|
||||
this.store.dispatch(actions.fetchResult({ id: processId }));
|
||||
}
|
||||
|
||||
async clearResult(id?: number) {
|
||||
let processId = id;
|
||||
if (typeof processId !== 'number') {
|
||||
processId = await this.getProcessId();
|
||||
}
|
||||
this.store.dispatch(actions.clearResults({ id: processId }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user