refactor
This commit is contained in:
@@ -25,11 +25,12 @@ interface CheckboxModel {
|
||||
})
|
||||
export class SlutredovisningFormStep0StillUnemployedComponent implements OnInit {
|
||||
readonly formGroupKey: MainOccupation = MainOccupation.StillUnemployed;
|
||||
@Input() formGroupRef: FormGroup;
|
||||
|
||||
@Input() formData: SlutredovisningFormStep0StillUnemployedFormData;
|
||||
StillUnemployedReason = StillUnemployedReason;
|
||||
|
||||
@Input() formGroupRef: FormGroup;
|
||||
@Input() formData: SlutredovisningFormStep0StillUnemployedFormData;
|
||||
@Input() shouldValidate: boolean;
|
||||
|
||||
@Output() nextClick = new EventEmitter<SlutredovisningFormStep0StillUnemployedFormData>();
|
||||
@Output() backClick = new EventEmitter<void>();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { BehaviorSubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SlutredovisningFormData } from '../models/slutredovisning-form-data.model';
|
||||
import { SlutredovisningFormService } from '../slutredovisning-form.service';
|
||||
import { slutredovisningFormDataToSlutredovisningRequest } from '../utils/form-data-to-slutredovisning.util';
|
||||
import { slutredovisningFormDataToSlutredovisningRequest } from '../utils/forms-to-slutredovisning-form-data';
|
||||
|
||||
@Component({
|
||||
selector: 'msfa-slutredovisning-form-step3',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { ChangeDetectionStrategy, Component, OnDestroy } from '@angular/core';
|
||||
import { AbstractControl, FormGroup } from '@angular/forms';
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { DeltagareAvrop } from '@msfa-models/avrop.model';
|
||||
import { addDays } from 'date-fns';
|
||||
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { map, shareReplay, switchMap } from 'rxjs/operators';
|
||||
import { SlutredovisningFormData } from './models/slutredovisning-form-data.model';
|
||||
import { SlutredovisningStep0FormData } from './slutredovisning-form-step0/slutredovisning-form-step0.component';
|
||||
@@ -11,7 +11,7 @@ import { SlutredovisningStep1FormData } from './slutredovisning-form-step1/slutr
|
||||
import { SlutredovisningStep2FormData } from './slutredovisning-form-step2/slutredovisning-form-step2.component';
|
||||
import { SlutredovisningStep } from './slutredovisning-form.model';
|
||||
import { SlutredovisningFormService } from './slutredovisning-form.service';
|
||||
import { formsToSlutredovisningFormData } from './utils/form-data-to-slutredovisning.util';
|
||||
import { formsToSlutredovisningFormData } from './utils/forms-to-slutredovisning-form-data';
|
||||
|
||||
interface Params {
|
||||
genomforandeReferens: string;
|
||||
@@ -24,7 +24,7 @@ interface Params {
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
providers: [SlutredovisningFormService],
|
||||
})
|
||||
export class SlutredovisningFormComponent implements OnDestroy {
|
||||
export class SlutredovisningFormComponent {
|
||||
totalSteps = 4;
|
||||
currentStep$ = this.slutredovisningFormService.currentStep$;
|
||||
showAvropDetails$ = this.currentStep$.pipe(map(step => step === 'step0' || step === 'step3'));
|
||||
@@ -37,8 +37,6 @@ export class SlutredovisningFormComponent implements OnDestroy {
|
||||
step1FormData$: Observable<SlutredovisningStep1FormData> = this.slutredovisningFormService.step1FormData$;
|
||||
step2FormData$: Observable<SlutredovisningStep2FormData> = this.slutredovisningFormService.step2FormData$;
|
||||
|
||||
shouldValidate$ = new BehaviorSubject<boolean>(false);
|
||||
|
||||
genomforandeReferens$: Observable<number> = this.activatedRoute.params.pipe(
|
||||
map((params: Params) => +params.genomforandeReferens)
|
||||
);
|
||||
@@ -59,18 +57,8 @@ export class SlutredovisningFormComponent implements OnDestroy {
|
||||
shareReplay(1)
|
||||
);
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
constructor(private slutredovisningFormService: SlutredovisningFormService, private activatedRoute: ActivatedRoute) {}
|
||||
|
||||
formControlIsInvalid(formControl: AbstractControl): boolean {
|
||||
return formControl.invalid && (formControl.touched || this.shouldValidate$.value);
|
||||
}
|
||||
|
||||
openConfirmDialog(): void {
|
||||
this.shouldValidate$.next(true);
|
||||
}
|
||||
|
||||
private _isAfterEndDate(date: Date): boolean {
|
||||
return new Date() > date;
|
||||
}
|
||||
@@ -100,10 +88,6 @@ export class SlutredovisningFormComponent implements OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscriptions.forEach(subscription => subscription.unsubscribe());
|
||||
}
|
||||
|
||||
getStepIndex(step: SlutredovisningStep): number {
|
||||
switch (step) {
|
||||
case 'step0':
|
||||
|
||||
Reference in New Issue
Block a user