feat(avrop): Updated Avrop response model and fixed mappings. (TV-873)
Squashed commit of the following: commit a03d179cd05a2266b11ac01acb2f2e07f9bb943d Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Thu Nov 4 08:31:59 2021 +0100 Updated name of AvropData model to AvropAndMeta commit d5e40567c991c15b23ac5b0978b3cc9c7084d697 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Thu Nov 4 08:26:42 2021 +0100 Updated Avrop response model and mapping function
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ChangeDetectionStrategy, Component, OnDestroy } from '@angular/core';
|
||||
import { AvropCompact, AvropCompactData } from '@msfa-models/avrop.model';
|
||||
import { Avrop, AvropAndMeta } from '@msfa-models/avrop.model';
|
||||
import { Handledare } from '@msfa-models/handledare.model';
|
||||
import { AvropService } from '@msfa-services/avrop.service';
|
||||
import { Observable } from 'rxjs';
|
||||
@@ -14,8 +14,8 @@ export class AvropComponent implements OnDestroy {
|
||||
readonly totalAmountOfSteps = 3;
|
||||
currentStep$: Observable<number> = this.avropService.currentStep$;
|
||||
error$: Observable<string> = this.avropService.error$;
|
||||
avropData$: Observable<AvropCompactData> = this.avropService.avropData$;
|
||||
selectedAvrop$: Observable<AvropCompact[]> = this.avropService.selectedAvrop$;
|
||||
avropData$: Observable<AvropAndMeta> = this.avropService.avropData$;
|
||||
selectedAvrop$: Observable<Avrop[]> = this.avropService.selectedAvrop$;
|
||||
availableHandledare$: Observable<Handledare[]> = this.avropService.availableHandledare$;
|
||||
selectedHandledare$: Observable<Handledare | null> = this.avropService.selectedHandledare$;
|
||||
avropIsLocked$: Observable<boolean> = this.avropService.avropIsLocked$;
|
||||
@@ -30,7 +30,7 @@ export class AvropComponent implements OnDestroy {
|
||||
this.returnToStep1();
|
||||
}
|
||||
|
||||
updateSelectedAvrop(deltagareList: AvropCompact[], currentStep: number): void {
|
||||
updateSelectedAvrop(deltagareList: Avrop[], currentStep: number): void {
|
||||
if (currentStep !== 1 && !deltagareList.length) {
|
||||
this.avropService.goToStep1();
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { Avrop, AvropCompact } from '@msfa-models/avrop.model';
|
||||
import { Avrop } from '@msfa-models/avrop.model';
|
||||
import { Handledare } from '@msfa-models/handledare.model';
|
||||
import { PaginationMeta } from '@msfa-models/pagination-meta.model';
|
||||
|
||||
@@ -10,18 +10,18 @@ import { PaginationMeta } from '@msfa-models/pagination-meta.model';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class AvropListComponent {
|
||||
@Input() availableAvrop: AvropCompact[];
|
||||
@Input() availableAvrop: Avrop[];
|
||||
@Input() paginationMeta: PaginationMeta;
|
||||
@Input() selectedAvrop: AvropCompact[];
|
||||
@Input() selectedAvrop: Avrop[];
|
||||
@Input() handledare: Handledare;
|
||||
@Input() isLocked: boolean;
|
||||
@Input() isSubmitted: boolean;
|
||||
@Input() handledareConfirmed: boolean;
|
||||
@Input() avropLoading: boolean;
|
||||
@Output() selectionChanged = new EventEmitter<AvropCompact[]>();
|
||||
@Output() selectionChanged = new EventEmitter<Avrop[]>();
|
||||
@Output() paginated = new EventEmitter<number>();
|
||||
|
||||
get avropRows(): AvropCompact[] {
|
||||
get avropRows(): Avrop[] {
|
||||
return this.isLocked ? this.selectedAvrop : this.availableAvrop;
|
||||
}
|
||||
get currentPage(): number {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ButtonVariation } from '@af/digi-ng/_button/button';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { AvropCompact } from '@msfa-models/avrop.model';
|
||||
import { Avrop } from '@msfa-models/avrop.model';
|
||||
import { Handledare } from '@msfa-models/handledare.model';
|
||||
|
||||
@Component({
|
||||
@@ -10,7 +10,7 @@ import { Handledare } from '@msfa-models/handledare.model';
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class AvropRowComponent {
|
||||
@Input() avrop: AvropCompact;
|
||||
@Input() avrop: Avrop;
|
||||
@Input() isSelected: boolean;
|
||||
@Input() isLocked: boolean;
|
||||
@Input() isSubmitted: boolean;
|
||||
|
||||
@@ -2,38 +2,28 @@ import { PaginationMeta } from '@msfa-models/pagination-meta.model';
|
||||
|
||||
export interface AvropResponse {
|
||||
id: string;
|
||||
deltagare: string;
|
||||
genomforandeReferens: number;
|
||||
orgId: string;
|
||||
leverantorId: number;
|
||||
organisationsnummer: string;
|
||||
utforandeVerksamhetId: number;
|
||||
utforandeverksamhet: string;
|
||||
kommunKod: string;
|
||||
kommun: string;
|
||||
utforandeAdressId: number;
|
||||
adress: string;
|
||||
ordernummer: string;
|
||||
bokningsId: number;
|
||||
personnummer: string;
|
||||
sokandeId: number;
|
||||
tjanstekod: string;
|
||||
tjansteNamn: string;
|
||||
deltagandeGrad: number;
|
||||
startdatumAvrop: string;
|
||||
slutdatumAvrop: string;
|
||||
aktnummerDiariet: string;
|
||||
tolkbehov: string;
|
||||
sprakstod: string;
|
||||
fullName: string;
|
||||
tjanst: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
originalEndDate: string | null;
|
||||
sprakstod: string | null;
|
||||
tolkbehov: string | null;
|
||||
utforandeVerksamhet: string;
|
||||
utforandeAdress: string;
|
||||
sparkod: string;
|
||||
sparNamn: string;
|
||||
handledareCiamUserId: string;
|
||||
genomforandeReferens: number;
|
||||
participationFrequency: number;
|
||||
receivedTimestamp: Date;
|
||||
handledareCiamUserId: string | null;
|
||||
handledare: string;
|
||||
recievedTimestamp: Date;
|
||||
hasAvbrott: boolean;
|
||||
hasGemensamPlanering: boolean;
|
||||
|
||||
//personnummer: string;
|
||||
}
|
||||
|
||||
export interface AvropApiResponse {
|
||||
export interface AvropAndMetaResponse {
|
||||
data: AvropResponse[];
|
||||
meta: PaginationMeta;
|
||||
}
|
||||
|
||||
@@ -1,83 +1,85 @@
|
||||
import { TrackName } from '@msfa-enums/track-name.enum';
|
||||
import { mapStringToSsn } from '@msfa-utils/map-string-to-ssn.util';
|
||||
import { AvropResponse } from './api/avrop.response.model';
|
||||
import { PaginationMeta } from './pagination-meta.model';
|
||||
|
||||
export interface AvropCompact {
|
||||
id: string; // id
|
||||
sokandeId: number; // sokandeId
|
||||
fullName: string; // deltagare
|
||||
tjanst: string; // tjansteNamn
|
||||
startDate: Date; // startdatumAvrop
|
||||
endDate: Date; // slutdatumAvrop
|
||||
tolkbehov: string; // tolkbehov
|
||||
sprakstod: string; // sprakstod
|
||||
kommun: string; // kommun
|
||||
utforandeAdress: string; // adress
|
||||
trackCode: string; // sparkod
|
||||
trackName: TrackName; // sparNamn
|
||||
genomforandeReferens: number; // genomforandeReferens
|
||||
}
|
||||
|
||||
export interface Avrop extends AvropCompact {
|
||||
ssn: string; // personnummer
|
||||
genomforandeReferens: number; // genomforandeReferens
|
||||
participationFrequency: number; // deltagandeGrad
|
||||
utforandeVerksamhet: string; // utforandeverksamhet
|
||||
export interface Avrop {
|
||||
id: string;
|
||||
fullName: string;
|
||||
tjanst: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
originalEndDate: Date;
|
||||
sprakstod: string;
|
||||
tolkbehov: string;
|
||||
utforandeVerksamhet: string;
|
||||
utforandeAdress: string;
|
||||
trackCode: string;
|
||||
trackName: TrackName;
|
||||
genomforandeReferens: number;
|
||||
participationFrequency: number;
|
||||
handledareCiamUserId: string;
|
||||
handledare: string;
|
||||
receivedTimestamp: Date;
|
||||
hasGemensamPlanering: boolean;
|
||||
hasAvbrott: boolean;
|
||||
|
||||
ssn: string; // personnummer
|
||||
kommun: string;
|
||||
}
|
||||
|
||||
export interface AvropCompactData {
|
||||
data: AvropCompact[];
|
||||
export interface AvropAndMeta {
|
||||
data: Avrop[];
|
||||
meta: PaginationMeta;
|
||||
}
|
||||
|
||||
export function mapAvropResponseToAvrop(data: AvropResponse): Avrop {
|
||||
const {
|
||||
id,
|
||||
sokandeId,
|
||||
deltagare,
|
||||
tjansteNamn,
|
||||
startdatumAvrop,
|
||||
slutdatumAvrop,
|
||||
tolkbehov,
|
||||
fullName,
|
||||
tjanst,
|
||||
startDate,
|
||||
endDate,
|
||||
originalEndDate,
|
||||
sprakstod,
|
||||
kommun,
|
||||
adress,
|
||||
tolkbehov,
|
||||
utforandeAdress,
|
||||
utforandeVerksamhet,
|
||||
sparkod,
|
||||
personnummer,
|
||||
genomforandeReferens,
|
||||
deltagandeGrad,
|
||||
utforandeverksamhet,
|
||||
participationFrequency,
|
||||
receivedTimestamp,
|
||||
handledareCiamUserId,
|
||||
handledare,
|
||||
recievedTimestamp,
|
||||
hasAvbrott,
|
||||
hasGemensamPlanering,
|
||||
|
||||
// kommun
|
||||
// personnummer,
|
||||
} = data;
|
||||
|
||||
return {
|
||||
id,
|
||||
sokandeId,
|
||||
fullName: deltagare,
|
||||
tjanst: tjansteNamn,
|
||||
startDate: new Date(startdatumAvrop),
|
||||
endDate: new Date(slutdatumAvrop),
|
||||
tolkbehov: tolkbehov,
|
||||
sprakstod: sprakstod,
|
||||
kommun,
|
||||
utforandeAdress: adress,
|
||||
fullName,
|
||||
tjanst,
|
||||
startDate: new Date(startDate),
|
||||
endDate: new Date(endDate),
|
||||
originalEndDate: new Date(originalEndDate),
|
||||
tolkbehov,
|
||||
sprakstod,
|
||||
utforandeVerksamhet,
|
||||
utforandeAdress,
|
||||
// kommun,
|
||||
kommun: '',
|
||||
trackCode: sparkod,
|
||||
trackName: (TrackName[sparkod] || TrackName.UNKNOWN) as TrackName,
|
||||
ssn: mapStringToSsn(personnummer),
|
||||
// ssn: mapStringToSsn(personnummer),
|
||||
ssn: '',
|
||||
genomforandeReferens,
|
||||
participationFrequency: deltagandeGrad,
|
||||
utforandeVerksamhet: utforandeverksamhet,
|
||||
handledareCiamUserId: handledareCiamUserId,
|
||||
participationFrequency,
|
||||
handledareCiamUserId,
|
||||
handledare,
|
||||
receivedTimestamp: new Date(recievedTimestamp),
|
||||
receivedTimestamp: new Date(receivedTimestamp),
|
||||
hasAvbrott,
|
||||
hasGemensamPlanering,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { AvropFilterResponse } from '@msfa-models/api/avrop-filter.response.model';
|
||||
import { AvropApiResponse } from '@msfa-models/api/avrop.response.model';
|
||||
import { AvropAndMetaResponse } from '@msfa-models/api/avrop.response.model';
|
||||
import { Params } from '@msfa-models/api/params.model';
|
||||
import { AvropFilter, mapResponseToAvropFilter } from '@msfa-models/avrop-filter.model';
|
||||
import { AvropCompact, AvropCompactData, mapAvropResponseToAvrop } from '@msfa-models/avrop.model';
|
||||
import { Avrop, AvropAndMeta, mapAvropResponseToAvrop } from '@msfa-models/avrop.model';
|
||||
import { CustomError, errorToCustomError } from '@msfa-models/error/custom-error';
|
||||
import { Handledare } from '@msfa-models/handledare.model';
|
||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
||||
@@ -16,20 +16,20 @@ import { catchError, filter, map } from 'rxjs/operators';
|
||||
})
|
||||
export class AvropApiService {
|
||||
private _apiBaseUrl = `${environment.api.url}/avrop`;
|
||||
private _lockedAvropSnapshot$ = new BehaviorSubject<AvropCompact[]>(null);
|
||||
private _lockedAvropSnapshot$ = new BehaviorSubject<Avrop[]>(null);
|
||||
private _availableHandledareSnapshot$ = new BehaviorSubject<Handledare[]>(null);
|
||||
private _showUnauthorizedError$ = new BehaviorSubject<boolean>(false);
|
||||
public showUnauthorizedError$: Observable<boolean> = this._showUnauthorizedError$.asObservable();
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
get lockedAvropValue(): AvropCompact[] {
|
||||
get lockedAvropValue(): Avrop[] {
|
||||
return this._lockedAvropSnapshot$.getValue();
|
||||
}
|
||||
|
||||
fetchAvrop$(params: Params): Observable<AvropCompactData | null> {
|
||||
fetchAvrop$(params: Params): Observable<AvropAndMeta | null> {
|
||||
return this.httpClient
|
||||
.get<AvropApiResponse>(`${this._apiBaseUrl}`, { params })
|
||||
.get<AvropAndMetaResponse>(`${this._apiBaseUrl}`, { params })
|
||||
.pipe(
|
||||
map(({ data, meta }) => ({ data: data.map(avrop => mapAvropResponseToAvrop(avrop)), meta })),
|
||||
catchError((error: Error & { status: number }) => {
|
||||
@@ -72,7 +72,7 @@ export class AvropApiService {
|
||||
);
|
||||
}
|
||||
|
||||
async assignHandledare(avrop: AvropCompact[], handledareId: string): Promise<void> {
|
||||
async assignHandledare(avrop: Avrop[], handledareId: string): Promise<void> {
|
||||
const params: Params = {
|
||||
avropIds: avrop.map(deltagare => deltagare.id),
|
||||
ciamUserId: handledareId,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AvropParams, Params } from '@msfa-models/api/params.model';
|
||||
import { AvropCompact, AvropCompactData } from '@msfa-models/avrop.model';
|
||||
import { Avrop, AvropAndMeta } 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';
|
||||
@@ -22,7 +22,7 @@ const DEFAULT_PARAMS: AvropParams = {
|
||||
})
|
||||
export class AvropService {
|
||||
private _params$ = new BehaviorSubject<AvropParams>(DEFAULT_PARAMS);
|
||||
private _selectedAvrop$ = new BehaviorSubject<AvropCompact[]>([]);
|
||||
private _selectedAvrop$ = new BehaviorSubject<Avrop[]>([]);
|
||||
private _avropIsLocked$ = new BehaviorSubject<boolean>(null);
|
||||
private _selectedHandledareId$ = new BehaviorSubject<string>(null);
|
||||
private _handledareIsConfirmed$ = new BehaviorSubject<boolean>(false);
|
||||
@@ -47,7 +47,7 @@ export class AvropService {
|
||||
map(({ filteredKommuner }) => filteredKommuner),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
public selectedAvrop$: Observable<AvropCompact[]> = this._selectedAvrop$.asObservable();
|
||||
public selectedAvrop$: Observable<Avrop[]> = this._selectedAvrop$.asObservable();
|
||||
public avropIsLocked$: Observable<boolean> = this._avropIsLocked$.asObservable();
|
||||
public selectedHandledare$: Observable<Handledare | null> = this._selectedHandledareId$.pipe(
|
||||
switchMap(handledareId =>
|
||||
@@ -58,7 +58,7 @@ export class AvropService {
|
||||
: of(null as null)
|
||||
)
|
||||
);
|
||||
public avropData$: Observable<AvropCompactData> = combineLatest([this._avropIsSubmitted$, this._params$]).pipe(
|
||||
public avropData$: Observable<AvropAndMeta> = combineLatest([this._avropIsSubmitted$, this._params$]).pipe(
|
||||
switchMap(() => {
|
||||
this._avropLoading$.next(true);
|
||||
return this.avropApiService.fetchAvrop$(this._filtersForAvrop).pipe(
|
||||
@@ -99,7 +99,7 @@ export class AvropService {
|
||||
shareReplay(1)
|
||||
);
|
||||
|
||||
private _lockedAvrop$: Observable<AvropCompact[]> = combineLatest([this.selectedAvrop$, this.avropIsLocked$]).pipe(
|
||||
private _lockedAvrop$: Observable<Avrop[]> = combineLatest([this.selectedAvrop$, this.avropIsLocked$]).pipe(
|
||||
map(([selectedAvrop, isLocked]) => (isLocked ? selectedAvrop : null))
|
||||
);
|
||||
|
||||
@@ -200,7 +200,7 @@ export class AvropService {
|
||||
|
||||
constructor(private avropApiService: AvropApiService, private handledareApiService: HandledareApiService) {}
|
||||
|
||||
public setSelectedAvrop(deltagare: AvropCompact[]): void {
|
||||
public setSelectedAvrop(deltagare: Avrop[]): void {
|
||||
this._selectedAvrop$.next(deltagare);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user