diff --git a/src/app/services/backend.service.ts b/src/app/services/backend.service.ts index ed9c838..3fa759e 100644 --- a/src/app/services/backend.service.ts +++ b/src/app/services/backend.service.ts @@ -235,7 +235,7 @@ export interface ScrumSprint{ description?: string; startDate: Date; endDate: Date; - project: number; + project?: number; } export interface ScrumCategory { diff --git a/src/app/sprint-form/sprint-form.component.ts b/src/app/sprint-form/sprint-form.component.ts index f19c1bb..b6360a2 100644 --- a/src/app/sprint-form/sprint-form.component.ts +++ b/src/app/sprint-form/sprint-form.component.ts @@ -1,37 +1,34 @@ import { Component, OnInit, Input } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { - BackendService, - ScrumTask, - Priority, - ScrumStatus, - ScrumCategory, - ScrumUser, - ScrumProject, - ScrumUserstory, - ScrumSprint + BackendService, + ScrumTask, + Priority, + ScrumStatus, + ScrumCategory, + ScrumUser, + ScrumProject, + ScrumUserstory, + ScrumSprint } from '../services/backend.service'; import { Observable } from 'rxjs'; import { HttpResponse } from '@angular/common/http'; @Component({ - selector: 'app-task-form', - templateUrl: './sprint-form.component.html', - styleUrls: ['./sprint-form.component.css'], + selector: 'app-task-form', + templateUrl: './sprint-form.component.html', + styleUrls: [ './sprint-form.component.css' ] }) export class SprintFormComponent implements OnInit { - @Input() public sprint: ScrumSprint; - public editing: Boolean; - public sprintid: string; + @Input() public sprint: ScrumSprint; + public editing: Boolean; + public sprintid: string; - constructor( - private backendService: BackendService, - private activeModalService: NgbActiveModal - ) { } + constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {} ngOnInit(): void { if (this.sprint === null || this.sprint === undefined) { - this.sprint = { title: '', startDate: new Date(), endDate: new Date(), project: 0 }; //project id: static counter? + this.sprint = { title: '', startDate: new Date(), endDate: new Date()}; //project id missing... this.editing = false; } else { this.editing = true; @@ -39,24 +36,25 @@ export class SprintFormComponent implements OnInit { document.getElementById('titleField').focus(); } - onSubmit() { - if (this.editing) { - this.backendService.putSprint(this.sprint).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } else { - this.backendService.postSprint(this.sprint).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } - this.activeModalService.close(this.sprint); - } + onSubmit() { + if (this.editing) { + this.backendService.putSprint(this.sprint).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } else { + this.backendService.postSprint(this.sprint).subscribe((response) => { + console.log('Sprint gespeichert!'); + if (response.status > 399) { + alert('Fehler'); + } + }); + } + this.activeModalService.close(this.sprint); + } - onClose() { - this.activeModalService.dismiss(this.sprint); - } + onClose() { + this.activeModalService.dismiss(this.sprint); + } } diff --git a/src/app/task-form/task-form.component.html b/src/app/task-form/task-form.component.html index 5aa9229..e68ee8d 100644 --- a/src/app/task-form/task-form.component.html +++ b/src/app/task-form/task-form.component.html @@ -7,7 +7,10 @@