stop page reload after employee deletion (#25)
Reviewed-on: #25 Reviewed-by: Get in my car i have candy <huydw@proton.me> Co-authored-by: Constantin Simonis <constantin@simonis.lol> Co-committed-by: Constantin Simonis <constantin@simonis.lol>
This commit is contained in:
parent
0782095970
commit
5829876444
@ -4,7 +4,7 @@ import {
|
|||||||
MAT_DIALOG_DATA,
|
MAT_DIALOG_DATA,
|
||||||
MatDialogActions,
|
MatDialogActions,
|
||||||
MatDialogClose,
|
MatDialogClose,
|
||||||
MatDialogContent,
|
MatDialogContent, MatDialogRef,
|
||||||
MatDialogTitle
|
MatDialogTitle
|
||||||
} from "@angular/material/dialog";
|
} from "@angular/material/dialog";
|
||||||
import {MatButton} from "@angular/material/button";
|
import {MatButton} from "@angular/material/button";
|
||||||
@ -25,12 +25,12 @@ import EmployeeApiService from "../../services/employee-api.service";
|
|||||||
})
|
})
|
||||||
export class DeleteComponent {
|
export class DeleteComponent {
|
||||||
private apiService: EmployeeApiService = inject(EmployeeApiService);
|
private apiService: EmployeeApiService = inject(EmployeeApiService);
|
||||||
|
private dialogRef: MatDialogRef<DeleteComponent> = inject(MatDialogRef);
|
||||||
protected employee: Employee = inject(MAT_DIALOG_DATA);
|
protected employee: Employee = inject(MAT_DIALOG_DATA);
|
||||||
|
|
||||||
deleteEmployee(id: number) {
|
deleteEmployee(id: number) {
|
||||||
this.apiService.deleteById(id).subscribe();
|
this.apiService.deleteById(id).subscribe();
|
||||||
|
|
||||||
location.reload();
|
this.dialogRef.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,11 @@ export class TableComponent implements OnInit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected openDeleteDialogue(employee: Employee): void {
|
protected openDeleteDialogue(employee: Employee): void {
|
||||||
this.deleteDialogue.open(DeleteComponent, {data: employee});
|
this.deleteDialogue.open(DeleteComponent, {data: employee})
|
||||||
|
.afterClosed()
|
||||||
|
.subscribe(() => {
|
||||||
|
this.employees$ = this.fetchEmployees();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected showCreateEmployeeModal() {
|
protected showCreateEmployeeModal() {
|
||||||
|
Reference in New Issue
Block a user