From 9b80777fc3518c31a02465532d10da6878a19d94 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 22 Jan 2025 09:03:52 +0100 Subject: [PATCH 1/2] feat: add qualification creation component and route --- src/app/app.routes.ts | 6 ++++ .../qualifikation-erstellen.component.css | 0 .../qualifikation-erstellen.component.html | 1 + .../qualifikation-erstellen.component.spec.ts | 23 +++++++++++++++ .../qualifikation-erstellen.component.ts | 29 +++++++++++++++++++ .../qualifikation-form.component.ts | 2 +- .../qualifikaton-bearbeiten-view.component.ts | 2 +- src/app/service/skill.service.ts | 4 +++ 8 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.css create mode 100644 src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.html create mode 100644 src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.spec.ts create mode 100644 src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 0300bf6..da54312 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -7,6 +7,7 @@ import { MitarbeiterBearbeitenViewComponent } from "./components/mitarbeiter-bea import { AuthGuard } from "./service/auth.service"; import { MitarbeiterErstellenComponent } from "./components/mitarbeiter-erstellen/mitarbeiter-erstellen.component"; import { QualifikationsverwaltungComponent } from "./components/qualifikationsverwaltung/qualifikationsverwaltung.component"; +import { QulifikationErstellenComponent } from "./components/qualifikation-erstellen/qualifikation-erstellen.component"; export const routes: Routes = [ { @@ -18,6 +19,11 @@ export const routes: Routes = [ component: MitarbeiterverwaltungViewComponent, canActivate: [AuthGuard], }, + { + path: "qualifikationerstellen", + component: QulifikationErstellenComponent, + canActivate: [AuthGuard], + }, { path: "mitarbeitererstellen", component: MitarbeiterErstellenComponent, diff --git a/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.css b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.html b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.html new file mode 100644 index 0000000..adfe33c --- /dev/null +++ b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.html @@ -0,0 +1 @@ + diff --git a/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.spec.ts b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.spec.ts new file mode 100644 index 0000000..a44fe02 --- /dev/null +++ b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { QulifikationErstellenComponent } from './qulifikation-erstellen.component'; + +describe('QulifikationErstellenComponent', () => { + let component: QulifikationErstellenComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [QulifikationErstellenComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(QulifikationErstellenComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts new file mode 100644 index 0000000..9445918 --- /dev/null +++ b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts @@ -0,0 +1,29 @@ +import { Component } from '@angular/core'; +import { QualifikationFormComponent } from '../qualifikation-form/qualifikation-form.component'; +import { QualificationGetDTO } from '../../models/skill'; +import { SkillService } from '../../service/skill.service'; + +@Component({ + selector: 'app-qulifikation-erstellen', + standalone: true, + imports: [QualifikationFormComponent], + templateUrl: './qulifikation-erstellen.component.html', + styleUrl: './qulifikation-erstellen.component.css' +}) +export class QulifikationErstellenComponent { + public skill!: QualificationGetDTO; + + constructor(private skillService: SkillService) { } + + submitted(skill: QualificationGetDTO) { + console.log(skill); + this.skillService.createSkill(skill); + } + + ngOnInit(): void { + this.skill = { + id: 0, + skill: '', + }; + } +} diff --git a/src/app/components/qualifikation-form/qualifikation-form.component.ts b/src/app/components/qualifikation-form/qualifikation-form.component.ts index 21ccf24..aad7492 100644 --- a/src/app/components/qualifikation-form/qualifikation-form.component.ts +++ b/src/app/components/qualifikation-form/qualifikation-form.component.ts @@ -115,7 +115,7 @@ export class QualifikationFormComponent { this.skill.skill = this.skillForm.get("name")?.value; this.skillChange.emit(this.skill); - this.router.navigate(["/qualifikationen"]); + this.router.navigate(["/qualifikationsverwaltung"]); } ngOnChanges(): void { diff --git a/src/app/components/qualifikaton-bearbeiten-view/qualifikaton-bearbeiten-view.component.ts b/src/app/components/qualifikaton-bearbeiten-view/qualifikaton-bearbeiten-view.component.ts index 791b8ec..b95a8eb 100644 --- a/src/app/components/qualifikaton-bearbeiten-view/qualifikaton-bearbeiten-view.component.ts +++ b/src/app/components/qualifikaton-bearbeiten-view/qualifikaton-bearbeiten-view.component.ts @@ -15,7 +15,7 @@ import { ActivatedRoute } from '@angular/router'; export class QualifikatonBearbeitenViewComponent { public skill!: QualificationGetDTO; - constructor(private skillService: SkillService, private route: ActivatedRoute) {} + constructor(private skillService: SkillService, private route: ActivatedRoute) { } submitted(skill: QualificationGetDTO) { this.skillService.updateSkill(skill); diff --git a/src/app/service/skill.service.ts b/src/app/service/skill.service.ts index 9e7f833..d0321a2 100644 --- a/src/app/service/skill.service.ts +++ b/src/app/service/skill.service.ts @@ -28,6 +28,10 @@ export class SkillService { } } + createSkill(skill: QualificationGetDTO) { + this.http.post(`${SkillService.BASE_URL}/qualifications`, this.getToPutDto(skill)).subscribe(); + } + constructor(private http: HttpClient, private employeeService: EmployeeService) { } From 471a67511739b68a0b922148dd75878849eedc95 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Wed, 22 Jan 2025 09:07:13 +0100 Subject: [PATCH 2/2] fix: correct selector and template URLs in component --- .../qualifikation-erstellen.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts index 9445918..f0f2cf9 100644 --- a/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts +++ b/src/app/components/qualifikation-erstellen/qualifikation-erstellen.component.ts @@ -7,8 +7,8 @@ import { SkillService } from '../../service/skill.service'; selector: 'app-qulifikation-erstellen', standalone: true, imports: [QualifikationFormComponent], - templateUrl: './qulifikation-erstellen.component.html', - styleUrl: './qulifikation-erstellen.component.css' + templateUrl: './qualifikation-erstellen.component.html', + styleUrl: './qualifikation-erstellen.component.css' }) export class QulifikationErstellenComponent { public skill!: QualificationGetDTO;