Merge pull request 'feat(qualifikationsverwaltung): add error handling for delete skill' (#76) from fix/skill-deletion-logi into main
All checks were successful
Playwright Tests / test (push) Successful in 2m25s
All checks were successful
Playwright Tests / test (push) Successful in 2m25s
Reviewed-on: #76
This commit is contained in:
commit
fbec66debc
2 changed files with 29 additions and 11 deletions
|
@ -12,7 +12,8 @@
|
||||||
<h1>Qualifications</h1>
|
<h1>Qualifications</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="header-actions">
|
<div class="d-flex flex-column">
|
||||||
|
<div class="row header-actions">
|
||||||
<form [formGroup]="searchForm">
|
<form [formGroup]="searchForm">
|
||||||
<div class="search-bar">
|
<div class="search-bar">
|
||||||
<input type="text" placeholder="Search employee" formControlName="search">
|
<input type="text" placeholder="Search employee" formControlName="search">
|
||||||
|
@ -20,7 +21,16 @@
|
||||||
</div>
|
</div>
|
||||||
<p class="text-body-tertiary">Search for a propertiy of a Qualification. eg. Name</p>
|
<p class="text-body-tertiary">Search for a propertiy of a Qualification. eg. Name</p>
|
||||||
</form>
|
</form>
|
||||||
<button (click)="createSkill()" class="add-button">Add qualification</button>
|
<div class="d-flex">
|
||||||
|
<button (click)="createSkill()" class="add-button me-auto">Add qualification</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (errorDeletingSkill) {
|
||||||
|
<div class="row">
|
||||||
|
<p class="alert alert-danger">This Qualification can not be deleted because it still has employees.</p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="employee-table">
|
<table class="employee-table">
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { Router } from '@angular/router';
|
||||||
export class QualifikationsverwaltungComponent {
|
export class QualifikationsverwaltungComponent {
|
||||||
skills: Array<QualificationGetDTO> = [];
|
skills: Array<QualificationGetDTO> = [];
|
||||||
public searchForm!: FormGroup;
|
public searchForm!: FormGroup;
|
||||||
|
public errorDeletingSkill = false;
|
||||||
|
|
||||||
constructor(private skillService: SkillService, private router: Router) { }
|
constructor(private skillService: SkillService, private router: Router) { }
|
||||||
|
|
||||||
|
@ -44,8 +45,15 @@ export class QualifikationsverwaltungComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSkill(id: number) {
|
deleteSkill(id: number) {
|
||||||
|
this.skillService.getEmployeesBySkill(id).subscribe(employees => {
|
||||||
|
this.errorDeletingSkill = false;
|
||||||
|
if (employees.employees.length == 0) {
|
||||||
this.skillService.deleteSkill(id);
|
this.skillService.deleteSkill(id);
|
||||||
this.skills = this.skills.filter(skill => skill.id != id);
|
this.skills = this.skills.filter(skill => skill.id != id);
|
||||||
|
} else {
|
||||||
|
this.errorDeletingSkill = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
Loading…
Add table
Reference in a new issue