fix activities validation

This commit is contained in:
Daniel Appelgren
2021-11-12 14:17:33 +01:00
parent 71e145f082
commit 4c1f5b1942
4 changed files with 42 additions and 42 deletions

View File

@@ -14,8 +14,8 @@
[uiMaxLength]="2000" [uiMaxLength]="2000"
[uiMinLength]="1" [uiMinLength]="1"
[uiRequired]="true" [uiRequired]="true"
[uiValidationMessage]="activityFormGroup.get('description')?.errors?.required" [uiValidationMessage]="activityFormGroup.get('whatHasBeenDone')?.errors?.required"
[uiInvalid]="activityFormGroup.get('description')?.touched && !!activityFormGroup.get('description')?.errors?.required" [uiInvalid]="activityFormGroup.get('whatHasBeenDone')?.touched && !!activityFormGroup.get('whatHasBeenDone')?.errors?.required"
></ui-textarea> ></ui-textarea>
</div> </div>
<!-- TODO: If something is required at the top of the form it will be hard to see when at the bottom and clicking next --> <!-- TODO: If something is required at the top of the form it will be hard to see when at the bottom and clicking next -->

View File

@@ -31,11 +31,11 @@ export class SlutredovisningFormStep1Component implements OnInit {
private changeDetectionRef: ChangeDetectorRef private changeDetectionRef: ChangeDetectorRef
) {} ) {}
private clearActivities(): void { private _clearActivities(): void {
this.activitiesFormArray.clear(); this.activitiesFormArray.clear();
} }
private addActivityToForm(activity: Activity): void { private _addActivityToForm(activity: Activity): void {
this.activitiesFormArray.push( this.activitiesFormArray.push(
new FormGroup({ new FormGroup({
name: new FormControl(activity.name), name: new FormControl(activity.name),
@@ -54,8 +54,8 @@ export class SlutredovisningFormStep1Component implements OnInit {
.getAllChosenActivities(this.genomforandereferens) .getAllChosenActivities(this.genomforandereferens)
.pipe(take(1)) .pipe(take(1))
.subscribe(activities => { .subscribe(activities => {
this.clearActivities(); this._clearActivities();
activities.forEach(activity => this.addActivityToForm(activity)); activities.forEach(activity => this._addActivityToForm(activity));
}); });
} }
} }

View File

@@ -37,4 +37,4 @@
</footer> </footer>
</ng-template> </ng-template>
</div> </div>
<pre>{{slutredovisning$|async|json}}</pre> <!--<pre>{{slutredovisning$|async|json}}</pre>-->

View File

@@ -51,43 +51,43 @@
</ng-template> </ng-template>
</div> </div>
<h2>Step 0 valueChanges:</h2> <!-- <h2>Step 0 valueChanges:</h2>-->
<pre> <!-- <pre>-->
{{ step0FormGroup.valueChanges | async | json}} <!-- {{ step0FormGroup.valueChanges | async | json}}-->
</pre <!-- </pre-->
> <!-- >-->
<h2>Step 1 valueChanges:</h2> <!-- <h2>Step 1 valueChanges:</h2>-->
<pre> <!-- <pre>-->
{{ step1FormGroup.valueChanges | async | json}} <!-- {{ step1FormGroup.valueChanges | async | json}}-->
</pre <!-- </pre-->
> <!-- >-->
<h2>Step 2 valueChanges:</h2> <!-- <h2>Step 2 valueChanges:</h2>-->
<pre> <!-- <pre>-->
{{ step2FormGroup.valueChanges | async | json}} <!-- {{ step2FormGroup.valueChanges | async | json}}-->
</pre <!-- </pre-->
> <!-- >-->
<h2>Step 0 data:</h2> <!-- <h2>Step 0 data:</h2>-->
<pre> <!-- <pre>-->
{{step0FormData$ | async | json}} <!-- {{step0FormData$ | async | json}}-->
</pre <!-- </pre-->
> <!-- >-->
<h2>Step 1 data:</h2> <!-- <h2>Step 1 data:</h2>-->
<pre> <!-- <pre>-->
{{step1FormData$ | async | json}} <!-- {{step1FormData$ | async | json}}-->
</pre <!-- </pre-->
> <!-- >-->
<h2>Step 2 data:</h2> <!-- <h2>Step 2 data:</h2>-->
<pre> <!-- <pre>-->
{{step2FormData$ | async | json}} <!-- {{step2FormData$ | async | json}}-->
</pre <!-- </pre-->
> <!-- >-->
<h2>slutredovisningFormData$ data:</h2> <!-- <h2>slutredovisningFormData$ data:</h2>-->
<pre> <!-- <pre>-->
{{slutredovisningFormData$ | async | json}} <!-- {{slutredovisningFormData$ | async | json}}-->
</pre <!-- </pre-->
> <!-- >-->
</msfa-report-layout> </msfa-report-layout>
</msfa-layout> </msfa-layout>
<ng-template #skeletonRef> <ng-template #skeletonRef>