perbaikan master

This commit is contained in:
2024-07-02 22:45:07 +07:00
parent b2d8a8e2f6
commit b095f870dd
17 changed files with 166 additions and 57 deletions

View File

@@ -36,7 +36,7 @@ export class AddEditMasterBuildingComponent {
createForm() {
this.myForm = this.fb.group({
name: ["", Validators.required],
statusId: [0, Validators.required],
statusId: ["", Validators.required],
email: ["", [Validators.required, Validators.email]],
owner: ["", Validators.required],
address: ["", Validators.required],
@@ -48,13 +48,16 @@ export class AddEditMasterBuildingComponent {
editForm() {
this.myForm = this.fb.group({
id: this.dataRow.id,
name: this.dataRow.name,
statusId: this.dataRow.statusId,
name: [this.dataRow.name, Validators.required],
statusId: [this.dataRow.statusId, Validators.required],
email: [this.dataRow.email, [Validators.required, Validators.email]],
owner: this.dataRow.owner,
address: this.dataRow.address,
phone: [this.dataRow.phone, [Validators.required, Validators.pattern("^[0-9]*$")]],
kwh: this.dataRow.kwh,
owner: [this.dataRow.owner, Validators.required],
address: [this.dataRow.address, Validators.required],
phone: [
this.dataRow.phone,
[Validators.required, Validators.pattern("^[0-9]*$")],
],
kwh: [this.dataRow.kwh, Validators.required],
});
}
@@ -66,7 +69,7 @@ export class AddEditMasterBuildingComponent {
);
this.dataStatus = this.dataMasterStatus.headerDetailParam;
console.log(this.dataStatus);
this.filteredDataStatus = this.dataStatus.filter(
(item) => item.status === "2"
);
@@ -76,9 +79,20 @@ export class AddEditMasterBuildingComponent {
addRow() {
if (this.myForm.valid) {
this.activeModal.close(this.myForm.value);
} else {
this.markFormGroupTouched(this.myForm);
}
}
markFormGroupTouched(formGroup: FormGroup) {
(Object as any).values(formGroup.controls).forEach((control) => {
control.markAsTouched();
if (control.controls) {
this.markFormGroupTouched(control);
}
});
}
addDepartment() {
let newDept = prompt("Enter new department name:");
if (newDept) {