Merge pull request #169 in TEA/mina-sidor-fa-web from bugfix/TV-718 to develop
Squashed commit of the following: commit 798af49b3e42f9d593b23d9fad1dc90aaf93e6af Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 17:23:10 2021 +0200 TV-718 update enum values commit 15fc401f8d995e7d991b7930c5295950b5954f13 Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 17:22:45 2021 +0200 TV-718 lower case on methods, cleaning, commit 900b72e5b0eda2dae36e7c315aa851c0117cad4e Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 17:05:30 2021 +0200 TV-718 updated heading commit 23f6077ebce03d61bc7bd65125d072916a2bfb51 Merge: b9c76e14f68eadbdAuthor: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 16:28:12 2021 +0200 Merge branch 'develop' into bugfix/TV-718 commit b9c76e1489729c4703d9db12e0724fd6db066386 Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 13:21:34 2021 +0200 TV-718 dont send contactInformatin in payload commit d636eaea7148b2aef1d67cf65612c0f1fd52de15 Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 11:44:38 2021 +0200 TV 718: update some headings and corr misspelling commit 68d355858b4fefc159448e34238267e0f3253824 Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 09:20:39 2021 +0200 TV-718 deleted console log commit 742dbba8859053786924c0a3a6da3f0f22654397 Merge: d961c55993556d48Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 08:45:57 2021 +0200 Merge branch 'develop' into bugfix/TV-718 commit d961c559837edb81976f3e5756fa63b450b57d24 Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Mon Oct 4 08:45:25 2021 +0200 TV-718 validation works, refactoring commit 5f89417a63757b7e51bcda382da86ed73a4dd042 Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Fri Oct 1 11:08:25 2021 +0200 TV-718 validator fixes
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<p>{{ formGroup?.get('alternative').value === 'franvaro' ? 'Frånvaro' : 'Avvikelse'}}</p>
|
||||
|
||||
<ng-container *ngIf="formGroup?.get('alternative').value === 'franvaro'">
|
||||
<h3 class="deltagare-confirm__header">Frånvaroorsak</h3>
|
||||
<h3 class="deltagare-confirm__header">Orsak till frånvaro</h3>
|
||||
<ng-container *ngFor="let orsak of orsakskoderfranvaro">
|
||||
<p *ngIf="orsak.value == formGroup?.get('orsakerFormGroup').get('orsaker').value">{{orsak.name}}</p>
|
||||
</ng-container>
|
||||
@@ -24,20 +24,20 @@
|
||||
|
||||
<h3 class="deltagare-confirm__header">Datum</h3>
|
||||
<p>{{formGroup?.get('date').value}}</p>
|
||||
<h3 class="deltagare-confirm__header">Hel- eller del av dag</h3>
|
||||
<h3 class="deltagare-confirm__header">Hel eller del av dag</h3>
|
||||
<p>{{formGroup.get('dayOrPartOfDay').value === 'HELDAG' ? 'Heldag' : 'Del av dag'}}</p>
|
||||
|
||||
<ng-container *ngIf="formGroup.get('dayOrPartOfDay').value === 'DEL_AV_DAG'">
|
||||
<h3 class="deltagare-confirm__header">Startid</h3>
|
||||
<h3 class="deltagare-confirm__header">Starttid</h3>
|
||||
<p>{{formGroup?.get('timepickerFormGroup').get('startTime').value}}</p>
|
||||
|
||||
<h3 class="deltagare-confirm-header">Sluttid</h3>
|
||||
<h3 class="deltagare-confirm__header">Sluttid</h3>
|
||||
<p>{{formGroup?.get('timepickerFormGroup').get('endTime').value}}</p>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="formGroup?.get('alternative').value === 'avvikelse'">
|
||||
<h3 class="deltagare-confirm__header">Avvikelseoorsak</h3>
|
||||
<h3 class="deltagare-confirm__header">Orsak till avvikelse</h3>
|
||||
<ng-container *ngFor="let orsak of avvikelseOrsaker">
|
||||
<p *ngIf="orsak.value == formGroup?.get('orsakerFormGroup').get('orsaker').value">{{orsak.name}}</p>
|
||||
</ng-container>
|
||||
@@ -60,7 +60,7 @@
|
||||
{{fraga.name}}
|
||||
</h3>
|
||||
</ng-container>
|
||||
<p>{{formGroup?.get('fragorFormGroup').get('fraga2').value}}</p>
|
||||
<p *ngIf="selectedOrsak !== '28'">{{formGroup?.get('fragorFormGroup').get('fraga2').value}}</p>
|
||||
|
||||
<h3 class="deltagare-confirm__header">Datum</h3>
|
||||
<p>{{formGroup?.get('date').value}}</p>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { AvvikelseOrsaksKodEnum } from '@msfa-enums/avvikelse-orsak-kod.enum';
|
||||
import { FragorForAvvikelser } from '@msfa-models/fragor-for-avvikelser.model';
|
||||
import { OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model';
|
||||
import { KandaAvvikelseKoder, OrsaksKoderFranvaro } from '@msfa-models/orsaks-koder-franvaro.model';
|
||||
@@ -10,11 +11,18 @@ import { KandaAvvikelseKoder, OrsaksKoderFranvaro } from '@msfa-models/orsaks-ko
|
||||
styleUrls: ['./deltagare-confirm-form.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.Default
|
||||
})
|
||||
export class DeltagareConfirmFormComponent {
|
||||
export class DeltagareConfirmFormComponent implements OnChanges {
|
||||
@Input() formGroup: FormGroup | null = null;
|
||||
@Input() orsakskoderfranvaro: OrsaksKoderFranvaro[];
|
||||
@Input() andraKandaOrsaker: KandaAvvikelseKoder[];
|
||||
@Input() avvikelseOrsaker: OrsaksKoderAvvikelse[];
|
||||
@Input() fragor1: FragorForAvvikelser[];
|
||||
@Input() fragor2: FragorForAvvikelser[];
|
||||
@Input() selectedOrsak: string;
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (Number(changes.selectedOrsak?.currentValue) === AvvikelseOrsaksKodEnum.SerTillAttErbjudetArbeteInteKommerTillStand) {
|
||||
this.formGroup?.get('fragorFormGroup').get('fraga2').reset('');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,33 +6,23 @@
|
||||
[afLabel]="fraga.name"
|
||||
[afDisableValidStyle]="true"
|
||||
[afRequired]="true"
|
||||
[afInvalid]="avvikelseFormGroup?.errors?.motiveringIsRequired && fragorFormGroup.get('fraga1').touched"
|
||||
[afInvalidMessage]="fragorFormGroup.get('fraga1').errors?.message"
|
||||
[afInvalid]="fragorFormGroup.get('fraga1').invalid && fragorFormGroup.get('fraga1').touched"
|
||||
[afMaxLength]="2000"
|
||||
></digi-ng-form-textarea>
|
||||
<digi-form-validation-message
|
||||
af-variation="error"
|
||||
*ngIf="avvikelseFormGroup?.errors?.motiveringIsRequired && fragorFormGroup.get('fraga1').touched"
|
||||
>
|
||||
Beskrivning är obligatoriskt
|
||||
</digi-form-validation-message>
|
||||
</div>
|
||||
</ng-container>
|
||||
<ng-container *ngFor="let fraga of fragor2 | filterFragor: selectedOrsaksKod">
|
||||
<div *ngIf="fragor1?.length > 0" class="fragor-form__content">
|
||||
<div class="fragor-form__content">
|
||||
<digi-ng-form-textarea
|
||||
[formControlName]="'fraga2'"
|
||||
[afLabel]="fraga.name"
|
||||
[afDisableValidStyle]="true"
|
||||
[afRequired]="fraga.descriptionIsRequired"
|
||||
[afInvalid]="fraga.descriptionIsRequired && fragorFormGroup.get('fraga2').touched && !fragorFormGroup.get('fraga2').value"
|
||||
[afRequired]="selectedOrsaksKod !== '19' && selectedOrsaksKod !== '20' && selectedOrsaksKod !== '28'"
|
||||
[afInvalidMessage]="fragorFormGroup.get('fraga2').errors?.message"
|
||||
[afInvalid]="fragorFormGroup.get('fraga2').invalid && fragorFormGroup.get('fraga2').touched"
|
||||
[afMaxLength]="2000"
|
||||
></digi-ng-form-textarea>
|
||||
<digi-form-validation-message
|
||||
af-variation="error"
|
||||
*ngIf="fraga.descriptionIsRequired && fragorFormGroup.get('fraga2').touched && !fragorFormGroup.get('fraga2').value"
|
||||
>
|
||||
Beskrivning är obligatoriskt
|
||||
</digi-form-validation-message>
|
||||
</div>
|
||||
</ng-container>
|
||||
</form>
|
||||
|
||||
@@ -16,5 +16,4 @@ export class DeltagareFragorFormComponent {
|
||||
@Input() fragorFormGroup: FormGroup | null = null;
|
||||
@Input() avvikelseFormGroup: FormGroup | null = null;
|
||||
@Input() selectedOrsaksKod: string | null = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<digi-ng-form-select
|
||||
*ngIf="franvaroOrsaker || avvikelseOrsaker; else loadingRef"
|
||||
[formControlName]="'orsaker'"
|
||||
[afLabel]="selectedAlternative === 'franvaro' ? 'Frånvaroorsak' : 'Avvikelseorsak'"
|
||||
[afLabel]="selectedAlternative === 'franvaro' ? 'Orsak till frånvaro' : 'Orsak till avvikelse'"
|
||||
[afPlaceholder]="'Välj orsak till ' + (selectedAlternative === 'franvaro' ? 'frånvaro' : 'avvikelse')"
|
||||
[afSelectItems]="selectedAlternative === 'franvaro' ? franvaroOrsaker : avvikelseOrsaker"
|
||||
[afDisableValidStyle]="true"
|
||||
|
||||
@@ -10,14 +10,9 @@
|
||||
[afDescription]="'Ange starttid'"
|
||||
[formControl]="timepickerFormGroup.get('startTime')"
|
||||
[afDisableValidStyle]="true"
|
||||
[afInvalidMessage]="timepickerFormGroup.get('startTime').errors?.message"
|
||||
afType="time"
|
||||
></digi-ng-form-input>
|
||||
<digi-form-validation-message
|
||||
af-variation="error"
|
||||
*ngIf="avvikelseFormGroup.errors?.startTimeIsRequired && timepickerFormGroup.get('startTime').touched"
|
||||
>
|
||||
Starttid är obligatoriskt
|
||||
</digi-form-validation-message>
|
||||
</div>
|
||||
<div class="deltagare-timepicker__input">
|
||||
<digi-ng-form-input
|
||||
@@ -25,14 +20,9 @@
|
||||
[afDescription]="'Ange sluttid'"
|
||||
[formControl]="timepickerFormGroup.get('endTime')"
|
||||
[afDisableValidStyle]="true"
|
||||
[afInvalidMessage]="timepickerFormGroup.get('endTime').errors?.message"
|
||||
afType="time"
|
||||
></digi-ng-form-input>
|
||||
<digi-form-validation-message
|
||||
af-variation="error"
|
||||
*ngIf="avvikelseFormGroup.errors?.endTimeIsRequired && timepickerFormGroup.get('endTime').touched"
|
||||
>
|
||||
Sluttid är obligatoriskt
|
||||
</digi-form-validation-message>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
}
|
||||
|
||||
&__start-time {
|
||||
margin-bottom: $digi--layout--gutter--m;
|
||||
margin-bottom: $digi--layout--gutter--l;
|
||||
}
|
||||
|
||||
&__input {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
></digi-ng-form-radiobutton-group>
|
||||
<digi-form-validation-message
|
||||
af-variation="error"
|
||||
*ngIf="alternativeFormControl.invalid && avvikelseFormGroup.touched"
|
||||
*ngIf="alternativeFormControl.invalid && alternativeFormControl.touched"
|
||||
>
|
||||
Alternativ är obligatoriskt
|
||||
</digi-form-validation-message>
|
||||
@@ -45,14 +45,9 @@
|
||||
[afDisableValidStyle]="true"
|
||||
[afMaxLength]="2000"
|
||||
[afRequired]="true"
|
||||
[afInvalid]="avvikelseFormGroup?.errors?.descriptionIsRequired && descriptionFormControl.touched"
|
||||
[afInvalidMessage]="descriptionFormControl.errors?.message"
|
||||
[afInvalid]="descriptionFormControl?.invalid && descriptionFormControl.touched"
|
||||
></digi-ng-form-textarea>
|
||||
<digi-form-validation-message
|
||||
af-variation="error"
|
||||
*ngIf="avvikelseFormGroup?.errors?.descriptionIsRequired && descriptionFormControl.touched"
|
||||
>
|
||||
Beskrivning är obligatoriskt
|
||||
</digi-form-validation-message>
|
||||
</div>
|
||||
|
||||
<msfa-deltagare-fragor-form
|
||||
@@ -80,8 +75,15 @@
|
||||
<digi-ng-form-radiobutton-group
|
||||
[afRadiobuttons]="dayOrPartOfDay"
|
||||
[formControlName]="dayOrPartOfDayFormControlName"
|
||||
[afRequired]="avvikelseFormGroup.errors?.dayOrPartOfDayIsRequired"
|
||||
[afRequired]="dayOrPartOfDayFormControl.invalid && dayOrPartOfDayFormControl.touched"
|
||||
(change)="setDayOrPartOfDayChanged()"
|
||||
></digi-ng-form-radiobutton-group>
|
||||
<digi-form-validation-message
|
||||
af-variation="error"
|
||||
*ngIf="dayOrPartOfDayFormControl.invalid && dayOrPartOfDayFormControl.touched"
|
||||
>
|
||||
{{dayOrPartOfDayFormControl.errors?.message}}
|
||||
</digi-form-validation-message>
|
||||
</div>
|
||||
|
||||
<msfa-deltagare-time-picker
|
||||
@@ -100,6 +102,7 @@
|
||||
[avvikelseOrsaker]="avvikelseOrsaker$ | async"
|
||||
[fragor1]="fragor1$ | async"
|
||||
[fragor2]="fragor2$ | async"
|
||||
[selectedOrsak]="selectedOrsaksKod"
|
||||
></msfa-deltagare-confirm-form>
|
||||
|
||||
<div class="deltagare-avvikelse__step-buttons-wrapper">
|
||||
|
||||
@@ -17,18 +17,14 @@ import { OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model'
|
||||
import { KandaAvvikelseKoder, OrsaksKoderFranvaro } from '@msfa-models/orsaks-koder-franvaro.model';
|
||||
import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service';
|
||||
import {
|
||||
AnnanKandOrsakeIsRequiredCheck,
|
||||
DateIsRequiredCheck,
|
||||
DayOrPartOfDayIsRequiredCheck,
|
||||
DescriptionIsRequiredCheck,
|
||||
EndTimeIsRequiredCheck,
|
||||
MotiveringIsRequiredCheck,
|
||||
OrsakerIsRequiredCheck,
|
||||
StartTimeIsRequiredCheck,
|
||||
requiredAnnanKandOrsakValidator, RequiredDateValidator,
|
||||
requiredDayOrPartOfDayValidator, requiredDescriptionValidator, requiredEndTimeValidator,
|
||||
requiredFraga1Validator,
|
||||
requiredfraga2Validator, requiredOrsakerValidator, requiredStartTimeValidator
|
||||
} from '@msfa-utils/validators/avvikelse-form-validator';
|
||||
import { RequiredValidator } from '@msfa-utils/validators/required.validator';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { first, map, switchMap } from 'rxjs/operators';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { DeltagareAvvikelseService } from '../../services/deltagare-avvikelse.service';
|
||||
import { avvikelseAlternatives, dayOrPartOfDay } from './report-alternatives';
|
||||
|
||||
@@ -63,7 +59,6 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
andraKandaOrsaker$: Observable<KandaAvvikelseKoder[]>;
|
||||
fragor1$: Observable<FragorForAvvikelser[]>;
|
||||
fragor2$: Observable<FragorForAvvikelser[]>;
|
||||
contactInformation: ContactInformation;
|
||||
sizeTextArea: FormTextareaSize.S;
|
||||
todayDate = new Date().toISOString().slice(0, 10);
|
||||
avvikelseAlternatives: RadiobuttonModel[] = avvikelseAlternatives;
|
||||
@@ -84,45 +79,29 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.contactInformation$.pipe(first()).subscribe(contactInformation => {
|
||||
this.contactInformation = contactInformation;
|
||||
});
|
||||
|
||||
this.avvikelseFormGroup = new FormGroup(
|
||||
{
|
||||
alternative: new FormControl(null, [RequiredValidator()]),
|
||||
description: new FormControl(''),
|
||||
description: new FormControl('', [requiredDescriptionValidator()]),
|
||||
date: new FormControl(this.todayDate),
|
||||
dayOrPartOfDay: new FormControl(null),
|
||||
dayOrPartOfDay: new FormControl(null, [requiredDayOrPartOfDayValidator()]),
|
||||
orsakerFormGroup: new FormGroup({
|
||||
orsaker: new FormControl([]),
|
||||
andraKandaOrsaker: new FormControl([]),
|
||||
orsaker: new FormControl([], [requiredOrsakerValidator()]),
|
||||
andraKandaOrsaker: new FormControl([], [requiredAnnanKandOrsakValidator()])
|
||||
}),
|
||||
fragorFormGroup: new FormGroup({
|
||||
fraga1: new FormControl(''),
|
||||
fraga2: new FormControl(''),
|
||||
fraga1: new FormControl('', [requiredFraga1Validator()]),
|
||||
fraga2: new FormControl('', [requiredfraga2Validator()])
|
||||
}),
|
||||
timepickerFormGroup: new FormGroup({
|
||||
startTime: new FormControl(''),
|
||||
endTime: new FormControl(''),
|
||||
startTime: new FormControl('', [requiredStartTimeValidator()]),
|
||||
endTime: new FormControl('', [requiredEndTimeValidator()])
|
||||
}),
|
||||
},
|
||||
{
|
||||
validators: [
|
||||
DescriptionIsRequiredCheck.CheckIfRequired(
|
||||
'description',
|
||||
'orsakerFormGroup',
|
||||
'andraKandaOrsaker',
|
||||
KandaOrsakerEnum.AnnanOrsak
|
||||
),
|
||||
OrsakerIsRequiredCheck.CheckIfRequired('orsakerFormGroup', 'orsaker'),
|
||||
AnnanKandOrsakeIsRequiredCheck.CheckIfRequired('orsakerFormGroup', 'andraKandaOrsaker'),
|
||||
DateIsRequiredCheck.CheckIfRequired('date'),
|
||||
DayOrPartOfDayIsRequiredCheck.CheckIfRequired('dayOrPartOfDay'),
|
||||
StartTimeIsRequiredCheck.CheckIfRequired('timepickerFormGroup', 'startTime'),
|
||||
EndTimeIsRequiredCheck.CheckIfRequired('timepickerFormGroup', 'endTime'),
|
||||
MotiveringIsRequiredCheck.CheckIfRequired('fraga1'),
|
||||
],
|
||||
RequiredDateValidator.CheckIfRequired()
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -172,11 +151,6 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
if (confirm === ConfirmDialog.ACCEPTED) {
|
||||
const postAvvikelse: Avvikelse = {
|
||||
datum_for_rapportering: this.todayDate,
|
||||
arbetssokande: {
|
||||
personnummer: this.contactInformation.ssn,
|
||||
fornamn: this.contactInformation.firstName,
|
||||
efternamn: this.contactInformation.lastName,
|
||||
},
|
||||
sokandeId: +this.activatedRoute.snapshot.params['genomforandeReferens'],
|
||||
};
|
||||
|
||||
@@ -251,7 +225,6 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
this.fragor2$ = this.deltagareAvvikelseService.getFragorForAvvikelser$().pipe(
|
||||
map((fragor: FragorForAvvikelser[]) => {
|
||||
return fragor.filter((fraga: FragorForAvvikelser) => {
|
||||
this.setIfRequiredDescription(fraga);
|
||||
return fraga.id.includes('_2');
|
||||
});
|
||||
})
|
||||
@@ -261,12 +234,6 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
this.clearControlOnAlternativeChange();
|
||||
}
|
||||
|
||||
private setIfRequiredDescription(fraga: FragorForAvvikelser) {
|
||||
fraga.id === '19_2' || fraga.id === '20_2'
|
||||
? (fraga.descriptionIsRequired = false)
|
||||
: (fraga.descriptionIsRequired = true);
|
||||
}
|
||||
|
||||
setOrsakerChanged(): void {
|
||||
this.avvikelseFormGroup.markAsUntouched();
|
||||
if ((this.alternativeFormControl.value as string) === Alternative.AVVIKELSE) {
|
||||
@@ -283,6 +250,13 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
setDayOrPartOfDayChanged(): void {
|
||||
if (this.dayOrPartOfDayFormControl.value === DayOrPartOfDay.HELDAG) {
|
||||
this.startTimeFormControl.reset();
|
||||
this.endTimeFormControl.reset();
|
||||
}
|
||||
}
|
||||
|
||||
get showDescription(): boolean {
|
||||
return (
|
||||
(this.alternativeFormControl.value as string) == Alternative.FRANVARO &&
|
||||
@@ -317,6 +291,8 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
}
|
||||
|
||||
get nextStep(): number {
|
||||
console.log(this.avvikelseFormGroup);
|
||||
|
||||
this.avvikelseFormGroup.markAllAsTouched();
|
||||
if (this.avvikelseFormGroup.valid && this.currentStep < this.totalAmountOfSteps) {
|
||||
return this.currentStep++;
|
||||
@@ -332,7 +308,9 @@ export class DeltagareAvvikelseComponent implements OnInit {
|
||||
}
|
||||
|
||||
backToDeltagare(): void {
|
||||
void this.router.navigate(['./deltagare', this.activatedRoute.snapshot.params['genomforandeReferens']]);
|
||||
this.router.navigate(['./deltagare', this.activatedRoute.snapshot.params['genomforandeReferens']])
|
||||
.catch(error => console.log(error, 'Failed to go back to deltagare')
|
||||
);
|
||||
}
|
||||
|
||||
private clearControlOnAlternativeChange(): void {
|
||||
|
||||
@@ -18,7 +18,14 @@ export class DeltagareAvvikelseService {
|
||||
public getOrsaksKoderFranvaro$(): Observable<OrsaksKoderFranvaro[]> {
|
||||
return this.avvikelseApiService.getOrsaksKoderFranvaro$()
|
||||
.pipe(
|
||||
map((orsaksKoder: OrsaksKoderFranvaro[]) => this.sortOrsaksKoder(orsaksKoder))
|
||||
map((orsaksKoder: OrsaksKoderFranvaro[]) => {
|
||||
orsaksKoder.find(kod => {
|
||||
if (kod.value === FranvaroOrsaksKodEnum.VAB) {
|
||||
kod.name = 'Vård av barn';
|
||||
}
|
||||
});
|
||||
return this.sortOrsaksKoder(orsaksKoder)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,6 @@ export enum FranvaroOrsaksKodEnum {
|
||||
Arbete = 16,
|
||||
OkandOrsak = 17,
|
||||
AnnanKandOrsak = 18,
|
||||
VAB = 23,
|
||||
Utbildning = 24,
|
||||
VAB = 26,
|
||||
Utbildning = 27,
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export interface Arbetssokande {
|
||||
personnummer: string,
|
||||
fornamn: string,
|
||||
efternamn: string
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
import { Arbetssokande } from './arbetssokande.model';
|
||||
import { AvvikelseAlternativ } from './avvikelse-alternativ.model';
|
||||
import { FranvaroAlternativ } from './franvaro-alternativ.model';
|
||||
|
||||
export interface Avvikelse {
|
||||
datum_for_rapportering: string,
|
||||
arbetssokande: Arbetssokande,
|
||||
sokandeId: number;
|
||||
avvikelsealternativ?: AvvikelseAlternativ,
|
||||
franvaro?: FranvaroAlternativ
|
||||
@@ -12,24 +10,21 @@ export interface Avvikelse {
|
||||
|
||||
export interface AvvikelseRequestData {
|
||||
datum_for_rapportering: string,
|
||||
arbetssokande: Arbetssokande,
|
||||
sokandeId: number;
|
||||
avvikelsealternativ: AvvikelseAlternativ,
|
||||
}
|
||||
|
||||
export interface FranvaroRequestData {
|
||||
datum_for_rapportering: string,
|
||||
arbetssokande: Arbetssokande,
|
||||
sokandeId: number;
|
||||
franvaro: FranvaroAlternativ
|
||||
}
|
||||
|
||||
export function mapAvvikelseRequestDataToAvvikelse(data: AvvikelseRequestData): Avvikelse {
|
||||
const { datum_for_rapportering, arbetssokande, sokandeId, avvikelsealternativ } = data;
|
||||
const { datum_for_rapportering, sokandeId, avvikelsealternativ } = data;
|
||||
|
||||
return {
|
||||
datum_for_rapportering,
|
||||
arbetssokande,
|
||||
sokandeId,
|
||||
avvikelsealternativ
|
||||
}
|
||||
|
||||
@@ -3,113 +3,169 @@ import { Alternative } from '@msfa-enums/alternative.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 class DescriptionIsRequiredCheck {
|
||||
static CheckIfRequired(
|
||||
controlToValidateName: string,
|
||||
nestedFormGroupName: string,
|
||||
nestedFormGroupControlName: string,
|
||||
valueForWhichTheControlShouldBeRequired: KandaOrsakerEnum
|
||||
): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: boolean } => {
|
||||
const valueOfControlToValidate = fg?.get(controlToValidateName)?.value as string;
|
||||
const valueOfNestedFormControl = fg?.get(nestedFormGroupName)?.get(nestedFormGroupControlName)?.value as string;
|
||||
const isRequired = +valueOfNestedFormControl === valueForWhichTheControlShouldBeRequired && valueOfControlToValidate === '';
|
||||
|
||||
return isRequired ? { descriptionIsRequired: true } : null;
|
||||
};
|
||||
}
|
||||
export interface Controls {
|
||||
[key: string]: AbstractControl
|
||||
}
|
||||
|
||||
export class OrsakerIsRequiredCheck {
|
||||
static CheckIfRequired(
|
||||
nestedFormGroupName: string,
|
||||
controlToValidateName: string,
|
||||
): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: boolean } => {
|
||||
const valueOfNestedFormControl = fg?.get(nestedFormGroupName)?.get(controlToValidateName)?.value as string;
|
||||
const isRequired = valueOfNestedFormControl === null && fg?.get(nestedFormGroupName)?.get('andraKandaOrsaker')?.value === null;
|
||||
export function requiredDescriptionValidator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.controls as Controls;
|
||||
|
||||
return isRequired ? { orsakerIsRequired: true } : null;
|
||||
};
|
||||
}
|
||||
}
|
||||
if (ctrls) {
|
||||
const valueOfNestedFormControl = ctrls['orsakerFormGroup'].get('andraKandaOrsaker').value as string;
|
||||
const valueOfFormControl = control.value as string;
|
||||
const isRequired = !valueOfFormControl && +valueOfNestedFormControl === KandaOrsakerEnum.AnnanOrsak;
|
||||
|
||||
export class DayOrPartOfDayIsRequiredCheck {
|
||||
static CheckIfRequired(
|
||||
controlToValidateName: string,
|
||||
): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: boolean } => {
|
||||
const valueOfControlToValidate = fg?.get(controlToValidateName)?.value as string;
|
||||
const isRequired = valueOfControlToValidate === null && fg?.get('alternative').value === Alternative.FRANVARO;
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: 'Beskrivning är obligatoriskt' }
|
||||
}
|
||||
|
||||
return isRequired ? { dayOrPartOfDayIsRequired: true } : null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class AnnanKandOrsakeIsRequiredCheck {
|
||||
static CheckIfRequired(
|
||||
nestedFormGroupName: string,
|
||||
controlToValidateName: string,
|
||||
): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: boolean } => {
|
||||
const valueOfNestedFormControl = fg?.get(nestedFormGroupName)?.get(controlToValidateName)?.value as string;
|
||||
const isRequired = +fg?.get(nestedFormGroupName).get('orsaker').value === FranvaroOrsaksKodEnum.AnnanKandOrsak &&
|
||||
valueOfNestedFormControl === null;
|
||||
|
||||
return isRequired ? { annanKandorsakIsRequired: true } : null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class StartTimeIsRequiredCheck {
|
||||
static CheckIfRequired(
|
||||
nestedFormGroupName: string,
|
||||
startTimeControlToValidateName: string,
|
||||
): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: boolean } => {
|
||||
const valueOfStartTimeFormControl = fg?.get(nestedFormGroupName)?.get(startTimeControlToValidateName)?.value as string;
|
||||
const isRequired = fg?.get('alternative')?.value as string === Alternative.FRANVARO &&
|
||||
fg?.get('dayOrPartOfDay').value === DayOrPartOfDay.DEL_AV_DAG && !valueOfStartTimeFormControl;
|
||||
|
||||
return isRequired ? { startTimeIsRequired: true } : null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class EndTimeIsRequiredCheck {
|
||||
static CheckIfRequired(
|
||||
nestedFormGroupName: string,
|
||||
endTimeControlToValidateName: string
|
||||
): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: boolean } => {
|
||||
const valueOfEndTimeFormControl = fg?.get(nestedFormGroupName)?.get(endTimeControlToValidateName)?.value as string;
|
||||
const isRequired = fg?.get('alternative').value as string === Alternative.FRANVARO &&
|
||||
fg?.get('dayOrPartOfDay').value === DayOrPartOfDay.DEL_AV_DAG && !valueOfEndTimeFormControl;
|
||||
export function requiredOrsakerValidator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.controls as Controls;
|
||||
|
||||
return isRequired ? { endTimeIsRequired: true } : null;
|
||||
if (ctrls) {
|
||||
const valueOfNestedFormControl = ctrls['orsaker'].value as string;
|
||||
const isRequired = !valueOfNestedFormControl && !ctrls['andraKandaOrsaker'].value;
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Orsak är obligatoriskt` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class MotiveringIsRequiredCheck {
|
||||
static CheckIfRequired(controlToValidateName: string): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: boolean } => {
|
||||
const valueOfControlToValidate = fg?.get('fragorFormGroup').get(controlToValidateName)?.value as string;
|
||||
const isRequired = fg?.get('alternative').value as string === Alternative.AVVIKELSE && valueOfControlToValidate === '';
|
||||
export function requiredAnnanKandOrsakValidator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.controls as Controls;
|
||||
|
||||
return isRequired ? { motiveringIsRequired: true } : null;
|
||||
};
|
||||
if (ctrls) {
|
||||
const isAnnanKandOrsak = +ctrls['orsaker'].value === FranvaroOrsaksKodEnum.AnnanKandOrsak;
|
||||
const valueOfNestedFormControl = ctrls['andraKandaOrsaker'].value as string;
|
||||
const isRequired = isAnnanKandOrsak && !valueOfNestedFormControl;
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Annan orsak är obligatoriskt` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
export class DateIsRequiredCheck {
|
||||
static CheckIfRequired(controlToValidateName: string): ValidatorFn {
|
||||
|
||||
export class RequiredDateValidator {
|
||||
static CheckIfRequired(): ValidatorFn {
|
||||
return (fg: AbstractControl): { [key: string]: string } => {
|
||||
const valueOfControlToValidate = fg?.get(controlToValidateName).value as string;
|
||||
const isRequired = valueOfControlToValidate === '';
|
||||
const valueOfFormControl = fg?.get('date')?.value as string;
|
||||
const isRequired = !valueOfFormControl;
|
||||
|
||||
return isRequired ? { dateIsRequired: 'Datum är obligatoriskt' } : null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function requiredDayOrPartOfDayValidator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
const isFranvaro = ctrls['alternative'].value === Alternative.FRANVARO;
|
||||
const valueOfFormControl = control.value as string;
|
||||
const isRequired = isFranvaro && !valueOfFormControl;
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Hel- eller del av dag är obligatoriskt` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function requiredStartTimeValidator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
const isFranvaro = ctrls['alternative']?.value as string === Alternative.FRANVARO;
|
||||
const isPartOfDay = ctrls['dayOrPartOfDay']?.value === DayOrPartOfDay.DEL_AV_DAG;
|
||||
const valueOfFormControl = control?.value as string;
|
||||
const isRequired = isFranvaro && isPartOfDay && (valueOfFormControl === '' || valueOfFormControl === null);
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Starttid är obligatoriskt` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function requiredEndTimeValidator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
const isFranvaro = ctrls['alternative']?.value as string === Alternative.FRANVARO;
|
||||
const isPartOfDay = ctrls['dayOrPartOfDay']?.value === DayOrPartOfDay.DEL_AV_DAG;
|
||||
const valueOfFormControl = control?.value as string;
|
||||
const isRequired = isFranvaro && isPartOfDay && (valueOfFormControl === '' || valueOfFormControl === null);
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Sluttid är obligatoriskt` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function requiredFraga1Validator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
const isAvvikelse = ctrls['alternative']?.value === 'avvikelse';
|
||||
const valueOfFormControl = control.value as string;
|
||||
const isRequired = isAvvikelse && !valueOfFormControl;
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Beskrivning är obligatoriskt` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function requiredfraga2Validator(): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
const ctrls = control?.parent?.parent?.controls as Controls;
|
||||
|
||||
if (ctrls) {
|
||||
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' &&
|
||||
orsaksKodToValidate !== '20' &&
|
||||
orsaksKodToValidate !== '28'
|
||||
)
|
||||
|
||||
if (isRequired) {
|
||||
return { type: 'required', message: `Beskrivning är obligatoriskt` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user