Fix: Delete Qualification
All checks were successful
Quality Check / Linting (push) Successful in 25s
Quality Check / Linting (pull_request) Successful in 25s

This commit is contained in:
Ole Kück 2025-01-21 12:47:43 +01:00
parent 76541fa2a8
commit 16a9aef3c5
Signed by: SZUT-Ole
GPG key ID: 0A1DF1B37C4A1E4C

View file

@ -138,6 +138,10 @@ export class QualificationsComponent {
return; return;
} }
this.qualificationService.getAllQualificationEmployees({id: qualification.id}).subscribe((employees: QualificationEmployees) => { this.qualificationService.getAllQualificationEmployees({id: qualification.id}).subscribe((employees: QualificationEmployees) => {
if (employees.employees.length==0){
this.execDelete(qualification);
return;
}
const requests: Array<Observable<RemoveQualificationFromEmployeeResponse>> = []; const requests: Array<Observable<RemoveQualificationFromEmployeeResponse>> = [];
for (const employee of employees.employees) { for (const employee of employees.employees) {
requests.push(this.employeeService.removeQualificationFromEmployee({ requests.push(this.employeeService.removeQualificationFromEmployee({
@ -152,17 +156,20 @@ export class QualificationsComponent {
return; return;
} }
} }
this.qualificationService.deleteQualification({id: qualification.id}).subscribe(() => { this.execDelete(qualification);
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);
});
}); });
}); });
}); });
} }
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);
});
}
} }