TSK-1488: fixed error while saving workbasket information (#1374)

This commit is contained in:
Chi Nguyen 2020-12-14 14:10:36 +01:00 committed by GitHub
parent ab3a417955
commit 164a7dffe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -68,6 +68,9 @@ export class WorkbasketDistributionTargetsComponent implements OnInit, OnDestroy
@Select(WorkbasketSelectors.buttonAction)
buttonAction$: Observable<ButtonAction>;
@Select(WorkbasketSelectors.selectedWorkbasket)
selectedWorkbasket$: Observable<Workbasket>;
destroy$ = new Subject<void>();
constructor(
@ -83,8 +86,15 @@ export class WorkbasketDistributionTargetsComponent implements OnInit, OnDestroy
* would be ideal to completely redo whole components using drag and drop angular components and clearer logics
*/
ngOnInit() {
this.store.dispatch(new GetWorkbasketDistributionTargets(this.workbasket._links.distributionTargets.href));
this.store.dispatch(new GetAvailableDistributionTargets());
this.selectedWorkbasket$
.pipe(filter((selectedWorkbasket) => typeof selectedWorkbasket !== 'undefined'))
.subscribe((selectedWorkbasket) => {
this.workbasket = selectedWorkbasket;
});
if (Object.keys(this.workbasket).length !== 0) {
this.store.dispatch(new GetWorkbasketDistributionTargets(this.workbasket._links.distributionTargets.href));
this.store.dispatch(new GetAvailableDistributionTargets());
}
this.availableDistributionTargets$
.pipe(takeUntil(this.destroy$))

View File

@ -382,6 +382,16 @@ export class WorkbasketState implements NgxsAfterBootstrap {
ctx.patchState({
workbasketDistributionTargets: updatedWorkbasketsDistributionTargets
});
const workbasketId = ctx.getState().selectedWorkbasket?.workbasketId;
if (typeof workbasketId !== 'undefined') {
this.workbasketService.getWorkBasket(workbasketId).subscribe((selectedWorkbasket) => {
ctx.patchState({
selectedWorkbasket,
action: ACTION.READ
});
});
}
this.requestInProgressService.setRequestInProgress(false);
this.notificationService.showToast(
NOTIFICATION_TYPES.SUCCESS_ALERT_8,