Fix employeedetails opened from qualification details not showing any skills

This commit is contained in:
Phan Huy Tran 2025-01-15 09:28:45 +01:00 committed by Constantin Simonis
parent 8284e1634d
commit a62b7e7d37
3 changed files with 34 additions and 13 deletions

View File

@ -1,20 +1,22 @@
<h2 mat-dialog-title class="text-xl font-semibold mb-4"> <h2 mat-dialog-title class="text-xl font-semibold mb-4">
Employees with {{ qualification.skill }} {{ qualification.skill }} Developers
</h2> </h2>
<mat-dialog-content> <mat-dialog-content class="px-1">
@if (employees$ | async; as employees) { @if (employees$ | async; as employees) {
@if (employees.length === 0) { @if (employees.length === 0) {
<p class="text-gray-500 italic">No employees found with this qualification.</p> <p class="text-gray-500 italic">No employees found with this qualification.</p>
} @else { } @else {
@for (employee of employees; track employee.id) { <div class="space-y-1">
<a @for (employee of employees; track employee.id) {
class="flex items-center p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors" <a
(click)="openEmployeeDetailsModal(employee)" class="block w-full px-4 py-2 text-blue-600 rounded-lg hover:bg-blue-50 transition-colors cursor-pointer"
> (click)="openEmployeeDetailsModal(employee.id)"
<span class="font-medium">{{ employee.firstName }} {{ employee.lastName }}</span> >
</a> <span class="font-medium">{{ employee.firstName }} {{ employee.lastName }}</span>
} </a>
}
</div>
} }
} }
</mat-dialog-content> </mat-dialog-content>

View File

@ -12,6 +12,14 @@ import {AsyncPipe} from "@angular/common";
import {MatButton} from "@angular/material/button"; import {MatButton} from "@angular/material/button";
import {Employee} from "../../employee/Employee"; import {Employee} from "../../employee/Employee";
import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/details/details.component"; import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/details/details.component";
import EmployeeApiService from "../../services/employee-api.service";
interface QualificationEmployee {
id: number;
lastName: string;
firstName: string;
}
@Component({ @Component({
selector: 'app-details', selector: 'app-details',
@ -27,6 +35,7 @@ import {DetailsComponent as EmployeeDetailsComponent} from "../../employee/detai
}) })
export class DetailsComponent { export class DetailsComponent {
private qualificationService = inject(QualificationService); private qualificationService = inject(QualificationService);
private employeeService = inject(EmployeeApiService);
private dialogRef: MatDialogRef<DetailsComponent> = inject(MatDialogRef); private dialogRef: MatDialogRef<DetailsComponent> = inject(MatDialogRef);
private dialog: MatDialog = inject(MatDialog); private dialog: MatDialog = inject(MatDialog);
@ -37,9 +46,15 @@ export class DetailsComponent {
this.dialogRef.close(); this.dialogRef.close();
} }
openEmployeeDetailsModal(employee: Employee) { openEmployeeDetailsModal(id: number | undefined) {
this.dialog.open(EmployeeDetailsComponent, { if (!id) {
data: employee throw new Error("ID must not be undefined");
}
this.employeeService.getById(id).subscribe(employee => {
this.dialog.open(EmployeeDetailsComponent, {
data: employee
});
}); });
} }
} }

View File

@ -12,6 +12,10 @@ export default class EmployeeApiService {
private static readonly BASE_URL = 'http://localhost:8089'; private static readonly BASE_URL = 'http://localhost:8089';
public getById(id: number): Observable<Employee> {
return this.http.get(`${EmployeeApiService.BASE_URL}/employees/${id}`)
}
public deleteById(id: number): Observable<Employee> { public deleteById(id: number): Observable<Employee> {
return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`) return this.http.delete(`${EmployeeApiService.BASE_URL}/employees/${id}`)
} }