From 86a5734749765b9777a4e6a38e77382e88f2c7f1 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Tue, 28 Sep 2021 09:31:30 +0200 Subject: [PATCH] Merge pull request #140 in TEA/mina-sidor-fa-web from bugfix/TV-699 to next Squashed commit of the following: commit 649afa24e8e5b1e99bc2c4bc7b5ac304bd79f7f1 Author: Erik Tiekstra Date: Tue Sep 28 09:30:43 2021 +0200 Fixed small linting issues and text-change after PR commit bc3716f037d3b1fce8b55fc875d9d68cb555e2c6 Author: Erik Tiekstra Date: Tue Sep 28 08:44:38 2021 +0200 Fixed issue with error state on handledare-select --- CHANGELOG.md | 1 + .../src/app/pages/avrop/avrop.component.html | 12 +++++------- .../src/app/pages/avrop/avrop.component.ts | 2 +- .../src/app/shared/services/avrop.service.ts | 15 +++++++++------ apps/mina-sidor-fa/src/assets/CHANGELOG.md | 1 + 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12cd822..023b639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - **deltagare:** Now fetching data using "genomforandeReferens" instead of "sokandeId" to avoid wrong data. [TV-692](https://jira.arbetsformedlingen.se/browse/TV-692) - **authorization:** Whenever the API throws a "403 Forbidden" error we now show an unauthorized message. [TV-695](https://jira.arbetsformedlingen.se/browse/TV-695) +- **avrop:** Fixed error-state on handledare select. [TV-699](https://jira.arbetsformedlingen.se/browse/TV-699) ## [2.0.0](https://bitbucket.arbetsformedlingen.se/projects/tea/repos/mina-sidor-fa-web/compare/diff?targetBranch=refs%2Ftags%2Fv1.5.0&sourceBranch=refs%2Ftags%2Fv2.0.0) (2021-09-24) diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html index 137d150..3d3ab99 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html @@ -51,14 +51,12 @@ af-label="Välj handledare att tilldela" af-placeholder="Välj handledare" [afRequired]="true" - af-validation="error" + af-validation-text="Handledare måste väljas" + [afValidation]="(error$ | async) ? 'error' : 'neutral'" (afOnChange)="changeHandledare($event.detail)" > - @@ -68,7 +66,7 @@ -

Välj deltagare att tilldela handledare

+

Välj deltagare att tilldela handledare

= this.avropService.avropData$; selectedAvrop$: Observable = this.avropService.selectedAvrop$; availableHandledare$: Observable = this.avropService.availableHandledare$; - selectedHandledare$: Observable = this.avropService.selectedHandledare$; + selectedHandledare$: Observable = this.avropService.selectedHandledare$; avropIsLocked$: Observable = this.avropService.avropIsLocked$; handledareConfirmed$: Observable = this.avropService.handledareIsConfirmed$; avropIsSubmitted$: Observable = this.avropService.avropIsSubmitted$; diff --git a/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts b/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts index 3a2bbe0..016556e 100644 --- a/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts +++ b/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts @@ -4,7 +4,7 @@ import { AvropCompact, AvropCompactData } from '@msfa-models/avrop.model'; import { Handledare } from '@msfa-models/handledare.model'; import { AvropApiService } from '@msfa-services/api/avrop-api.service'; import { MultiselectFilterOption } from '@msfa-shared/components/multiselect/multiselect-filter-option'; -import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; +import { BehaviorSubject, combineLatest, Observable, of } from 'rxjs'; import { filter, map, switchMap, tap } from 'rxjs/operators'; type Step = 1 | 2 | 3 | 4; @@ -34,12 +34,13 @@ export class AvropService { public filteredKommuner$: Observable = this._filteredKommuner$.asObservable(); public selectedAvrop$: Observable = this._selectedAvrop$.asObservable(); public avropIsLocked$: Observable = this._avropIsLocked$.asObservable(); - public selectedHandledare$: Observable = this._selectedHandledareId$.pipe( - filter(selectedHandledare => !!selectedHandledare), + public selectedHandledare$: Observable = this._selectedHandledareId$.pipe( switchMap(handledareId => - this.availableHandledare$.pipe( - map(availableHandledare => availableHandledare.find(handledare => handledare.ciamUserId === handledareId)) - ) + handledareId + ? this.availableHandledare$.pipe( + map(availableHandledare => availableHandledare.find(handledare => handledare.ciamUserId === handledareId)) + ) + : of(null as null) ) ); public handledareIsConfirmed$: Observable = this._handledareIsConfirmed$.asObservable(); @@ -201,6 +202,7 @@ export class AvropService { public unconfirmHandledare(): void { this.resetError(); + this._selectedHandledareId$.next(null); this._handledareIsConfirmed$.next(false); } @@ -221,6 +223,7 @@ export class AvropService { } public assignHandledare(handledareId: string): void { + this.resetError(); this._selectedHandledareId$.next(handledareId); } diff --git a/apps/mina-sidor-fa/src/assets/CHANGELOG.md b/apps/mina-sidor-fa/src/assets/CHANGELOG.md index 12cd822..023b639 100644 --- a/apps/mina-sidor-fa/src/assets/CHANGELOG.md +++ b/apps/mina-sidor-fa/src/assets/CHANGELOG.md @@ -4,6 +4,7 @@ - **deltagare:** Now fetching data using "genomforandeReferens" instead of "sokandeId" to avoid wrong data. [TV-692](https://jira.arbetsformedlingen.se/browse/TV-692) - **authorization:** Whenever the API throws a "403 Forbidden" error we now show an unauthorized message. [TV-695](https://jira.arbetsformedlingen.se/browse/TV-695) +- **avrop:** Fixed error-state on handledare select. [TV-699](https://jira.arbetsformedlingen.se/browse/TV-699) ## [2.0.0](https://bitbucket.arbetsformedlingen.se/projects/tea/repos/mina-sidor-fa-web/compare/diff?targetBranch=refs%2Ftags%2Fv1.5.0&sourceBranch=refs%2Ftags%2Fv2.0.0) (2021-09-24)