Typo fixes for required fields
This commit is contained in:
@@ -14,7 +14,7 @@ import { BehaviorSubject, Observable } from 'rxjs';
|
|||||||
})
|
})
|
||||||
export class EmployeeInviteComponent {
|
export class EmployeeInviteComponent {
|
||||||
formGroup: FormGroup = new FormGroup({
|
formGroup: FormGroup = new FormGroup({
|
||||||
emails: new FormControl('', [RequiredValidator('E-postadresser'), CommaSeparatedEmailValidator()]),
|
emails: new FormControl('', [RequiredValidator(), CommaSeparatedEmailValidator()]),
|
||||||
});
|
});
|
||||||
private _lastInvites$ = new BehaviorSubject<EmployeeInviteResponse>(null);
|
private _lastInvites$ = new BehaviorSubject<EmployeeInviteResponse>(null);
|
||||||
lastInvites$: Observable<EmployeeInviteResponse> = this._lastInvites$.asObservable();
|
lastInvites$: Observable<EmployeeInviteResponse> = this._lastInvites$.asObservable();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class DeltagareTabReportsComponent {
|
|||||||
|
|
||||||
readonly reportsFormControlName = 'reports';
|
readonly reportsFormControlName = 'reports';
|
||||||
reportPickerFormGroup: FormGroup = this.formBuilder.group({
|
reportPickerFormGroup: FormGroup = this.formBuilder.group({
|
||||||
reports: this.formBuilder.control('', [RequiredValidator('Rapporttyp')]),
|
reports: this.formBuilder.control('', [RequiredValidator('Rapporttyp är obligatoriskt')]),
|
||||||
});
|
});
|
||||||
|
|
||||||
selectableReportTypes: Array<FormSelectItem> = [
|
selectableReportTypes: Array<FormSelectItem> = [
|
||||||
@@ -27,7 +27,7 @@ export class DeltagareTabReportsComponent {
|
|||||||
// { name: 'Signal om arbete eller studier', value: 'signal' },
|
// { name: 'Signal om arbete eller studier', value: 'signal' },
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(private formBuilder: FormBuilder, private router: Router) { }
|
constructor(private formBuilder: FormBuilder, private router: Router) {}
|
||||||
|
|
||||||
get reportsFormControl(): AbstractControl | null {
|
get reportsFormControl(): AbstractControl | null {
|
||||||
return this.reportPickerFormGroup?.get(this.reportsFormControlName);
|
return this.reportPickerFormGroup?.get(this.reportsFormControlName);
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
|
import { FormSelectItem } from '@af/digi-ng/_form/form-select';
|
||||||
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { Avrop } from '@msfa-models/avrop.model';
|
||||||
import { AvvikelseAlternativ, AvvikelseRequestData } from '@msfa-models/avvikelse.model';
|
import { AvvikelseAlternativ, AvvikelseRequestData } from '@msfa-models/avvikelse.model';
|
||||||
|
import { CustomError } from '@msfa-models/error/custom-error';
|
||||||
|
import { FragorForAvvikelser } from '@msfa-models/fragor-for-avvikelser.model';
|
||||||
|
import { OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model';
|
||||||
import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service';
|
import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service';
|
||||||
|
import { RequiredValidator } from '@msfa-validators/required.validator';
|
||||||
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
|
||||||
import { map, shareReplay, switchMap, take } from 'rxjs/operators';
|
import { map, shareReplay, switchMap, take } from 'rxjs/operators';
|
||||||
import { DeltagareAvvikelserapportService } from './deltagare-avvikelserapport.service';
|
import { DeltagareAvvikelserapportService } from './deltagare-avvikelserapport.service';
|
||||||
import { Avrop } from '@msfa-models/avrop.model';
|
|
||||||
import { FragorForAvvikelser } from '@msfa-models/fragor-for-avvikelser.model';
|
|
||||||
import { RequiredValidator } from '@msfa-validators/required.validator';
|
|
||||||
import { FormSelectItem } from '@af/digi-ng/_form/form-select';
|
|
||||||
import { OrsaksKoderAvvikelse } from '@msfa-models/orsaks-koder-avvikelse.model';
|
|
||||||
import { CustomError } from '@msfa-models/error/custom-error';
|
|
||||||
|
|
||||||
interface Params {
|
interface Params {
|
||||||
genomforandeReferens: string;
|
genomforandeReferens: string;
|
||||||
@@ -63,8 +63,8 @@ export class DeltagareAvvikelserapportComponent implements OnInit, OnDestroy {
|
|||||||
private subscriptions: Subscription[] = [];
|
private subscriptions: Subscription[] = [];
|
||||||
private todayDateISO = new Date().toISOString().slice(0, 10);
|
private todayDateISO = new Date().toISOString().slice(0, 10);
|
||||||
avvikelseFormGroup = new FormGroup({
|
avvikelseFormGroup = new FormGroup({
|
||||||
[this.reasonFormName]: new FormControl(null, RequiredValidator('En orsak')), //[this.orsakFormControlName]:
|
[this.reasonFormName]: new FormControl(null, RequiredValidator('Orsak är obligatorisk')),
|
||||||
[this.reportingDateFormName]: new FormControl(this.todayDateISO, RequiredValidator('Datum')),
|
[this.reportingDateFormName]: new FormControl(this.todayDateISO, RequiredValidator('Datum är obligatoriskt')),
|
||||||
[this.questionsFormName]: new FormArray([]),
|
[this.questionsFormName]: new FormArray([]),
|
||||||
});
|
});
|
||||||
private formData$: Observable<AvvikelseFormData> = this.avvikelseFormGroup
|
private formData$: Observable<AvvikelseFormData> = this.avvikelseFormGroup
|
||||||
@@ -199,7 +199,7 @@ export class DeltagareAvvikelserapportComponent implements OnInit, OnDestroy {
|
|||||||
this.currentQuestions.push(question);
|
this.currentQuestions.push(question);
|
||||||
|
|
||||||
this.questionsFormArray.push(
|
this.questionsFormArray.push(
|
||||||
new FormControl('', this.questionIsRequired(question) ? RequiredValidator('Frågan') : null)
|
new FormControl('', this.questionIsRequired(question) ? RequiredValidator('Frågan är obligatorisk') : null)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ export class DeltagarePeriodiskRedovisningComponent {
|
|||||||
|
|
||||||
initializePeriodiskRedovisningFormGroup(activitiesList: Activity[]): void {
|
initializePeriodiskRedovisningFormGroup(activitiesList: Activity[]): void {
|
||||||
this.periodiskRedovisningFormGroup = new FormGroup({
|
this.periodiskRedovisningFormGroup = new FormGroup({
|
||||||
lamnatJobbForslag: new FormControl(null, [RequiredValidator('lamnatJobbForslag')]),
|
lamnatJobbForslag: new FormControl(null, [RequiredValidator('lamnatJobbForslag är obligatoriskt')]),
|
||||||
providedSprakStod: new FormControl(null, [RequiredValidator('providedSprakStod')]),
|
providedSprakStod: new FormControl(null, [RequiredValidator('providedSprakStod är obligatoriskt')]),
|
||||||
activities: new FormArray([]),
|
activities: new FormArray([]),
|
||||||
});
|
});
|
||||||
this.getActivitesFormArray(activitiesList);
|
this.getActivitesFormArray(activitiesList);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class HandledarePickerFormComponent implements OnChanges {
|
|||||||
@Input() invalid = false;
|
@Input() invalid = false;
|
||||||
@Output() selectedHandledareChanged = new EventEmitter<string>();
|
@Output() selectedHandledareChanged = new EventEmitter<string>();
|
||||||
formGroup: FormGroup = new FormGroup({
|
formGroup: FormGroup = new FormGroup({
|
||||||
handledare: new FormControl(null, [RequiredValidator('Handledare')]),
|
handledare: new FormControl(null, [RequiredValidator('Handledare är obligatorisk')]),
|
||||||
});
|
});
|
||||||
selectableHandledare: FormSelectItem[] = [];
|
selectableHandledare: FormSelectItem[] = [];
|
||||||
submitted = false;
|
submitted = false;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class OrganizationPickerFormComponent implements OnChanges {
|
|||||||
@Output() selectedOrganizationChanged = new EventEmitter<Organization>();
|
@Output() selectedOrganizationChanged = new EventEmitter<Organization>();
|
||||||
|
|
||||||
organizationPickerFormGroup: FormGroup = new FormGroup({
|
organizationPickerFormGroup: FormGroup = new FormGroup({
|
||||||
organization: new FormControl(null, [RequiredValidator('Organisation')]),
|
organization: new FormControl(null, [RequiredValidator('Organisation är obligatorisk')]),
|
||||||
});
|
});
|
||||||
selectableOrganizations: Array<FormSelectItem> = [];
|
selectableOrganizations: Array<FormSelectItem> = [];
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,11 @@
|
|||||||
import { AbstractControl, ValidatorFn } from '@angular/forms';
|
import { AbstractControl, ValidatorFn } from '@angular/forms';
|
||||||
import { ValidationError } from '@msfa-models/validation-error.model';
|
import { ValidationError } from '@msfa-models/validation-error.model';
|
||||||
|
|
||||||
export function RequiredValidator(label = 'Fältet', arrayValue = false): ValidatorFn {
|
export function RequiredValidator(message = 'Fältet är obligatoriskt'): ValidatorFn {
|
||||||
return (control: AbstractControl): ValidationError => {
|
return (control: AbstractControl): ValidationError => {
|
||||||
if (control) {
|
if (control) {
|
||||||
if ((arrayValue && !control.value) || (Array.isArray(control.value) && !control.value.length)) {
|
if (!control.value || (Array.isArray(control.value) && !control.value.length)) {
|
||||||
return { type: 'required', message: `Minst ${label} behöver väljas` };
|
return { type: 'required', message };
|
||||||
}
|
|
||||||
|
|
||||||
if (!control.value) {
|
|
||||||
return { type: 'required', message: `${label} är obligatoriskt` };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user