Removed a lot of unused models, services and enums
This commit is contained in:
@@ -14,7 +14,6 @@ import { BehaviorSubject, Observable } from 'rxjs';
|
||||
})
|
||||
export class EmployeeCardComponent implements OnDestroy {
|
||||
private _employeeId$ = new BehaviorSubject<string>(this.activatedRoute.snapshot.params['employeeId']);
|
||||
private _pendingSelectedParticipants$ = new BehaviorSubject<string[]>([]);
|
||||
employee$: Observable<Employee> = this.employeeService.employee$;
|
||||
lastUpdatedEmployeeId$: Observable<string> = this.employeeService.lastUpdatedEmployeeId$;
|
||||
allRoles: Role[] = this.roleService.allRoles;
|
||||
@@ -37,10 +36,6 @@ export class EmployeeCardComponent implements OnDestroy {
|
||||
return this._employeeId$.getValue();
|
||||
}
|
||||
|
||||
get pendingSelectedParticipants(): string[] {
|
||||
return this._pendingSelectedParticipants$.getValue();
|
||||
}
|
||||
|
||||
isAccordionExpanded(id: number): boolean {
|
||||
return this.accordionsExpanded.includes(id);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
OnInit,
|
||||
Output,
|
||||
SimpleChanges,
|
||||
ViewChild,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
||||
import { RoleEnum } from '@msfa-enums/role.enum';
|
||||
@@ -23,7 +23,7 @@ import { UtforandeVerksamhet } from '@msfa-models/utforande-verksamhet.model';
|
||||
import { UtforandeVerksamheterService } from '@msfa-services/utforande-verksamheter/utforande-verksamheter.service';
|
||||
import { ValidationErrorLink } from '@msfa-shared/components/error-list/error-list.component';
|
||||
import { TreeNodesSelectorService } from '@msfa-shared/components/tree-nodes-selector/services/tree-nodes-selector.service';
|
||||
import { uuid } from '@msfa-utils/uuid';
|
||||
import { uuid } from '@msfa-utils/uuid.util';
|
||||
import { EmployeeValidator } from '@msfa-utils/validators/employee.validator';
|
||||
import { EmployeeFormService } from '../services/employee-form.service';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { Alternative } from '@msfa-enums/alternative.enum';
|
||||
import { FranvaroOrsaksKodEnum } from '@msfa-enums/franvaro-orsak-kod.enum';
|
||||
import { ReportType } from '@msfa-enums/report-type.enum';
|
||||
import { OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model';
|
||||
import { OrsaksKoderFranvaro } from '@msfa-models/orsaks-koder-franvaro.model';
|
||||
|
||||
@@ -9,7 +9,7 @@ import { OrsaksKoderFranvaro } from '@msfa-models/orsaks-koder-franvaro.model';
|
||||
selector: 'msfa-deltagare-orsaks-form',
|
||||
templateUrl: './deltagare-orsaks-form.component.html',
|
||||
styleUrls: ['./deltagare-orsaks-form.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class DeltagareOrsaksFormComponent implements OnChanges {
|
||||
@Input() franvaroOrsaker: OrsaksKoderFranvaro[] | null = null;
|
||||
@@ -26,8 +26,9 @@ export class DeltagareOrsaksFormComponent implements OnChanges {
|
||||
}
|
||||
|
||||
get showAndraKandaOrsaker(): boolean {
|
||||
return this.selectedAlternative === Alternative.FRANVARO &&
|
||||
+this.orsakerFormGroup.get('orsaker')?.value === FranvaroOrsaksKodEnum.AnnanKandOrsak;
|
||||
return (
|
||||
this.selectedAlternative === ReportType.FRANVARO &&
|
||||
+this.orsakerFormGroup.get('orsaker')?.value === FranvaroOrsaksKodEnum.AnnanKandOrsak
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { FormTextareaSize } from '@af/digi-ng/_form/form-textarea';
|
||||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Alternative } from '@msfa-enums/alternative.enum';
|
||||
import { ReportType } from '@msfa-enums/report-type.enum';
|
||||
import { ConfirmDialog } from '@msfa-enums/confirm-dialog.enum';
|
||||
import { DayOrPartOfDay } from '@msfa-enums/day-or-part-of-day.enum';
|
||||
import { FranvaroOrsaksKodEnum } from '@msfa-enums/franvaro-orsak-kod.enum';
|
||||
@@ -159,7 +159,7 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
|
||||
get showDescription(): boolean {
|
||||
return (
|
||||
(this.alternativeFormControl.value as string) == Alternative.FRANVARO &&
|
||||
(this.alternativeFormControl.value as string) == ReportType.FRANVARO &&
|
||||
+this.orsakerFormControl.value === FranvaroOrsaksKodEnum.AnnanKandOrsak &&
|
||||
+this.andraKandaOrsakerFormControl.value === KandaOrsakerEnum.AnnanOrsak
|
||||
);
|
||||
@@ -167,7 +167,7 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
|
||||
get showFragor(): boolean {
|
||||
return (
|
||||
(this.alternativeFormControl.value as string) === Alternative.AVVIKELSE &&
|
||||
(this.alternativeFormControl.value as string) === ReportType.AVVIKELSE &&
|
||||
(this.orsakerFormControl.value as boolean)
|
||||
);
|
||||
}
|
||||
@@ -178,14 +178,14 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
|
||||
get showDayOrPartOfDayPicker(): boolean {
|
||||
return (
|
||||
(this.alternativeFormControl.value as string) === Alternative.FRANVARO &&
|
||||
(this.alternativeFormControl.value as string) === ReportType.FRANVARO &&
|
||||
(this.orsakerFormControl.value as boolean)
|
||||
);
|
||||
}
|
||||
|
||||
get showTimePicker(): boolean {
|
||||
return (
|
||||
(this.alternativeFormControl.value as string) === Alternative.FRANVARO &&
|
||||
(this.alternativeFormControl.value as string) === ReportType.FRANVARO &&
|
||||
(this.dayOrPartOfDayFormControl.value as string) === DayOrPartOfDay.DEL_AV_DAG
|
||||
);
|
||||
}
|
||||
@@ -233,9 +233,9 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
sokandeId: +this.activatedRoute.snapshot.params['genomforandeReferens'],
|
||||
};
|
||||
|
||||
if ((this.alternativeFormControl.value as string) === Alternative.AVVIKELSE) {
|
||||
if ((this.alternativeFormControl.value as string) === ReportType.AVVIKELSE) {
|
||||
postAvvikelse['avvikelsealternativ'] = this.avvikelse;
|
||||
} else if ((this.alternativeFormControl.value as string) == Alternative.FRANVARO) {
|
||||
} else if ((this.alternativeFormControl.value as string) == ReportType.FRANVARO) {
|
||||
postAvvikelse['franvaro'] = this.franvaro;
|
||||
}
|
||||
|
||||
@@ -250,12 +250,12 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
}
|
||||
|
||||
setAlternative(): void {
|
||||
if ((this.alternativeFormControl.value as string) == Alternative.FRANVARO) {
|
||||
if ((this.alternativeFormControl.value as string) == ReportType.FRANVARO) {
|
||||
this.franvaroOrsaker$ = this.deltagareAvvikelseService.getOrsaksKoderFranvaro$();
|
||||
this.andraKandaOrsaker$ = this.deltagareAvvikelseService.getAndraKandaOrsaker$();
|
||||
}
|
||||
|
||||
if ((this.alternativeFormControl.value as string) == Alternative.AVVIKELSE) {
|
||||
if ((this.alternativeFormControl.value as string) == ReportType.AVVIKELSE) {
|
||||
this.avvikelseOrsaker$ = this.deltagareAvvikelseService.getOrsaksKoderAvvikelse$();
|
||||
this.fragor1$ = this.deltagareAvvikelseService.getFragorForAvvikelser$().pipe(
|
||||
map((fragor: FragorForAvvikelser[]) => {
|
||||
@@ -277,7 +277,7 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
|
||||
setOrsakerChanged(): void {
|
||||
this.avvikelseFormGroup.markAsUntouched();
|
||||
if ((this.alternativeFormControl.value as string) === Alternative.AVVIKELSE) {
|
||||
if ((this.alternativeFormControl.value as string) === ReportType.AVVIKELSE) {
|
||||
this.selectedOrsaksKod = this.avvikelseFormGroup.get('orsakerFormGroup').get('orsaker').value as string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Alternative } from '@msfa-enums/alternative.enum';
|
||||
import { ReportType } from '@msfa-enums/report-type.enum';
|
||||
import { DayOrPartOfDay } from '@msfa-enums/day-or-part-of-day.enum';
|
||||
import { RadiobuttonModel } from '@af/digi-ng/_form/form-radiobutton-group';
|
||||
|
||||
export const avvikelseAlternatives: RadiobuttonModel[] = [
|
||||
{
|
||||
label: 'Frånvaro',
|
||||
value: Alternative.FRANVARO,
|
||||
value: ReportType.FRANVARO,
|
||||
},
|
||||
{
|
||||
label: 'Avvikelse',
|
||||
value: Alternative.AVVIKELSE,
|
||||
value: ReportType.AVVIKELSE,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
AfterViewInit,
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
forwardRef,
|
||||
Input,
|
||||
AfterViewInit,
|
||||
Output,
|
||||
Renderer2,
|
||||
ViewChild,
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { DropdownTriggerForDirective } from '@msfa-shared/components/dropdown/dropdown-trigger-for.directive';
|
||||
import { MultiselectFilterOption } from '@msfa-shared/components/multiselect/multiselect-filter-option';
|
||||
import { uuid } from '@msfa-utils/uuid';
|
||||
import { uuid } from '@msfa-utils/uuid.util';
|
||||
|
||||
interface PropagateChangeFn {
|
||||
(_: unknown): void;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { uuid } from '@msfa-utils/uuid';
|
||||
import { uuid } from '@msfa-utils/uuid.util';
|
||||
import { TreeNode, TreeNodeModel, TreeNodesSelectorService } from '../../services/tree-nodes-selector.service';
|
||||
import { TreeNodesSelectorPanelComponent } from '../tree-nodes-selector-panel/tree-nodes-selector-panel.component';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { uuid } from '@msfa-utils/uuid';
|
||||
import { uuid } from '@msfa-utils/uuid.util';
|
||||
|
||||
export interface TreeNode {
|
||||
label: string;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export enum Alternative {
|
||||
FRANVARO = 'franvaro',
|
||||
AVVIKELSE = 'avvikelse'
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export enum Authorization {
|
||||
UserManagement = 'UserManagement',
|
||||
Economy = 'Economy',
|
||||
Reports = 'Reports',
|
||||
ParticipantManagement = 'ParticipantManagement',
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export enum ParticipantStatus {
|
||||
ACTIVE = 'active',
|
||||
FOLLOW_UP = 'follow-up',
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum ReportType {
|
||||
FRANVARO = 'franvaro',
|
||||
AVVIKELSE = 'avvikelse',
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export enum ServiceEnum {
|
||||
KVL,
|
||||
KROM,
|
||||
STOM
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { Tjanst } from './tjanst.model';
|
||||
|
||||
export interface FormTagData {
|
||||
tjanstekod: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function mapTjanstToFormTag(tjanstData: Tjanst): FormTagData {
|
||||
const { name, code } = tjanstData;
|
||||
return { tjanstekod: code, name };
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
import { ParticipantStatus } from '@msfa-enums/participant-status.enum';
|
||||
import { ServiceEnum } from '@msfa-enums/service.enum';
|
||||
import { PaginationMeta } from './pagination-meta.model';
|
||||
|
||||
export interface Participant {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
fullName: string;
|
||||
ssn: string;
|
||||
status: ParticipantStatus;
|
||||
nextStep: string;
|
||||
service: ServiceEnum;
|
||||
errandNumber: number;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
handleBefore: Date;
|
||||
}
|
||||
|
||||
export interface ParticipantsApiResponse {
|
||||
data: ParticipantApiResponseData[];
|
||||
meta?: PaginationMeta;
|
||||
}
|
||||
|
||||
export interface ParticipantApiResponse {
|
||||
data: ParticipantApiResponseData;
|
||||
}
|
||||
|
||||
export interface ParticipantApiResponseData {
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
ssn: string;
|
||||
status: ParticipantStatus;
|
||||
nextStep: string;
|
||||
service: ServiceEnum;
|
||||
errandNumber: number;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
handleBefore: Date;
|
||||
}
|
||||
|
||||
export function mapParticipantApiResponseToParticipant(data: ParticipantApiResponseData): Participant {
|
||||
const {
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
ssn,
|
||||
status,
|
||||
nextStep,
|
||||
service,
|
||||
errandNumber,
|
||||
startDate,
|
||||
endDate,
|
||||
handleBefore,
|
||||
} = data;
|
||||
return {
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
fullName: `${firstName} ${lastName}`,
|
||||
ssn,
|
||||
status,
|
||||
nextStep,
|
||||
service,
|
||||
errandNumber,
|
||||
startDate,
|
||||
endDate,
|
||||
handleBefore,
|
||||
};
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import { ServiceEnum } from '@msfa-enums/service.enum';
|
||||
|
||||
export interface Service {
|
||||
id: string;
|
||||
name: string;
|
||||
tjanstekod: string;
|
||||
tjanstId: number;
|
||||
type: ServiceEnum;
|
||||
}
|
||||
|
||||
export interface ServiceApiResponse {
|
||||
data: ServiceApiResponseData[];
|
||||
}
|
||||
|
||||
export interface ServiceApiResponseData {
|
||||
id: string;
|
||||
name: string;
|
||||
tjanstekod: string;
|
||||
tjanstId: number;
|
||||
type: ServiceEnum;
|
||||
}
|
||||
|
||||
export function mapServiceApiResponseToService(data: ServiceApiResponseData): Service {
|
||||
const { id, name, tjanstekod, tjanstId } = data;
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
tjanstekod,
|
||||
tjanstId,
|
||||
type: getServiceEnumType(name),
|
||||
};
|
||||
}
|
||||
|
||||
export function getServiceEnumType(name: string):ServiceEnum {
|
||||
switch (name) {
|
||||
case 'Kundval Rusta och matcha':
|
||||
return ServiceEnum.KROM;
|
||||
case 'Karriärvägledning':
|
||||
return ServiceEnum.KVL;
|
||||
case 'Stöd och Matchning':
|
||||
return ServiceEnum.STOM;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Alternative } from '@msfa-enums/alternative.enum';
|
||||
import { ReportType } from '@msfa-enums/report-type.enum';
|
||||
import { ErrorType } from '@msfa-enums/error-type.enum';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { FragorForAvvikelserResponse } from '@msfa-models/api/fragor-for-avvikelser.response';
|
||||
@@ -72,10 +72,10 @@ export class AvvikelseApiService {
|
||||
let endpoint = '';
|
||||
|
||||
switch (alternative) {
|
||||
case Alternative.AVVIKELSE:
|
||||
case ReportType.AVVIKELSE:
|
||||
endpoint = 'avvikelse';
|
||||
break;
|
||||
case Alternative.FRANVARO:
|
||||
case ReportType.FRANVARO:
|
||||
endpoint = 'franvaro';
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ParticipantStatus } from '@msfa-enums/participant-status.enum';
|
||||
import { SortOrder } from '@msfa-enums/sort-order.enum';
|
||||
import { environment } from '@msfa-environment';
|
||||
import {
|
||||
mapParticipantApiResponseToParticipant,
|
||||
Participant,
|
||||
ParticipantApiResponse,
|
||||
ParticipantsApiResponse,
|
||||
} from '@msfa-models/participant.model';
|
||||
import { Sort } from '@msfa-models/sort.model';
|
||||
import { sort } from '@msfa-utils/sort.util';
|
||||
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
function filterParticipants(participants: Participant[], searchFilter: string): Participant[] {
|
||||
return participants.filter(participant => {
|
||||
const searchValueExistsInName = participant.fullName.toLowerCase().includes(searchFilter.toLowerCase());
|
||||
const searchValueExistsInErrandNumber = participant.errandNumber.toString().includes(searchFilter);
|
||||
|
||||
return searchValueExistsInName || searchValueExistsInErrandNumber;
|
||||
});
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ParticipantsService {
|
||||
private _apiBaseUrl = `${environment.api.url}/participants`;
|
||||
private _allParticipants$: Observable<Participant[]> = this.httpClient
|
||||
.get<ParticipantsApiResponse>(this._apiBaseUrl)
|
||||
.pipe(map(response => response.data.map(participant => mapParticipantApiResponseToParticipant(participant))));
|
||||
private _activeParticipantsSortBy$ = new BehaviorSubject<Sort<keyof Participant> | null>({
|
||||
key: 'handleBefore',
|
||||
order: SortOrder.ASC,
|
||||
});
|
||||
public activeParticipantsSortBy$: Observable<
|
||||
Sort<keyof Participant>
|
||||
> = this._activeParticipantsSortBy$.asObservable();
|
||||
private _followUpParticipantsSortBy$ = new BehaviorSubject<Sort<keyof Participant> | null>({
|
||||
key: 'handleBefore',
|
||||
order: SortOrder.ASC,
|
||||
});
|
||||
public followUpParticipantsSortBy$: Observable<
|
||||
Sort<keyof Participant>
|
||||
> = this._followUpParticipantsSortBy$.asObservable();
|
||||
private _searchFilter$ = new BehaviorSubject<string>('');
|
||||
public searchFilter$: Observable<string> = this._searchFilter$.asObservable();
|
||||
|
||||
public filteredParticipants$: Observable<Participant[]> = combineLatest([
|
||||
this._allParticipants$,
|
||||
this._searchFilter$,
|
||||
]).pipe(map(([participants, searchFilter]) => filterParticipants(participants, searchFilter)));
|
||||
|
||||
public activeParticipants$: Observable<Participant[]> = combineLatest([
|
||||
this.filteredParticipants$,
|
||||
this._activeParticipantsSortBy$,
|
||||
]).pipe(
|
||||
map(([participants, sortBy]) => {
|
||||
const activeParticipants = participants.filter(participant => participant.status === ParticipantStatus.ACTIVE);
|
||||
return sortBy ? sort(activeParticipants, sortBy) : activeParticipants;
|
||||
})
|
||||
);
|
||||
|
||||
public followUpParticipants$: Observable<Participant[]> = combineLatest([
|
||||
this.filteredParticipants$,
|
||||
this._followUpParticipantsSortBy$,
|
||||
]).pipe(
|
||||
map(([participants, sortBy]) => {
|
||||
const followUpParticipants = participants.filter(
|
||||
participant => participant.status === ParticipantStatus.FOLLOW_UP
|
||||
);
|
||||
return sortBy ? sort(followUpParticipants, sortBy) : followUpParticipants;
|
||||
})
|
||||
);
|
||||
|
||||
public fetchDetailedParticipantData$(id: string): Observable<Participant> {
|
||||
return this.httpClient
|
||||
.get<ParticipantApiResponse>(`${this._apiBaseUrl}/${id}`)
|
||||
.pipe(map(result => mapParticipantApiResponseToParticipant(result.data)));
|
||||
}
|
||||
|
||||
public setSearchFilter(value: string): void {
|
||||
this._searchFilter$.next(value);
|
||||
}
|
||||
|
||||
public setActiveParticipantsSortKey(key: keyof Participant): void {
|
||||
const currentSortBy = this._activeParticipantsSortBy$.getValue();
|
||||
let order = currentSortBy.order;
|
||||
if (currentSortBy?.key === key) {
|
||||
order = order === SortOrder.ASC ? SortOrder.DESC : SortOrder.ASC;
|
||||
}
|
||||
this._activeParticipantsSortBy$.next({ key, order });
|
||||
}
|
||||
|
||||
public setFollowUpParticipantsSortKey(key: keyof Participant): void {
|
||||
const currentSortBy = this._followUpParticipantsSortBy$.getValue();
|
||||
let order = currentSortBy.order;
|
||||
if (currentSortBy?.key === key) {
|
||||
order = order === SortOrder.ASC ? SortOrder.DESC : SortOrder.ASC;
|
||||
}
|
||||
this._followUpParticipantsSortBy$.next({ key, order });
|
||||
}
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { mapServiceApiResponseToService, Service, ServiceApiResponse } from '@msfa-models/service.model';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ServiceService {
|
||||
private _apiBaseUrl = `${environment.api.url}/services`;
|
||||
public services$: Observable<Service[]> = this.httpClient
|
||||
.get<ServiceApiResponse>(this._apiBaseUrl)
|
||||
.pipe(map(response => response.data.map(service => mapServiceApiResponseToService(service))));
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { AbstractControl, ValidatorFn } from '@angular/forms';
|
||||
import { Alternative } from '@msfa-enums/alternative.enum';
|
||||
import { ReportType } from '@msfa-enums/report-type.enum';
|
||||
import { DayOrPartOfDay } from '@msfa-enums/day-or-part-of-day.enum';
|
||||
import { FranvaroOrsaksKodEnum } from '@msfa-enums/franvaro-orsak-kod.enum';
|
||||
import { KandaOrsakerEnum } from '@msfa-enums/kanda-orsaker-kod.enum';
|
||||
import { ValidationError } from '@msfa-models/validation-error.model';
|
||||
|
||||
export interface Controls {
|
||||
[key: string]: AbstractControl
|
||||
[key: string]: AbstractControl;
|
||||
}
|
||||
|
||||
export function requiredDescriptionValidator(): ValidatorFn {
|
||||
@@ -19,12 +19,12 @@ export function requiredDescriptionValidator(): ValidatorFn {
|
||||
const isRequired = !valueOfFormControl && +valueOfNestedFormControl === KandaOrsakerEnum.AnnanOrsak;
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: 'Beskrivning är obligatoriskt' }
|
||||
return { type: 'required', message: 'Beskrivning är obligatoriskt' };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function requiredOrsakerValidator(): ValidatorFn {
|
||||
@@ -41,7 +41,7 @@ export function requiredOrsakerValidator(): ValidatorFn {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function requiredAnnanKandOrsakValidator(): ValidatorFn {
|
||||
@@ -59,7 +59,7 @@ export function requiredAnnanKandOrsakValidator(): ValidatorFn {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export class RequiredDateValidator {
|
||||
@@ -69,7 +69,7 @@ export class RequiredDateValidator {
|
||||
const isRequired = !valueOfFormControl;
|
||||
|
||||
return isRequired ? { dateIsRequired: 'Datum är obligatoriskt' } : null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ export function requiredDayOrPartOfDayValidator(): ValidatorFn {
|
||||
const ctrls = control?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
const isFranvaro = ctrls['alternative'].value === Alternative.FRANVARO;
|
||||
const isFranvaro = ctrls['alternative'].value === ReportType.FRANVARO;
|
||||
const valueOfFormControl = control.value as string;
|
||||
const isRequired = isFranvaro && !valueOfFormControl;
|
||||
|
||||
@@ -88,7 +88,7 @@ export function requiredDayOrPartOfDayValidator(): ValidatorFn {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function requiredStartTimeValidator(): ValidatorFn {
|
||||
@@ -96,7 +96,7 @@ export function requiredStartTimeValidator(): ValidatorFn {
|
||||
const ctrls = control?.parent?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
const isFranvaro = ctrls['alternative']?.value as string === Alternative.FRANVARO;
|
||||
const isFranvaro = (ctrls['alternative']?.value as string) === ReportType.FRANVARO;
|
||||
const isPartOfDay = ctrls['dayOrPartOfDay']?.value === DayOrPartOfDay.DEL_AV_DAG;
|
||||
const valueOfFormControl = control?.value as string;
|
||||
const isRequired = isFranvaro && isPartOfDay && (valueOfFormControl === '' || valueOfFormControl === null);
|
||||
@@ -107,7 +107,7 @@ export function requiredStartTimeValidator(): ValidatorFn {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function requiredEndTimeValidator(): ValidatorFn {
|
||||
@@ -115,7 +115,7 @@ export function requiredEndTimeValidator(): ValidatorFn {
|
||||
const ctrls = control?.parent?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
const isFranvaro = ctrls['alternative']?.value as string === Alternative.FRANVARO;
|
||||
const isFranvaro = (ctrls['alternative']?.value as string) === ReportType.FRANVARO;
|
||||
const isPartOfDay = ctrls['dayOrPartOfDay']?.value === DayOrPartOfDay.DEL_AV_DAG;
|
||||
const valueOfFormControl = control?.value as string;
|
||||
const isRequired = isFranvaro && isPartOfDay && (valueOfFormControl === '' || valueOfFormControl === null);
|
||||
@@ -126,7 +126,7 @@ export function requiredEndTimeValidator(): ValidatorFn {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function requiredFraga1Validator(): ValidatorFn {
|
||||
@@ -144,7 +144,7 @@ export function requiredFraga1Validator(): ValidatorFn {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function requiredfraga2Validator(): ValidatorFn {
|
||||
@@ -155,11 +155,12 @@ export function requiredfraga2Validator(): ValidatorFn {
|
||||
const isAvvikelse = ctrls['alternative']?.value === 'avvikelse';
|
||||
const valueOfFormControl = control.value as string;
|
||||
const orsaksKodToValidate = ctrls['orsakerFormGroup']?.get('orsaker')?.value as string;
|
||||
const isRequired = isAvvikelse && !valueOfFormControl &&
|
||||
(orsaksKodToValidate !== '19' &&
|
||||
const isRequired =
|
||||
isAvvikelse &&
|
||||
!valueOfFormControl &&
|
||||
orsaksKodToValidate !== '19' &&
|
||||
orsaksKodToValidate !== '20' &&
|
||||
orsaksKodToValidate !== '28'
|
||||
)
|
||||
orsaksKodToValidate !== '28';
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Beskrivning är obligatoriskt` };
|
||||
@@ -167,5 +168,5 @@ export function requiredfraga2Validator(): ValidatorFn {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import fs from 'fs';
|
||||
import activities from './activities.js';
|
||||
import { authTokens } from './auth-tokens.js';
|
||||
import avrop from './avrop.js';
|
||||
import fragorForAvvikelser from './avvikelse-alternative/fragor-for-avvikelser.js';
|
||||
import kandaAvvikelseKoder from './avvikelse-alternative/kanda-avvikelse-koder.js';
|
||||
import orsaksKoderAvvikelse from './avvikelse-alternative/orsaks-koder-avvikelse.js';
|
||||
import orsaksKoderFranvaro from './avvikelse-alternative/orsaks-koder-franvaro.js';
|
||||
import currentUser from './current-user.js';
|
||||
import userinfo from './userinfo.js';
|
||||
import deltagare from './deltagare.js';
|
||||
import deltagareHandelser from './deltagare-handelser.js';
|
||||
import deltagare from './deltagare.js';
|
||||
import employees from './employees.js';
|
||||
import handledare from './handledare.js';
|
||||
import languages from './languages.js';
|
||||
import participants from './participants.js';
|
||||
import tjanster from './tjanster.js';
|
||||
import chooseRandom from './utils/choose-random.util.js';
|
||||
import organizations from './organizations.js';
|
||||
import orsaksKoderFranvaro from './avvikelse-alternative/orsaks-koder-franvaro.js';
|
||||
import orsaksKoderAvvikelse from './avvikelse-alternative/orsaks-koder-avvikelse.js';
|
||||
import kandaAvvikelseKoder from './avvikelse-alternative/kanda-avvikelse-koder.js';
|
||||
import fragorForAvvikelser from './avvikelse-alternative/fragor-for-avvikelser.js';
|
||||
import activities from './activities.js';
|
||||
import tjanster from './tjanster.js';
|
||||
import userinfo from './userinfo.js';
|
||||
import chooseRandom from './utils/choose-random.util.js';
|
||||
|
||||
const ORGANIZATIONS = organizations.generate();
|
||||
const AUTHORIZATIONS = ['Hantera användare', 'Hantera origisation', 'Hantera ekonomi'];
|
||||
@@ -118,10 +117,6 @@ const apiData = {
|
||||
deltagare: generatedDeltagare,
|
||||
deltagareHandelser: generatedDeltagareHandelser,
|
||||
handledare: generatedHandledare,
|
||||
participants: participants.generate(50).map(participant => ({
|
||||
...participant,
|
||||
employeeId: generatedEmployees[Math.floor(Math.random() * generatedEmployees.length)].id,
|
||||
})),
|
||||
currentUser: generatedCurrentUser,
|
||||
organizations: generatedOrganizations,
|
||||
userinfo: generatedUserinfo,
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import faker from 'faker';
|
||||
import tjanster from './tjanster.js';
|
||||
|
||||
faker.locale = 'sv';
|
||||
|
||||
const TJANSTER = tjanster.generate();
|
||||
const STATUSES = ['active', 'follow-up'];
|
||||
const STEPS = ['Gemensam planering', 'Periodisk rapport', 'Resultatrapport', 'Slutrapport'];
|
||||
|
||||
function generateParticipants(amount = 10) {
|
||||
const participants = [];
|
||||
|
||||
for (let i = 1; i <= amount; ++i) {
|
||||
const participant = {
|
||||
id: faker.datatype.uuid(),
|
||||
firstName: faker.name.firstName(),
|
||||
lastName: faker.name.lastName(),
|
||||
status: STATUSES[Math.floor(Math.random() * STATUSES.length)],
|
||||
service: TJANSTER[Math.floor(Math.random() * TJANSTER.length)].label,
|
||||
nextStep: STEPS[Math.floor(Math.random() * STEPS.length)],
|
||||
errandNumber: faker.datatype.number({ min: 100000, max: 999999 }),
|
||||
startDate: faker.date.recent(),
|
||||
endDate: faker.date.future(),
|
||||
handleBefore: faker.date.soon(),
|
||||
};
|
||||
participants.push({ ...participant, fullName: `${participant.firstName} ${participant.lastName}` });
|
||||
}
|
||||
|
||||
console.info('Participants generated...');
|
||||
return participants;
|
||||
}
|
||||
|
||||
export default {
|
||||
generate: generateParticipants,
|
||||
};
|
||||
@@ -31,8 +31,6 @@ server.use(
|
||||
'/employees*onlyEmployeesWithoutAuthorization=*': '/employees$1roles.length_lte=1',
|
||||
'/employees*': '/employees$1',
|
||||
'/services*': '/tjanster$1',
|
||||
'/participants': '/participants?_embed=employees',
|
||||
'/participant/:id': '/participants/:id?_embed=employees',
|
||||
'/auth/userinfo': '/userinfo',
|
||||
'/auth/organizations': '/organizations',
|
||||
'/users/currentUser': '/currentUser',
|
||||
@@ -56,7 +54,7 @@ server.use(
|
||||
'/report/orsakskoderavvikelse': '/orsakskoderavvikelse',
|
||||
'/report/fragorforavvikelser': '/fragorforavvikelser',
|
||||
'/report/orsakskoderfranvaro': '/orsakskoderfranvaro',
|
||||
'/report/kandaavvikelsekoder': '/kandaavvikelsekoder'
|
||||
'/report/kandaavvikelsekoder': '/kandaavvikelsekoder',
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user