alert mandatory monitoring list

This commit is contained in:
Fuzi_fauzia 2024-08-20 16:04:45 +07:00
parent b195055651
commit 9529da581a
2 changed files with 13 additions and 9 deletions

View File

@ -68,15 +68,9 @@
<i class="feather ft-plus"> New Building</i> <i class="feather ft-plus"> New Building</i>
</button> </button>
</div> </div>
<small <div *ngIf="projectInfo.get('buildingId').touched && projectInfo.get('buildingId').invalid" class="text-danger">
class="form-text text-muted danger" Building is required.
*ngIf="submitted && f.buildingId.errors" </div>
class="invalid-feedback"
>
<div *ngIf="f.buildingId.errors.required">
Building is required
</div>
</small>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="floorId" style="color: #242222" <label for="floorId" style="color: #242222"

View File

@ -294,6 +294,7 @@ export class AddEditListComponent {
save() { save() {
if (this.mode === "add") { if (this.mode === "add") {
if (this.projectInfo.invalid) { if (this.projectInfo.invalid) {
this.markFormGroupTouched(this.projectInfo)
return; return;
} }
const formData = this.projectInfo.value; const formData = this.projectInfo.value;
@ -318,6 +319,15 @@ export class AddEditListComponent {
} }
} }
markFormGroupTouched(formGroup: FormGroup) {
(Object as any).values(formGroup.controls).forEach((control) => {
control.markAsTouched();
if (control.controls) {
this.markFormGroupTouched(control);
}
});
}
cancel() { cancel() {
this.router.navigate(["/list-monitoring"]); this.router.navigate(["/list-monitoring"]);
} }