From 16a9aef3c53d0c335af145d2f4569e0886b2e750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20K=C3=BCck?= Date: Tue, 21 Jan 2025 12:47:43 +0100 Subject: [PATCH] Fix: Delete Qualification --- .../qualifications.component.ts | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/app/views/qualifications/qualifications.component.ts b/src/app/views/qualifications/qualifications.component.ts index 0de8985..b6d047b 100644 --- a/src/app/views/qualifications/qualifications.component.ts +++ b/src/app/views/qualifications/qualifications.component.ts @@ -138,6 +138,10 @@ export class QualificationsComponent { return; } this.qualificationService.getAllQualificationEmployees({id: qualification.id}).subscribe((employees: QualificationEmployees) => { + if (employees.employees.length==0){ + this.execDelete(qualification); + return; + } const requests: Array> = []; for (const employee of employees.employees) { requests.push(this.employeeService.removeQualificationFromEmployee({ @@ -152,17 +156,20 @@ export class QualificationsComponent { return; } } - this.qualificationService.deleteQualification({id: qualification.id}).subscribe(() => { - const data = this.qualificationDataSource.data; - const i = data.indexOf(qualification); - if (i != -1) { - data.splice(i, 1); - this.qualificationDataSource.data = data; - } - this.notifications.publish(`Deleted ${qualification.skill}`, NotificationType.Information); - }); + this.execDelete(qualification); }); }); }); } + execDelete(qualification: Qualification){ + this.qualificationService.deleteQualification({id: qualification.id}).subscribe(() => { + const data = this.qualificationDataSource.data; + const i = data.indexOf(qualification); + if (i != -1) { + data.splice(i, 1); + this.qualificationDataSource.data = data; + } + this.notifications.publish(`Deleted ${qualification.skill}`, NotificationType.Information); + }); + } }