diff --git a/src/app/task-form/task-form.component.html b/src/app/task-form/task-form.component.html index c8782f8..b0a5f4e 100644 --- a/src/app/task-form/task-form.component.html +++ b/src/app/task-form/task-form.component.html @@ -17,7 +17,7 @@
- diff --git a/src/app/task-form/task-form.component.ts b/src/app/task-form/task-form.component.ts index 1660fbd..154e22f 100644 --- a/src/app/task-form/task-form.component.ts +++ b/src/app/task-form/task-form.component.ts @@ -11,17 +11,23 @@ export class TaskFormComponent implements OnInit { @Input() public task: ScrumTask; - private submitted: boolean; + public editing: Boolean; constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { } ngOnInit(): void { - if (this.task !== null && this.task !== undefined) { + if (this.task === null || this.task === undefined) { + this.task = {title: ""}; + this.editing = false; + } + else + { + this.editing = true; } } onSubmit() { - if (this.task !== null && this.task !== undefined) { + if (this.editing) { this.backendService.putTask(this.task).subscribe(response => { if (response.status > 399) { alert('Fehler'); @@ -29,14 +35,12 @@ export class TaskFormComponent implements OnInit { }); } else { - this.task = { title: this.title, content: this.content, priority: this.prio }; this.backendService.postTask(this.task).subscribe(response => { if (response.status > 399) { alert('Fehler'); } }); } - this.submitted = true; this.activeModalService.close(this.task); }