diff --git a/src/app/sprint-form/sprint-form.component.ts b/src/app/sprint-form/sprint-form.component.ts index f19c1bb..2ec6c61 100644 --- a/src/app/sprint-form/sprint-form.component.ts +++ b/src/app/sprint-form/sprint-form.component.ts @@ -1,62 +1,60 @@ 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.editing = false; - } else { - this.editing = true; - } - document.getElementById('titleField').focus(); - } + 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.editing = false; + } else { + this.editing = true; + } + 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 d63239f..e9ccf30 100644 --- a/src/app/task-form/task-form.component.html +++ b/src/app/task-form/task-form.component.html @@ -7,7 +7,10 @@ - +