From fd520be55efbc4f42f445c52d4bffca520c94aa2 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Wed, 5 May 2021 11:59:27 +0200
Subject: [PATCH] fix: workshop price to required and default value

---
 src/app/form/form.component.ts | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts
index 74de67430..d01cd1041 100644
--- a/src/app/form/form.component.ts
+++ b/src/app/form/form.component.ts
@@ -309,7 +309,7 @@ export class FormComponent implements OnInit {
         Validators.required,
         Validators.pattern(CustomRegExp.NO_NULL_NUMBER),
       ]),
-      freeWorkShop: new FormControl(structure.freeWorkShop),
+      freeWorkShop: new FormControl(structure.freeWorkShop, [Validators.required]),
     });
     return form;
   }
@@ -888,6 +888,9 @@ export class FormComponent implements OnInit {
   }
 
   public validateForm(): void {
+    if (this.getStructureControl('freeWorkShop').value === null) {
+      this.getStructureControl('freeWorkShop').setValue(false);
+    }
     if (this.structureForm.valid && this.hoursForm.valid) {
       let structure: Structure = this.structureForm.value;
       structure.hours = this.hoursForm.value;
-- 
GitLab