Merge pull request 'feature/addQualifications' (#23) from feature/addQualifications into trunk
All checks were successful
Quality Check / Linting (push) Successful in 25s

Reviewed-on: #23
This commit is contained in:
SZUT-Ole 2025-01-21 11:54:54 +00:00 committed by Euph Forge
commit a87d420f6d
Signed by: Euph Forge
GPG key ID: 85A06461FB6BDBB7
2 changed files with 28 additions and 11 deletions

View file

@ -2,9 +2,9 @@
<div class="qualifications__action-row">
<mat-form-field>
<mat-label>Qualification</mat-label>
<input matInput>
<input matInput #qualificationInput minlength="1" maxlength="25">
</mat-form-field>
<button mat-fab class="shadowless">
<button mat-fab class="shadowless" (click)="onAdd(qualificationInput)">
<mat-icon>add</mat-icon>
</button>
</div>

View file

@ -79,6 +79,16 @@ export class QualificationsComponent {
this.qualificationEdits.set(id, true);
}
onAdd(qualificationField: HTMLInputElement){
this.qualificationService.createQualification({requestBody: {skill: qualificationField.value}}).subscribe((qualification)=>{
const data = this.qualificationDataSource.data;
data.push(qualification);
this.qualificationDataSource = new MatTableDataSource<Qualification>(data);
this.notifications.publish(`Added ${qualification.skill}`);
qualificationField.value='';
});
}
endEdit(oldQualification: Qualification, save: boolean) {
const qualificationFormGroup = this.qualificationSkillFormGroups.get(oldQualification.id);
@ -128,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<Observable<RemoveQualificationFromEmployeeResponse>> = [];
for (const employee of employees.employees) {
requests.push(this.employeeService.removeQualificationFromEmployee({
@ -142,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);
});
}
}