Add basic userstory components nr. 2

This commit is contained in:
Nicolai Ort 2020-06-10 11:09:10 +02:00
parent 5179256435
commit 17b1872ebd
5 changed files with 92 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<div class="modal-content p-3">
<form (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="Title">Titel</label>
<input type="text" class="form-control" id="Title" required name="title" [(ngModel)]="title">
</div>
<div class="form-group">
<label for="Inhalt">Inhalt</label>
<input type="text" class="form-control" id="Content" required name="content" [(ngModel)]="content">
</div>
<div class="form-group">
<label for="Prio">Prio</label>
<select class="form-control" id="prio" required name="prio" [(ngModel)]="prio">
<option value="low">Low</option>
<option value="medium">Medium</option>
<option value="high">High</option>
</select>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div>

View File

@ -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();
}
}

View File

@ -0,0 +1,14 @@
<button class="btn btn-dark m-3" (click)="openUserstoryForm(null)">Neu</button>
<ul class="list-group m-3">
<li *ngFor="let userstory of userstories" class="list-group-item">
<span>Titel: {{userstory.title}}</span>
<br/>
<span>Inhalt: {{userstory.content}}</span>
<br/>
<span>Priotität: {{userstory.priority}}</span>
<br>
<button class="btn btn-secondary m-2" (click)="openUserstoryForm(userstory)">Bearbeiten</button>
<button class="btn btn-secondary m-2" (click)="deleteUserstory(userstory)">Löschen</button>
</li>
</ul>

View File

@ -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',