diff --git a/src/app/userstory-form/userstory-form.component.html b/src/app/userstory-form/userstory-form.component.html index 3475006..70f3d0b 100644 --- a/src/app/userstory-form/userstory-form.component.html +++ b/src/app/userstory-form/userstory-form.component.html @@ -7,17 +7,17 @@
- +
- +
- diff --git a/src/app/userstory-form/userstory-form.component.ts b/src/app/userstory-form/userstory-form.component.ts index 1e9857f..28f605f 100644 --- a/src/app/userstory-form/userstory-form.component.ts +++ b/src/app/userstory-form/userstory-form.component.ts @@ -9,29 +9,26 @@ import { BackendService, ScrumUserstory, Priority } from '../services/backend.se }) export class UserstoryFormComponent implements OnInit { - public title: string; - public content: string; - public prio: Priority; @Input() public userstory: ScrumUserstory; - private submitted: boolean; + private editing: boolean; constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { } ngOnInit(): void { - if (this.userstory !== null && this.userstory !== undefined) { - this.title = this.userstory.title; - this.content = this.userstory.content; - this.prio = this.userstory.priority; + if (this.userstory === null || this.userstory === undefined) { + this.userstory = {title: ""}; + this.editing = false; + } + else + { + this.editing = true; } } onSubmit() { - if (this.userstory !== null && this.userstory !== undefined) { - this.userstory.title = this.title; - this.userstory.content = this.content; - this.userstory.priority = this.prio; + if (this.editing) { this.backendService.putUserstory(this.userstory).subscribe(response => { if (response.status > 399) { alert('Fehler'); @@ -39,14 +36,12 @@ export class UserstoryFormComponent implements OnInit { }); } else { - this.userstory = { title: this.title, content: this.content, priority: this.prio }; this.backendService.postUserstory(this.userstory).subscribe(response => { if (response.status > 399) { alert('Fehler'); } }); } - this.submitted = true; this.activeModalService.close(this.userstory); } onClose(){