fix models
This commit is contained in:
@@ -102,9 +102,9 @@
|
|||||||
<ui-loader *ngIf="submitLoading$ | async" uiType="absolute"></ui-loader>
|
<ui-loader *ngIf="submitLoading$ | async" uiType="absolute"></ui-loader>
|
||||||
<msfa-report-description-list [avrop]="avrop">
|
<msfa-report-description-list [avrop]="avrop">
|
||||||
<dt>Typ av sysselsättning</dt>
|
<dt>Typ av sysselsättning</dt>
|
||||||
<dd>{{typeFormControl.value}}</dd>
|
<dd>{{convertTypeValueToLabel(typeFormControl.value)}}</dd>
|
||||||
<dt>Omfattning</dt>
|
<dt>Omfattning</dt>
|
||||||
<dd>{{omfattningFormControl.value}}</dd>
|
<dd>{{convertOmfattningValueToLabel(omfattningFormControl.value)}}</dd>
|
||||||
<ng-container *ngIf="showPercentFormControl">
|
<ng-container *ngIf="showPercentFormControl">
|
||||||
<dt>Antal procent vid deltid</dt>
|
<dt>Antal procent vid deltid</dt>
|
||||||
<dd>{{percentFormControl.value}}%</dd>
|
<dd>{{percentFormControl.value}}%</dd>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { BehaviorSubject, Observable } from 'rxjs';
|
|||||||
import { map, shareReplay, switchMap, take } from 'rxjs/operators';
|
import { map, shareReplay, switchMap, take } from 'rxjs/operators';
|
||||||
import { SignalFormService } from './signal-form.service';
|
import { SignalFormService } from './signal-form.service';
|
||||||
import { SignalFormValidator } from './signal-form.validator';
|
import { SignalFormValidator } from './signal-form.validator';
|
||||||
import { SignalFormData, SignalFormKeys, SignalOmfattning } from './signal-form.model';
|
import { SignalFormData, SignalFormKeys, SignalOmfattning, SignalType } from './signal-form.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'msfa-signal-form',
|
selector: 'msfa-signal-form',
|
||||||
@@ -31,7 +31,7 @@ export class SignalFormComponent {
|
|||||||
signalFormGroup = new FormGroup(
|
signalFormGroup = new FormGroup(
|
||||||
{
|
{
|
||||||
type: new FormControl(null),
|
type: new FormControl(null),
|
||||||
omfattning: new FormControl('heltid'),
|
omfattning: new FormControl(SignalOmfattning.Heltid),
|
||||||
percent: new FormControl(50),
|
percent: new FormControl(50),
|
||||||
startDate: new FormControl(new Date()),
|
startDate: new FormControl(new Date()),
|
||||||
},
|
},
|
||||||
@@ -50,8 +50,8 @@ export class SignalFormComponent {
|
|||||||
);
|
);
|
||||||
|
|
||||||
typeSelectItems: FormSelectItem[] = [
|
typeSelectItems: FormSelectItem[] = [
|
||||||
{ name: 'Arbete', value: 'arbete' },
|
{ name: 'Arbete', value: SignalType.Arbete },
|
||||||
{ name: 'Utbildning', value: 'utbildning' },
|
{ name: 'Utbildning', value: SignalType.Utbildning },
|
||||||
];
|
];
|
||||||
|
|
||||||
omfattningRadioButtons: Radiobutton[] = [
|
omfattningRadioButtons: Radiobutton[] = [
|
||||||
@@ -61,6 +61,13 @@ export class SignalFormComponent {
|
|||||||
|
|
||||||
constructor(private signalFormService: SignalFormService, private activatedRoute: ActivatedRoute) {}
|
constructor(private signalFormService: SignalFormService, private activatedRoute: ActivatedRoute) {}
|
||||||
|
|
||||||
|
convertTypeValueToLabel(type: SignalType): string {
|
||||||
|
return this.typeSelectItems?.find(selectItem => selectItem.value === type)?.name;
|
||||||
|
}
|
||||||
|
convertOmfattningValueToLabel(type: SignalType): string {
|
||||||
|
return this.omfattningRadioButtons?.find(radiobuttons => radiobuttons.value === type)?.label;
|
||||||
|
}
|
||||||
|
|
||||||
get formErrors(): { [key: string]: string } {
|
get formErrors(): { [key: string]: string } {
|
||||||
return this.signalFormGroup.errors || {};
|
return this.signalFormGroup.errors || {};
|
||||||
}
|
}
|
||||||
@@ -79,7 +86,7 @@ export class SignalFormComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get showPercentFormControl(): boolean {
|
get showPercentFormControl(): boolean {
|
||||||
return this.omfattningFormControl.value === 'deltid';
|
return this.omfattningFormControl.value === SignalOmfattning.Deltid;
|
||||||
}
|
}
|
||||||
|
|
||||||
get startDateFormValueAsDate(): Date {
|
get startDateFormValueAsDate(): Date {
|
||||||
@@ -110,9 +117,9 @@ export class SignalFormComponent {
|
|||||||
|
|
||||||
private typeToRequest(type: string): SignalRequestType {
|
private typeToRequest(type: string): SignalRequestType {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'arbete':
|
case SignalType.Arbete:
|
||||||
return SignalRequestType.Work;
|
return SignalRequestType.Work;
|
||||||
case 'utbildning':
|
case SignalType.Utbildning:
|
||||||
return SignalRequestType.Education;
|
return SignalRequestType.Education;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { AbstractControl, ValidatorFn } from '@angular/forms';
|
import { AbstractControl, ValidatorFn } from '@angular/forms';
|
||||||
import { SignalFormData } from './signal-form.model';
|
import { SignalFormData, SignalOmfattning } from './signal-form.model';
|
||||||
|
|
||||||
export class SignalFormValidator {
|
export class SignalFormValidator {
|
||||||
static isSignalValid(): ValidatorFn {
|
static isSignalValid(): ValidatorFn {
|
||||||
@@ -13,7 +13,7 @@ export class SignalFormValidator {
|
|||||||
type: 'Typ av sysselsättning måste väljas',
|
type: 'Typ av sysselsättning måste väljas',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (type && omfattning === 'deltid') {
|
if (type && omfattning === SignalOmfattning.Deltid) {
|
||||||
if (percent < 1) {
|
if (percent < 1) {
|
||||||
errors = {
|
errors = {
|
||||||
...errors,
|
...errors,
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
export interface SignalResponse {
|
export enum SignalResponseType {
|
||||||
typ: 'arbete' | 'utbildning';
|
Work = 'work',
|
||||||
omfattning: 'heltid' | 'deltid';
|
Education = 'education',
|
||||||
omfattning_procent: number;
|
}
|
||||||
startdatum: string;
|
|
||||||
|
export enum SignalResponseOmfattning {
|
||||||
|
Heltid = 'heltid',
|
||||||
|
Deltid = 'deltid',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SignalResponse {
|
||||||
|
genomforandereferens: number;
|
||||||
|
type: SignalResponseType;
|
||||||
|
omfattning: SignalResponseOmfattning;
|
||||||
|
omfattningPercent: number;
|
||||||
|
startDate: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
import { SignalResponse } from './api/signal.response.model';
|
import { SignalResponse } from './api/signal.response.model';
|
||||||
import { Signal } from '../../pages/deltagare/pages/deltagare-details/pages/report-forms/signal-form/signal-form.model';
|
|
||||||
|
export type Signal = SignalResponse;
|
||||||
|
|
||||||
export function mapResponseToSignal(data: SignalResponse): Signal {
|
export function mapResponseToSignal(data: SignalResponse): Signal {
|
||||||
const { typ, startdatum, omfattning, omfattning_procent } = data;
|
return data;
|
||||||
|
|
||||||
return {
|
|
||||||
type: typ,
|
|
||||||
omfattning,
|
|
||||||
percent: omfattning_procent,
|
|
||||||
startDate: new Date(startdatum),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user