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$,
]).pipe(
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>
<digi-form-checkbox
*ngFor="let filterOption of filterOptions"
[afLabel]="filterOption.label + ' (' + filterOption.count + ')'"
[afLabel]="filterOption.label + ' (' + (filterOption.count || 0) + ')'"
(change)="setOptionState(filterOption, $event.target.checked)"
[afChecked]="isSelected(filterOption)"
>

View File

@@ -14,7 +14,7 @@
<div class="avrop-table__cell">
<digi-typography>
<strong class="avrop-table__label">Namn:</strong>
<span>{{deltagare?.name}}</span>
<span>{{deltagare?.fullName}}</span>
</digi-typography>
</div>
<div class="avrop-table__cell">
@@ -42,7 +42,7 @@
<div class="avrop-table__cell">
<digi-typography>
<strong class="avrop-table__label">Språkstöd/Tolk:</strong>
<span>{{deltagare?.translator}}</span>
<span>{{deltagare?.sprakstod.beskrivning}}</span>
</digi-typography>
</div>
<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 {
id: number;
name: string;
kommunCode: number;
kommun: string;
}

View File

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

View File

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

View File

@@ -2,99 +2,50 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '@dafa-environment';
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 { mapKommunResponseToKommun } from '@dafa-models/kommun.model';
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 { delay, map } from 'rxjs/operators';
import { delay, filter, map } from 'rxjs/operators';
import { HandledareAvrop } from '../../../pages/avrop/models/handledare-avrop';
const API_HEADERS = { headers: environment.api.headers };
const tempHandledareMock: HandledareAvrop[] = [
{ id: '1', fullName: 'Göran Persson' },
{ 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 API_HEADERS = { headers: environment.api.headers };
@Injectable({
providedIn: 'root',
})
export class AvropApiService {
private _apiBaseUrl = `${environment.api.url}/avrop`;
private _fetchAllAvrop$: Observable<AvropResponse[]> = this.httpClient.get<AvropResponse[]>(`${this._apiBaseUrl}`, {
...API_HEADERS,
});
constructor(private httpClient: HttpClient) { }
constructor(private httpClient: HttpClient) {}
public allAvrop$: Observable<Avrop[]> = this._fetchAllAvrop$.pipe(
map(response => response.map(data => mapAvropResponseToAvrop(data)))
);
getNyaDeltagare$(
getNyaAvrop$(
tjanstIds: MultiselectFilterOption[],
kommunIds: MultiselectFilterOption[],
utforandeVerksamhetIds: MultiselectFilterOption[],
offset = 0,
limit = 20
): Observable<Avrop[]> {
// TODO replace with API-call using tjanstIds, kommunIds, utforandeVerksamhetIds
console.log(
'[API call] getNyaDeltagare$. Inputs: tjanstIds, kommunIds, utforandeVerksamhetIds',
tjanstIds,
kommunIds,
utforandeVerksamhetIds
);
return of(tempDeltagareMock).pipe(delay(tempMockDelay));
return this.httpClient
.get<{ data: AvropResponse[] }>(`${this._apiBaseUrl}`, { ...API_HEADERS })
.pipe(
filter(response => !!response),
map(response => {
return response.data.map(avrop => mapAvropResponseToAvrop(avrop))
})
);
}
getSelectableHandledare$(deltagare: Avrop[]): Observable<HandledareAvrop[]> {
@@ -107,39 +58,46 @@ export class AvropApiService {
selectedKommuner: MultiselectFilterOption[],
selectedUtforandeVerksamheter: MultiselectFilterOption[]
): Observable<MultiselectFilterOption[]> {
// TODO replace with API-call
console.log(
'[API call] getSelectableTjanster$. Inputs: selectedKommuner, selectedUtforandeVerksamheter',
selectedKommuner,
selectedUtforandeVerksamheter
);
return of(tempTjansterMock).pipe(delay(tempMockDelay));
return this.httpClient.get<{ data: TjanstResponse[] }>(`${this._apiBaseUrl}/tjanster`)
.pipe(
filter(response => !!response),
map(response => {
return response.data.map(tjanster => {
return { label: mapTjanstResponseToTjanst(tjanster).name }
})
})
);
}
getSelectableUtforandeVerksamheter$(
selectedTjanster: MultiselectFilterOption[],
selectedKommuner: MultiselectFilterOption[]
): Observable<MultiselectFilterOption[]> {
// TODO replace with API-call
console.log(
'[API call] getSelectableUtforandeVerksamheter$. Inputs: selectedTjanster, selectedKommuner',
selectedTjanster,
selectedKommuner
);
return of(tempUtforandeVerksamheterMock).pipe(delay(tempMockDelay));
return this.httpClient.get<{ data: UtforandeVerksamhetResponse[] }>(`${this._apiBaseUrl}/utforandeverksamheter`, { ...API_HEADERS })
.pipe(
filter(response => !!response),
map(response => {
return response.data.map(utforandeverksamheter => {
return { label: mapUtforandeVerksamhetResponseToUtforandeVerksamhet(utforandeverksamheter).name }
})
}
)
);
}
getSelectableKommuner$(
selectedTjanster: MultiselectFilterOption[],
selectedUtforandeVerksamheter: MultiselectFilterOption[]
): Observable<MultiselectFilterOption[]> {
// TODO replace with API-call
console.log(
'[API call] getSelectableKommuner$. Inputs: selectedTjanster, selectedUtforandeVerksamheter',
selectedTjanster,
selectedUtforandeVerksamheter
);
return of(tempKommunerMock).pipe(delay(tempMockDelay));
return this.httpClient.get<{ data: KommunResponse[] }>(`${this._apiBaseUrl}/kommuner`, { ...API_HEADERS })
.pipe(
filter(response => !!response),
map(response => {
return response.data.map(kommun => {
return { label: mapKommunResponseToKommun(kommun).name }
})
})
);
}
async tilldelaHandledare(deltagare: Avrop[], handledare: HandledareAvrop): Promise<void> {