validasi device

This commit is contained in:
Fuzi_fauzia 2024-08-21 10:20:59 +07:00
parent f81dc7bf66
commit 04972e33b1
4 changed files with 67 additions and 49 deletions

View File

@ -13,7 +13,7 @@
href="https://allbestsistem.com/" href="https://allbestsistem.com/"
target="_blank" target="_blank"
style="background-color: #ffffff !important;" style="background-color: #ffffff !important;"
>Smart Building Management Systems (V@2024-08-20.2) >Smart Building Management Systems (V@2024-08-21.2)
</a></span </a></span
> >
</p> </p>

View File

@ -69,7 +69,7 @@
<div class="input-group"> <div class="input-group">
<select <select
id="categoryId" id="categoryId"
class="form-control" class="form-control custom-select"
formControlName="categoryId" formControlName="categoryId"
[ngClass]="{ [ngClass]="{
'is-invalid': submitted && f.categoryId.errors 'is-invalid': submitted && f.categoryId.errors
@ -83,15 +83,17 @@
</option> </option>
</select> </select>
</div> </div>
<small <div
class="form-text text-muted danger" *ngIf="
*ngIf="submitted && f.categoryId.errors" projectInfo.get('categoryId').invalid &&
class="invalid-feedback" projectInfo.get('categoryId').touched
"
class="text-danger"
>
<small class="text-danger"
>Category is required.</small
> >
<div *ngIf="f.categoryId.errors.required">
Category is required
</div> </div>
</small>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -116,15 +118,17 @@
</option> </option>
</select> </select>
</div> </div>
<small <div
class="form-text text-muted danger" *ngIf="
*ngIf="submitted && f.voltageId.errors" projectInfo.get('voltageId').invalid &&
class="invalid-feedback" projectInfo.get('voltageId').touched
"
class="text-danger"
>
<small class="text-danger"
>Voltage is required.</small
> >
<div *ngIf="f.voltageId.errors.required">
Voltage is required
</div> </div>
</small>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
@ -270,7 +274,7 @@
class="btn btn-primary" class="btn btn-primary"
style=" style="
color: #ffffff !important; color: #ffffff !important;
background-color: #37A647 !important; background-color: #37a647 !important;
" "
(click)="saveEdit()" (click)="saveEdit()"
*ngIf="mode === 'edit'" *ngIf="mode === 'edit'"

View File

@ -253,6 +253,7 @@ export class AddEditDeviceComponent implements OnInit {
} }
saveEdit() { saveEdit() {
if (this.projectInfo.valid) {
if (this.projectInfo.get("roomBuildingId").value) { if (this.projectInfo.get("roomBuildingId").value) {
this.monitoringApiService this.monitoringApiService
.putDevice(this.projectInfo.value, this.deviceId) .putDevice(this.projectInfo.value, this.deviceId)
@ -283,6 +284,19 @@ export class AddEditDeviceComponent implements OnInit {
} }
}); });
} }
} else {
this.markFormGroupTouched(this.projectInfo)
}
}
markFormGroupTouched(formGroup: FormGroup) {
(Object as any).values(formGroup.controls).forEach((control) => {
control.markAsTouched();
if (control.controls) {
this.markFormGroupTouched(control);
}
});
} }
cancel() { cancel() {

View File

@ -138,7 +138,7 @@
<p <p
class="card-subtitle line-on-side text-muted text-center font-small-3 mx-2 my-1" class="card-subtitle line-on-side text-muted text-center font-small-3 mx-2 my-1"
> >
<span>(v@2024.08.20.2)</span> <span>(v@2024.08.21.2)</span>
</p> </p>
<!-- <div class="card-body"> <!-- <div class="card-body">
<a <a