fix bug where tables reload on action cancel
This commit is contained in:
parent
89bea09476
commit
ddb67fc40d
@ -56,6 +56,6 @@ export class CreateComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.employeeService.create(this.employeeForm.value as Employee).subscribe();
|
this.employeeService.create(this.employeeForm.value as Employee).subscribe();
|
||||||
this.dialogRef.close();
|
this.dialogRef.close(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,6 @@ export class DeleteComponent {
|
|||||||
deleteEmployee(id: number) {
|
deleteEmployee(id: number) {
|
||||||
this.apiService.deleteById(id).subscribe();
|
this.apiService.deleteById(id).subscribe();
|
||||||
|
|
||||||
this.dialogRef.close()
|
this.dialogRef.close(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,6 @@ export class EditComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.employeeService.update(this.employeeForm.value as Employee, this.employee.id).subscribe();
|
this.employeeService.update(this.employeeForm.value as Employee, this.employee.id).subscribe();
|
||||||
this.dialogRef.close();
|
this.dialogRef.close(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import {DetailsComponent} from "../details/details.component";
|
|||||||
templateUrl: './table.component.html',
|
templateUrl: './table.component.html',
|
||||||
styleUrl: './table.component.css'
|
styleUrl: './table.component.css'
|
||||||
})
|
})
|
||||||
export class TableComponent implements OnInit{
|
export class TableComponent implements OnInit {
|
||||||
private readonly apiService: EmployeeApiService = inject(EmployeeApiService);
|
private readonly apiService: EmployeeApiService = inject(EmployeeApiService);
|
||||||
private readonly snackBar: MatSnackBar = inject(MatSnackBar);
|
private readonly snackBar: MatSnackBar = inject(MatSnackBar);
|
||||||
private readonly matDialog: MatDialog = inject(MatDialog);
|
private readonly matDialog: MatDialog = inject(MatDialog);
|
||||||
@ -76,24 +76,30 @@ export class TableComponent implements OnInit{
|
|||||||
protected openDeleteDialogue(employee: Employee): void {
|
protected openDeleteDialogue(employee: Employee): void {
|
||||||
this.matDialog.open(DeleteComponent, {data: employee})
|
this.matDialog.open(DeleteComponent, {data: employee})
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe(() => {
|
.subscribe((deleted: boolean) => {
|
||||||
this.employees$ = this.fetchEmployees();
|
if (deleted) {
|
||||||
|
this.employees$ = this.fetchEmployees();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected showCreateEmployeeModal() {
|
protected showCreateEmployeeModal() {
|
||||||
this.matDialog.open(CreateComponent)
|
this.matDialog.open(CreateComponent)
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe(() => {
|
.subscribe((created: boolean) => {
|
||||||
this.employees$ = this.fetchEmployees();
|
if (created) {
|
||||||
});
|
this.employees$ = this.fetchEmployees();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected showEditEmployeeModal(employee: Employee) {
|
protected showEditEmployeeModal(employee: Employee) {
|
||||||
this.matDialog.open(EditComponent, {data: employee})
|
this.matDialog.open(EditComponent, {data: employee})
|
||||||
.afterClosed()
|
.afterClosed()
|
||||||
.subscribe(() => {
|
.subscribe((edited: boolean) => {
|
||||||
this.employees$ = this.fetchEmployees();
|
if (edited) {
|
||||||
|
this.employees$ = this.fetchEmployees();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user