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/"
target="_blank"
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
>
</p>

View File

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

View File

@ -253,6 +253,7 @@ export class AddEditDeviceComponent implements OnInit {
}
saveEdit() {
if (this.projectInfo.valid) {
if (this.projectInfo.get("roomBuildingId").value) {
this.monitoringApiService
.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() {

View File

@ -138,7 +138,7 @@
<p
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>
<!-- <div class="card-body">
<a