Merge branch 'next' into develop
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
grid-area: content;
|
||||
max-width: $digi--layout--breakpoint--l;
|
||||
padding: $digi--layout--gutter--l $digi--layout--gutter--l $digi--layout--gutter--xxl;
|
||||
z-index: $msfa__z-index-default;
|
||||
}
|
||||
|
||||
&__breadcrumbs {
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface AvropCompact {
|
||||
sprakstod: string; // sprakstod
|
||||
utforandeAdress: string; // adress
|
||||
trackCode: string; // sparkod
|
||||
trackName: string; // sparNamn
|
||||
trackName: TrackName; // sparNamn
|
||||
}
|
||||
|
||||
export interface Avrop extends AvropCompact {
|
||||
@@ -60,11 +60,11 @@ export function mapAvropResponseToAvrop(data: AvropResponse): Avrop {
|
||||
sprakstod: sprakstod,
|
||||
utforandeAdress: adress,
|
||||
trackCode: sparkod,
|
||||
trackName: TrackName[sparkod] || TrackName.UNKNOWN,
|
||||
trackName: (TrackName[sparkod] || TrackName.UNKNOWN) as TrackName,
|
||||
genomforandeReferens,
|
||||
participationFrequency: deltagandeGrad,
|
||||
utforandeVerksamhet: utforandeverksamhet,
|
||||
handledareCiamUserId,
|
||||
handledareCiamUserId: handledareCiamUserId,
|
||||
handledare,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,13 +15,18 @@ export interface ContactInformation {
|
||||
|
||||
export function mapResponseToContactInformation(data: ContactInformationResponse): ContactInformation {
|
||||
const { fornamn, efternamn, personnummer, epost, telekomadresser, adresser } = data;
|
||||
|
||||
return {
|
||||
firstName: fornamn || '',
|
||||
lastName: efternamn || '',
|
||||
fullName: fornamn && efternamn ? `${fornamn} ${efternamn}` : '',
|
||||
ssn: personnummer ? mapStringToSsn(personnummer) : '',
|
||||
email: epost || '',
|
||||
phoneNumbers: telekomadresser ? telekomadresser.map(phoneNumber => mapResponseToPhoneNumber(phoneNumber)) : [],
|
||||
phoneNumbers: telekomadresser
|
||||
? telekomadresser
|
||||
.filter(phoneNumber => phoneNumber.landskod && phoneNumber.nummer_utan_inledande_nolla)
|
||||
.map(phoneNumber => mapResponseToPhoneNumber(phoneNumber))
|
||||
: [],
|
||||
addresses: adresser ? adresser.map(address => mapResponseToAddress(address)) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,27 @@
|
||||
const GENOMFORANDEHANDELSE_EFFECT_MAP = {
|
||||
Inrapporteringsdatum_GP: 'Inskickad datum',
|
||||
Godkannandedatum_GP: 'Godkänd datum',
|
||||
Avvisatdatum_GP: 'Ej godkänd datum',
|
||||
Inrapporteringsdatum_PR: 'Inrapporterad datum',
|
||||
Godkannandedatum_PR: 'Godkänd datum',
|
||||
Avvisatdatum_PR: 'Ej godkänd datum',
|
||||
Inrapporteringsdatum_SR: 'Inskickad datum',
|
||||
Godkannandedatum_SR: 'Godkänd datum',
|
||||
Avvisatdatum_SR: 'Ej godkänd datum',
|
||||
Handlaggning_startad: 'Handläggning startad',
|
||||
Andringsbeslutdatum: 'Ändringsbeslut datum',
|
||||
Slut_avropsperiod: 'Nytt slutdatum',
|
||||
};
|
||||
|
||||
export interface DeltagareHandelse {
|
||||
description: string;
|
||||
receivedDate: Date;
|
||||
isAvbrott: boolean;
|
||||
effectDate: Date;
|
||||
effectDescription: string;
|
||||
}
|
||||
|
||||
interface DeltagareHandelseApiResponse {
|
||||
description: string;
|
||||
receivedDate: Date;
|
||||
isAvbrott: boolean;
|
||||
@@ -6,6 +29,18 @@ export interface DeltagareHandelse {
|
||||
tidpunktDescription: string;
|
||||
}
|
||||
|
||||
export interface DeltagareHandelseApiResponse {
|
||||
data: DeltagareHandelse[];
|
||||
export interface DeltagareHandelserApiResponse {
|
||||
data: DeltagareHandelseApiResponse[];
|
||||
}
|
||||
|
||||
export function mapDeltagareHandelseApiResponse(
|
||||
deltagareHandelseApiResponse: DeltagareHandelseApiResponse
|
||||
): DeltagareHandelse {
|
||||
const { description, receivedDate, isAvbrott } = deltagareHandelseApiResponse;
|
||||
const effectDate = deltagareHandelseApiResponse.tidpunkt;
|
||||
const effectDescription =
|
||||
GENOMFORANDEHANDELSE_EFFECT_MAP[deltagareHandelseApiResponse.tidpunktDescription] ??
|
||||
deltagareHandelseApiResponse.tidpunktDescription ??
|
||||
'';
|
||||
return { description, receivedDate, isAvbrott, effectDate, effectDescription };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { DeltagareHandelse, DeltagareHandelseApiResponse } from '@msfa-models/deltagare-handelse.model';
|
||||
import {
|
||||
DeltagareHandelse,
|
||||
DeltagareHandelserApiResponse,
|
||||
mapDeltagareHandelseApiResponse,
|
||||
} from '@msfa-models/deltagare-handelse.model';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@@ -18,11 +22,11 @@ export class DeltagareHandelserApiService {
|
||||
}
|
||||
|
||||
return this.httpClient
|
||||
.get<DeltagareHandelseApiResponse>(`${this._apiBaseUrl}/deltagare/${genomforandeReferens}/handelser`)
|
||||
.get<DeltagareHandelserApiResponse>(`${this._apiBaseUrl}/deltagare/${genomforandeReferens}/handelser`)
|
||||
.pipe(
|
||||
map(({ data }) => {
|
||||
if (data) {
|
||||
return data;
|
||||
return data.map(genomforandeHandelse => mapDeltagareHandelseApiResponse(genomforandeHandelse));
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@@ -23,19 +23,35 @@ import { ErrorService } from '@msfa-services/error.service';
|
||||
import { BehaviorSubject, combineLatest, Observable, of, throwError } from 'rxjs';
|
||||
import { catchError, distinctUntilChanged, filter, map, switchMap, take, tap } from 'rxjs/operators';
|
||||
|
||||
interface EmployeeParams {
|
||||
page: number;
|
||||
limit: number;
|
||||
sort: keyof EmployeeCompactResponse;
|
||||
order: SortOrder;
|
||||
search: string;
|
||||
onlyEmployeesWithoutAuthorization: boolean;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class EmployeeService extends UnsubscribeDirective {
|
||||
private _apiBaseUrl = `${environment.api.url}/users`;
|
||||
private _currentEmployeeId$ = new BehaviorSubject<string>(null);
|
||||
private _limit$ = new BehaviorSubject<number>(10);
|
||||
private _page$ = new BehaviorSubject<number>(1);
|
||||
private _sort$ = new BehaviorSubject<Sort<keyof EmployeeCompactResponse>>({ key: 'name', order: SortOrder.ASC });
|
||||
public sort$: Observable<Sort<keyof EmployeeCompactResponse>> = this._sort$.asObservable();
|
||||
private _searchFilter$ = new BehaviorSubject<string>('');
|
||||
private _onlyEmployeesWithoutAuthorization$ = new BehaviorSubject<boolean>(false);
|
||||
public onlyEmployeesWithoutAuthorization$: Observable<boolean> = this._onlyEmployeesWithoutAuthorization$.asObservable();
|
||||
private _params$ = new BehaviorSubject<EmployeeParams>({
|
||||
page: 1,
|
||||
limit: 10,
|
||||
sort: 'name',
|
||||
order: SortOrder.ASC,
|
||||
search: '',
|
||||
onlyEmployeesWithoutAuthorization: false,
|
||||
});
|
||||
public sort$: Observable<Sort<keyof EmployeeCompactResponse>> = this._params$.pipe(
|
||||
map(({ sort, order }) => ({ key: sort, order }))
|
||||
);
|
||||
public onlyEmployeesWithoutAuthorization$: Observable<boolean> = this._params$.pipe(
|
||||
map(({ onlyEmployeesWithoutAuthorization }) => onlyEmployeesWithoutAuthorization)
|
||||
);
|
||||
private _employee$ = new BehaviorSubject<Employee>(null);
|
||||
public employee$: Observable<Employee> = this._employee$.asObservable();
|
||||
private _lastUpdatedEmployeeId$ = new BehaviorSubject<string>(null);
|
||||
@@ -67,17 +83,8 @@ export class EmployeeService extends UnsubscribeDirective {
|
||||
);
|
||||
}
|
||||
|
||||
public employeesData$: Observable<EmployeesData> = combineLatest([
|
||||
this._limit$,
|
||||
this._page$,
|
||||
this._sort$,
|
||||
this._searchFilter$,
|
||||
this._onlyEmployeesWithoutAuthorization$,
|
||||
this._lastDeletedEmployee$,
|
||||
]).pipe(
|
||||
switchMap(([limit, page, sort, searchFilter, onlyEmployeesWithoutAuthorization]) =>
|
||||
this._fetchEmployees$(limit, page, sort, searchFilter, onlyEmployeesWithoutAuthorization)
|
||||
)
|
||||
public employeesData$: Observable<EmployeesData> = combineLatest([this._params$, this._lastDeletedEmployee$]).pipe(
|
||||
switchMap(([params]) => this._fetchEmployees$(params))
|
||||
);
|
||||
|
||||
public setCurrentEmployeeId(currentEmployeeId: string): void {
|
||||
@@ -91,26 +98,21 @@ export class EmployeeService extends UnsubscribeDirective {
|
||||
this._lastUpdatedEmployeeId$.next(null);
|
||||
}
|
||||
|
||||
private _fetchEmployees$(
|
||||
limit: number,
|
||||
page: number,
|
||||
sort: Sort<keyof EmployeeCompactResponse>,
|
||||
searchFilter: string,
|
||||
onlyEmployeesWithoutAuthorization?: boolean
|
||||
): Observable<EmployeesData> {
|
||||
private _fetchEmployees$(employeeParams: EmployeeParams): Observable<EmployeesData> {
|
||||
const { sort, order, limit, page, search, onlyEmployeesWithoutAuthorization } = employeeParams;
|
||||
const params: Params = {
|
||||
sort: sort.key as string,
|
||||
order: sort.order as string,
|
||||
sort,
|
||||
order,
|
||||
limit: limit.toString(),
|
||||
page: page.toString(),
|
||||
};
|
||||
|
||||
if (searchFilter) {
|
||||
params.search = searchFilter;
|
||||
if (search) {
|
||||
params.search = search;
|
||||
}
|
||||
|
||||
if (onlyEmployeesWithoutAuthorization) {
|
||||
params.onlyEmployeesWithoutAuthorization = onlyEmployeesWithoutAuthorization?.toString();
|
||||
params.onlyEmployeesWithoutAuthorization = onlyEmployeesWithoutAuthorization.toString();
|
||||
}
|
||||
this._employeesLoading$.next(true);
|
||||
|
||||
@@ -134,12 +136,20 @@ export class EmployeeService extends UnsubscribeDirective {
|
||||
);
|
||||
}
|
||||
|
||||
public setSearchFilter(value: string): void {
|
||||
this._searchFilter$.next(value);
|
||||
public setSearchString(value: string): void {
|
||||
this._params$.next({
|
||||
...this._params$.getValue(),
|
||||
search: value,
|
||||
page: 1,
|
||||
});
|
||||
}
|
||||
|
||||
public setOnlyEmployeesWithoutAuthorization(value: boolean): void {
|
||||
this._onlyEmployeesWithoutAuthorization$.next(value);
|
||||
this._params$.next({
|
||||
...this._params$.getValue(),
|
||||
onlyEmployeesWithoutAuthorization: value,
|
||||
page: 1,
|
||||
});
|
||||
}
|
||||
|
||||
public setEmployeeToDelete(employee: Employee): void {
|
||||
@@ -156,16 +166,17 @@ export class EmployeeService extends UnsubscribeDirective {
|
||||
);
|
||||
}
|
||||
|
||||
public setSort(newSortKey: keyof EmployeeCompactResponse): void {
|
||||
const currentSort = this._sort$.getValue();
|
||||
const order =
|
||||
currentSort.key === newSortKey && currentSort.order === SortOrder.ASC ? SortOrder.DESC : SortOrder.ASC;
|
||||
public setSort(sort: keyof EmployeeCompactResponse): void {
|
||||
const currentParams = this._params$.getValue();
|
||||
const currentSort = currentParams.sort;
|
||||
const currentOrder = currentParams.order;
|
||||
const order = currentSort === sort && currentOrder === SortOrder.ASC ? SortOrder.DESC : SortOrder.ASC;
|
||||
|
||||
this._sort$.next({ key: newSortKey, order });
|
||||
this._params$.next({ ...this._params$.getValue(), sort, order });
|
||||
}
|
||||
|
||||
public setPage(page: number): void {
|
||||
this._page$.next(page);
|
||||
this._params$.next({ ...this._params$.getValue(), page });
|
||||
}
|
||||
|
||||
public postEmployeeInvitation(emails: string[]): Observable<EmployeeInviteResponse | null> {
|
||||
|
||||
@@ -95,8 +95,11 @@ export class AvropService {
|
||||
this._avropIsLocked$,
|
||||
this._avropIsSubmitted$,
|
||||
]).pipe(
|
||||
map(([confirmedHandledare, avropIsLocked, avropIsSubmitted]) => {
|
||||
return AvropService.calculateStep(confirmedHandledare, avropIsLocked, avropIsSubmitted);
|
||||
map(([confirmedHandledare, avropIsLocked, avropIsSubmitted]) =>
|
||||
AvropService.calculateStep(confirmedHandledare, avropIsLocked, avropIsSubmitted)
|
||||
),
|
||||
tap(() => {
|
||||
window.scrollTo(0, 0);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user