Fixed removal of avrop

This commit is contained in:
Erik Tiekstra
2021-09-20 11:55:40 +02:00
parent bfffed4099
commit ffc5a46807
3 changed files with 9 additions and 4 deletions

View File

@@ -50,6 +50,7 @@
af-label="Välj handledare att tilldela"
af-placeholder="Välj handledare"
[afRequired]="true"
af-validation="error"
(afOnChange)="changeHandledare($event.detail)"
>
<option
@@ -76,7 +77,7 @@
[handledare]="selectedHandledare$ | async"
[handledareConfirmed]="handledareConfirmed$ | async"
[avropLoading]="avropLoading$ | async"
(selectionChanged)="updateSelectedAvrop($event)"
(selectionChanged)="updateSelectedAvrop($event, currentStep)"
(paginated)="setNewPage($event)"
></msfa-avrop-list>
</div>

View File

@@ -29,8 +29,12 @@ export class AvropComponent {
constructor(private avropService: AvropService) {}
updateSelectedAvrop(deltagareList: Avrop[]): void {
this.avropService.setSelectedAvrop(deltagareList);
updateSelectedAvrop(deltagareList: Avrop[], currentStep: number): void {
if (currentStep !== 1 && !deltagareList.length) {
this.avropService.goToStep1();
} else {
this.avropService.setSelectedAvrop(deltagareList);
}
}
lockSelectedAvrop(): void {

View File

@@ -85,7 +85,7 @@ export class AvropService {
);
public availableHandledare$: Observable<Handledare[]> = this._lockedAvrop$.pipe(
filter(lockedAvrop => !!lockedAvrop),
filter(lockedAvrop => !!lockedAvrop?.length),
switchMap(lockedAvrop => this.avropApiService.fetchAvailableHandledare$(lockedAvrop))
);