From ed1d31bdafc0a3a8a137989fc96ff98324820ff3 Mon Sep 17 00:00:00 2001 From: Niggl Date: Fri, 10 Jul 2020 16:56:32 +0200 Subject: [PATCH] Added sprint selection to backlog --- .../components/backlog/backlog.component.html | 33 +++++++++++++++---- .../components/backlog/backlog.component.ts | 32 +++++++++++------- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/app/components/backlog/backlog.component.html b/src/app/components/backlog/backlog.component.html index b0295e3..a61ca33 100644 --- a/src/app/components/backlog/backlog.component.html +++ b/src/app/components/backlog/backlog.component.html @@ -8,10 +8,34 @@
+ +
+

Backlog

+
+
+ +

Aktuell läuft kein Sprint. Zur Sprint Übersicht

+
+ +

Aktueller Sprint:

+

Sprint:

+ +
+
+
-

Backlog

@@ -32,12 +56,9 @@
-
-
- -

Sprint-Backlog - Aktueller Sprint: {{this.currentSprint.title}}

-
+
+

{{story.title}}

diff --git a/src/app/components/backlog/backlog.component.ts b/src/app/components/backlog/backlog.component.ts index f67c1fb..2c251f9 100644 --- a/src/app/components/backlog/backlog.component.ts +++ b/src/app/components/backlog/backlog.component.ts @@ -28,9 +28,9 @@ export class BacklogComponent extends TableComponentBase< public status: ScrumStatus[] = []; public categories: ScrumCategory[] = []; public sprints: ScrumSprint[] = []; + public storys: ScrumUserstory[] = []; - public backlog: ScrumUserstory[] = []; - public choosen: ScrumUserstory[] = []; + public selectedSprint: ScrumSprint; constructor( private backendService: BackendService, @@ -43,14 +43,14 @@ export class BacklogComponent extends TableComponentBase< alert('Fehler'); } else { this.sprints.push(...response.body); + this.selectedSprint = this.currentSprint; } }); backendService.getUserstories().subscribe((response) => { if (response.status > 399) { alert('Fehler'); } else { - this.backlog = response.body.filter(u => u.sprintid == null); - this.choosen = response.body.filter(u => u.sprintid == this.currentSprint.id); + this.storys.push(...response.body); } }); backendService.getTasks().subscribe((response) => { @@ -117,10 +117,7 @@ export class BacklogComponent extends TableComponentBase< // Sprint-Backlog public addToSprintBacklog(userstory: ScrumUserstory) { - this.choosen.push(userstory); - const index = this.backlog.indexOf(userstory); - this.backlog.splice(index, 1); - userstory.sprintid = this.currentSprint.id; + userstory.sprintid = this.selectedSprint.id; this.backendService.putUserstory(userstory).subscribe((response) => { if (response.status > 399) { alert('Fehler'); @@ -129,9 +126,6 @@ export class BacklogComponent extends TableComponentBase< } public deleteFromSprintBacklog(userstory: ScrumUserstory){ - const index = this.choosen.indexOf(userstory); - this.choosen.splice(index, 1); - this.backlog.push(userstory) userstory.sprintid = null; this.backendService.putUserstory(userstory).subscribe((response) => { if (response.status > 399) { @@ -140,11 +134,27 @@ export class BacklogComponent extends TableComponentBase< }); } + public get choosen(): ScrumUserstory[] + { + if(this.selectedSprint === undefined){return null;} + return this.storys.filter(u => u.sprintid == this.selectedSprint.id); + } + + public get backlog(): ScrumUserstory[] + { + return this.storys.filter(u => u.sprintid === undefined); + } + public get currentSprint(): ScrumSprint { const now = Date.now(); return this.sprints.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now); } + public toDateString(isoFormatString) { + const date = new Date(isoFormatString); + return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`; + } + public openSprintForm(editSprint?: ScrumSprint) { const modalRef = this.modalService.open(SprintFormComponent, { backdrop: 'static',