Merge pull request #41 in TEA/dafa-web-monorepo from TV-292 to develop

Squashed commit of the following:

commit 936a5bbb0dcf8204fef864d5e6feafc1293159a9
Merge: 4bac607 1e41ab0
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Wed Aug 11 11:43:01 2021 +0200

    Merge branch 'develop' into TV-292

commit 4bac607de89e7d2732337391961077dec3ef57a9
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Wed Aug 11 09:50:57 2021 +0200

    TV-292 updated response due to database

commit e0da747dfe697c1f6b2a0e79a423c274e445be4d
Merge: ce4ed5e b621b72
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Tue Aug 10 11:47:09 2021 +0200

    Merge branch 'TV-292' of ssh://bitbucket.arbetsformedlingen.se:7999/tea/dafa-web-monorepo into TV-292

commit ce4ed5e95b918d056b7faf32c3afb5f52c2495fb
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Tue Aug 10 11:45:07 2021 +0200

    deleted property name

commit b621b7287652896e993dd21f0bb3f476c8184049
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Tue Aug 10 11:45:07 2021 +0200

    TV-292 changed property name to fullName

commit 4e50e005e17de0e641efcb0c839978c72bfe1d70
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Tue Aug 10 10:57:34 2021 +0200

    TV-292 pr review update

commit f9643c516d744a42c326512257422b2af74cbce6
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Tue Aug 10 10:38:33 2021 +0200

    corr

commit 0b60d0baa9d4979c67238ece600d55378b0cabb6
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Tue Aug 10 10:35:30 2021 +0200

    TV-292 pr review updates

commit c5ca8a5eb2f320f54b54884a0a8fec14a40363b4
Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se>
Date:   Mon Aug 9 12:51:13 2021 +0200

    TV-292 changed mock data to api requests
This commit is contained in:
Nicolas Fuentes Maturana
2021-08-11 12:11:28 +02:00
parent 1e41ab069f
commit 327075bd73
10 changed files with 86 additions and 107 deletions

View File

@@ -33,7 +33,7 @@ export class AvropService {
this.selectedKommuner$, this.selectedKommuner$,
]).pipe( ]).pipe(
switchMap(([selectedTjanster, selectedUtforandeVerksamheter, selectedKommuner]) => switchMap(([selectedTjanster, selectedUtforandeVerksamheter, selectedKommuner]) =>
this.avropApiService.getNyaDeltagare$(selectedTjanster, selectedKommuner, selectedUtforandeVerksamheter) this.avropApiService.getNyaAvrop$(selectedTjanster, selectedKommuner, selectedUtforandeVerksamheter)
) )
); );

View File

@@ -2,7 +2,7 @@
<strong>{{filterLabel}}</strong> <strong>{{filterLabel}}</strong>
<digi-form-checkbox <digi-form-checkbox
*ngFor="let filterOption of filterOptions" *ngFor="let filterOption of filterOptions"
[afLabel]="filterOption.label + ' (' + filterOption.count + ')'" [afLabel]="filterOption.label + ' (' + (filterOption.count || 0) + ')'"
(change)="setOptionState(filterOption, $event.target.checked)" (change)="setOptionState(filterOption, $event.target.checked)"
[afChecked]="isSelected(filterOption)" [afChecked]="isSelected(filterOption)"
> >

View File

@@ -14,7 +14,7 @@
<div class="avrop-table__cell"> <div class="avrop-table__cell">
<digi-typography> <digi-typography>
<strong class="avrop-table__label">Namn:</strong> <strong class="avrop-table__label">Namn:</strong>
<span>{{deltagare?.name}}</span> <span>{{deltagare?.fullName}}</span>
</digi-typography> </digi-typography>
</div> </div>
<div class="avrop-table__cell"> <div class="avrop-table__cell">
@@ -42,7 +42,7 @@
<div class="avrop-table__cell"> <div class="avrop-table__cell">
<digi-typography> <digi-typography>
<strong class="avrop-table__label">Språkstöd/Tolk:</strong> <strong class="avrop-table__label">Språkstöd/Tolk:</strong>
<span>{{deltagare?.translator}}</span> <span>{{deltagare?.sprakstod.beskrivning}}</span>
</digi-typography> </digi-typography>
</div> </div>
<div class="avrop-table__cell"> <div class="avrop-table__cell">

View File

@@ -0,0 +1,4 @@
export interface HandledareResponse {
id: number;
name: string
}

View File

@@ -1,4 +1,4 @@
export interface KommunResponse { export interface KommunResponse {
id: number; kommunCode: number;
name: string; kommun: string;
} }

View File

@@ -3,12 +3,12 @@ import { AvropResponse } from './api/avrop.response.model';
export interface AvropCompact { export interface AvropCompact {
id: string; // id id: string; // id
sokandeId: number; // sokandeId sokandeId: number; // sokandeId
name: string; // deltagare fullName: string; // deltagare
tjanst: string; // tjansteNamn tjanst: string; // tjansteNamn
startDate: Date; // startdatumAvrop startDate: Date; // startdatumAvrop
endDate: Date; // slutdatumAvrop endDate: Date; // slutdatumAvrop
translator: string; // tolkbehov tolkbehov: string; // tolkbehov
languageSupport: string; // sprakstod sprakstod: string; // sprakstod
utforandeAdress: string; // adress utforandeAdress: string; // adress
trackCode: string; // sparkod trackCode: string; // sparkod
} }
@@ -39,12 +39,12 @@ export function mapAvropResponseToAvrop(data: AvropResponse): Avrop {
return { return {
id, id,
sokandeId, sokandeId,
name: deltagare, fullName: deltagare,
tjanst: tjansteNamn, tjanst: tjansteNamn,
startDate: new Date(startdatumAvrop), startDate: new Date(startdatumAvrop),
endDate: new Date(slutdatumAvrop), endDate: new Date(slutdatumAvrop),
translator: tolkbehov, tolkbehov: tolkbehov,
languageSupport: sprakstod, sprakstod: sprakstod,
utforandeAdress: adress, utforandeAdress: adress,
trackCode: sparkod, trackCode: sparkod,
genomforandeReferens, genomforandeReferens,

View File

@@ -0,0 +1,17 @@
import { HandledareResponse } from './api/handledare.response.model';
export interface Handledare {
id: number;
name: string;
}
export function mapHandledareResponseToHandledare(
data: HandledareResponse
): Handledare {
const { id, name } = data;
return {
id,
name
}
}

View File

@@ -6,10 +6,10 @@ export interface Kommun {
} }
export function mapKommunResponseToKommun(data: KommunResponse): Kommun { export function mapKommunResponseToKommun(data: KommunResponse): Kommun {
const { id, name } = data; const { kommunCode, kommun } = data;
return { return {
id, id: kommunCode,
name, name: kommun
}; };
} }

View File

@@ -1,5 +1,5 @@
export interface MultiselectFilterOption { export interface MultiselectFilterOption {
label: string; label?: string;
id: string; id?: string;
count: number; count?: number;
} }

View File

@@ -2,99 +2,50 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { environment } from '@dafa-environment'; import { environment } from '@dafa-environment';
import { AvropResponse } from '@dafa-models/api/avrop.response.model'; import { AvropResponse } from '@dafa-models/api/avrop.response.model';
import { KommunResponse } from '@dafa-models/api/kommun.response.model';
import { TjanstResponse } from '@dafa-models/api/tjanst.response.model';
import { UtforandeVerksamhetResponse } from '@dafa-models/api/utforande-verksamhet.response.model';
import { Avrop, mapAvropResponseToAvrop } from '@dafa-models/avrop.model'; import { Avrop, mapAvropResponseToAvrop } from '@dafa-models/avrop.model';
import { mapKommunResponseToKommun } from '@dafa-models/kommun.model';
import { MultiselectFilterOption } from '@dafa-models/multiselect-filter-option'; import { MultiselectFilterOption } from '@dafa-models/multiselect-filter-option';
import { mapTjanstResponseToTjanst } from '@dafa-models/tjanst.model';
import { mapUtforandeVerksamhetResponseToUtforandeVerksamhet } from '@dafa-models/utforande-verksamhet.model';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { delay, map } from 'rxjs/operators'; import { delay, filter, map } from 'rxjs/operators';
import { HandledareAvrop } from '../../../pages/avrop/models/handledare-avrop'; import { HandledareAvrop } from '../../../pages/avrop/models/handledare-avrop';
const API_HEADERS = { headers: environment.api.headers };
const tempHandledareMock: HandledareAvrop[] = [ const tempHandledareMock: HandledareAvrop[] = [
{ id: '1', fullName: 'Göran Persson' }, { id: '1', fullName: 'Göran Persson' },
{ id: '2', fullName: 'Stefan Löfven' }, { id: '2', fullName: 'Stefan Löfven' },
]; ];
const tempDeltagareMock: Avrop[] = [
{
id: 'id',
sokandeId: 1,
name: 'Daniel',
tjanst: 'Kundval rusta och matcha',
startDate: new Date('2021-03-04'),
endDate: new Date('2022-06-04'),
translator: 'Ja',
languageSupport: 'Ja',
utforandeAdress: 'Xgatan 3, Ystad',
trackCode: 'A',
genomforandeReferens: 1,
participationFrequency: 25,
utforandeVerksamhet: 'utf',
},
{
id: 'id',
sokandeId: 1,
name: 'Nisse',
tjanst: 'STOM',
startDate: new Date('2020-12-22'),
endDate: new Date('2023-08-15'),
translator: '-',
languageSupport: '-',
utforandeAdress: 'Zgatan 4, Qstad',
trackCode: 'B',
genomforandeReferens: 2,
participationFrequency: 75,
utforandeVerksamhet: 'utf',
},
];
const tempKommunerMock: MultiselectFilterOption[] = [
{ id: '124', count: 12, label: 'Stockholm' },
{ id: '125', count: 42, label: 'Göteborg' },
];
const tempUtforandeVerksamheterMock: MultiselectFilterOption[] = [
{ id: 'a124', count: 312, label: 'Utf verk 1' },
{ id: 'b125', count: 142, label: 'Utf verk 2' },
];
const tempTjansterMock: MultiselectFilterOption[] = [
{ id: '013', count: 312, label: 'Karriärvägledning' },
{ id: '321', count: 142, label: 'Karriärval rusta och matcha' },
];
const tempMockDelay = 300; const tempMockDelay = 300;
const API_HEADERS = { headers: environment.api.headers };
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class AvropApiService { export class AvropApiService {
private _apiBaseUrl = `${environment.api.url}/avrop`; private _apiBaseUrl = `${environment.api.url}/avrop`;
private _fetchAllAvrop$: Observable<AvropResponse[]> = this.httpClient.get<AvropResponse[]>(`${this._apiBaseUrl}`, { constructor(private httpClient: HttpClient) { }
...API_HEADERS,
});
constructor(private httpClient: HttpClient) {} getNyaAvrop$(
public allAvrop$: Observable<Avrop[]> = this._fetchAllAvrop$.pipe(
map(response => response.map(data => mapAvropResponseToAvrop(data)))
);
getNyaDeltagare$(
tjanstIds: MultiselectFilterOption[], tjanstIds: MultiselectFilterOption[],
kommunIds: MultiselectFilterOption[], kommunIds: MultiselectFilterOption[],
utforandeVerksamhetIds: MultiselectFilterOption[], utforandeVerksamhetIds: MultiselectFilterOption[],
offset = 0, offset = 0,
limit = 20 limit = 20
): Observable<Avrop[]> { ): Observable<Avrop[]> {
// TODO replace with API-call using tjanstIds, kommunIds, utforandeVerksamhetIds return this.httpClient
console.log( .get<{ data: AvropResponse[] }>(`${this._apiBaseUrl}`, { ...API_HEADERS })
'[API call] getNyaDeltagare$. Inputs: tjanstIds, kommunIds, utforandeVerksamhetIds', .pipe(
tjanstIds, filter(response => !!response),
kommunIds, map(response => {
utforandeVerksamhetIds return response.data.map(avrop => mapAvropResponseToAvrop(avrop))
); })
return of(tempDeltagareMock).pipe(delay(tempMockDelay)); );
} }
getSelectableHandledare$(deltagare: Avrop[]): Observable<HandledareAvrop[]> { getSelectableHandledare$(deltagare: Avrop[]): Observable<HandledareAvrop[]> {
@@ -107,39 +58,46 @@ export class AvropApiService {
selectedKommuner: MultiselectFilterOption[], selectedKommuner: MultiselectFilterOption[],
selectedUtforandeVerksamheter: MultiselectFilterOption[] selectedUtforandeVerksamheter: MultiselectFilterOption[]
): Observable<MultiselectFilterOption[]> { ): Observable<MultiselectFilterOption[]> {
// TODO replace with API-call return this.httpClient.get<{ data: TjanstResponse[] }>(`${this._apiBaseUrl}/tjanster`)
console.log( .pipe(
'[API call] getSelectableTjanster$. Inputs: selectedKommuner, selectedUtforandeVerksamheter', filter(response => !!response),
selectedKommuner, map(response => {
selectedUtforandeVerksamheter return response.data.map(tjanster => {
); return { label: mapTjanstResponseToTjanst(tjanster).name }
return of(tempTjansterMock).pipe(delay(tempMockDelay)); })
})
);
} }
getSelectableUtforandeVerksamheter$( getSelectableUtforandeVerksamheter$(
selectedTjanster: MultiselectFilterOption[], selectedTjanster: MultiselectFilterOption[],
selectedKommuner: MultiselectFilterOption[] selectedKommuner: MultiselectFilterOption[]
): Observable<MultiselectFilterOption[]> { ): Observable<MultiselectFilterOption[]> {
// TODO replace with API-call return this.httpClient.get<{ data: UtforandeVerksamhetResponse[] }>(`${this._apiBaseUrl}/utforandeverksamheter`, { ...API_HEADERS })
console.log( .pipe(
'[API call] getSelectableUtforandeVerksamheter$. Inputs: selectedTjanster, selectedKommuner', filter(response => !!response),
selectedTjanster, map(response => {
selectedKommuner return response.data.map(utforandeverksamheter => {
); return { label: mapUtforandeVerksamhetResponseToUtforandeVerksamhet(utforandeverksamheter).name }
return of(tempUtforandeVerksamheterMock).pipe(delay(tempMockDelay)); })
}
)
);
} }
getSelectableKommuner$( getSelectableKommuner$(
selectedTjanster: MultiselectFilterOption[], selectedTjanster: MultiselectFilterOption[],
selectedUtforandeVerksamheter: MultiselectFilterOption[] selectedUtforandeVerksamheter: MultiselectFilterOption[]
): Observable<MultiselectFilterOption[]> { ): Observable<MultiselectFilterOption[]> {
// TODO replace with API-call return this.httpClient.get<{ data: KommunResponse[] }>(`${this._apiBaseUrl}/kommuner`, { ...API_HEADERS })
console.log( .pipe(
'[API call] getSelectableKommuner$. Inputs: selectedTjanster, selectedUtforandeVerksamheter', filter(response => !!response),
selectedTjanster, map(response => {
selectedUtforandeVerksamheter return response.data.map(kommun => {
); return { label: mapKommunResponseToKommun(kommun).name }
return of(tempKommunerMock).pipe(delay(tempMockDelay)); })
})
);
} }
async tilldelaHandledare(deltagare: Avrop[], handledare: HandledareAvrop): Promise<void> { async tilldelaHandledare(deltagare: Avrop[], handledare: HandledareAvrop): Promise<void> {