From 17b1872ebdfba47926a8613b016a767653d73fff Mon Sep 17 00:00:00 2001 From: Niggl Date: Wed, 10 Jun 2020 11:09:10 +0200 Subject: [PATCH] Add basic userstory components nr. 2 --- .../userstory-form.component.css | 0 .../userstory-form.component.html | 25 +++++++++ .../userstory-form.component.ts | 52 +++++++++++++++++++ .../userstory-list.component.html | 14 +++++ .../userstory-list.component.ts | 1 + 5 files changed, 92 insertions(+) create mode 100644 src/app/userstory-form/userstory-form.component.css create mode 100644 src/app/userstory-form/userstory-form.component.html create mode 100644 src/app/userstory-form/userstory-form.component.ts diff --git a/src/app/userstory-form/userstory-form.component.css b/src/app/userstory-form/userstory-form.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/userstory-form/userstory-form.component.html b/src/app/userstory-form/userstory-form.component.html new file mode 100644 index 0000000..edb588c --- /dev/null +++ b/src/app/userstory-form/userstory-form.component.html @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/src/app/userstory-form/userstory-form.component.ts b/src/app/userstory-form/userstory-form.component.ts new file mode 100644 index 0000000..020f199 --- /dev/null +++ b/src/app/userstory-form/userstory-form.component.ts @@ -0,0 +1,52 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { BackendService, ScrumUserstory, Priority } from '../services/backend.service'; + +@Component({ + selector: 'app-userstory-form', + templateUrl: './userstory-form.component.html', + styleUrls: ['./userstory-form.component.css'] +}) +export class UserstoryFormComponent implements OnInit { + + public title: string; + public content: string; + public prio: Priority; + + @Input() + public userstory: ScrumUserstory; + private submitted: 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; + } + } + + onSubmit() { + if (this.userstory !== null && this.userstory !== undefined) { + this.userstory.title = this.title; + this.userstory.content = this.content; + this.userstory.priority = this.prio; + this.backendService.putUserstory(this.userstory).subscribe(response => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + 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(); + } +} diff --git a/src/app/userstory-list/userstory-list.component.html b/src/app/userstory-list/userstory-list.component.html index e69de29..c8c9bb6 100644 --- a/src/app/userstory-list/userstory-list.component.html +++ b/src/app/userstory-list/userstory-list.component.html @@ -0,0 +1,14 @@ + + + diff --git a/src/app/userstory-list/userstory-list.component.ts b/src/app/userstory-list/userstory-list.component.ts index 0942175..154fbcf 100644 --- a/src/app/userstory-list/userstory-list.component.ts +++ b/src/app/userstory-list/userstory-list.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { BackendService, ScrumUserstory } from '../services/backend.service'; +import { UserstoryFormComponent } from '../userstory-form/userstory-form.component'; @Component({ selector: 'app-userstory-list',