From f1ab3156e586c366b2089b9bec4e2ca853430588 Mon Sep 17 00:00:00 2001 From: Niggl Date: Tue, 7 Jul 2020 11:39:45 +0200 Subject: [PATCH] Backlog now actually does stuff, when you move userstorys --- src/app/backlog-table/backlog.component.html | 2 +- src/app/backlog-table/backlog.component.ts | 75 +++++++------------- 2 files changed, 28 insertions(+), 49 deletions(-) diff --git a/src/app/backlog-table/backlog.component.html b/src/app/backlog-table/backlog.component.html index 4abc9d8..f64ab58 100644 --- a/src/app/backlog-table/backlog.component.html +++ b/src/app/backlog-table/backlog.component.html @@ -36,7 +36,7 @@
-

Sprint-Backlog - y

+

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

diff --git a/src/app/backlog-table/backlog.component.ts b/src/app/backlog-table/backlog.component.ts index cb7fccc..a99e19a 100644 --- a/src/app/backlog-table/backlog.component.ts +++ b/src/app/backlog-table/backlog.component.ts @@ -27,7 +27,7 @@ export class BacklogComponent extends TableComponentBase< public filterPriority: string | null = null; public status: ScrumStatus[] = []; public categories: ScrumCategory[] = []; - public currentSprint: ScrumSprint; + public sprints: ScrumSprint[] = []; public backlog: ScrumUserstory[] = []; public choosen: ScrumUserstory[] = []; @@ -38,13 +38,19 @@ export class BacklogComponent extends TableComponentBase< private route: ActivatedRoute, ) { super(); - + backendService.getSprints().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.sprints.push(...response.body); + } + }); backendService.getUserstories().subscribe((response) => { if (response.status > 399) { alert('Fehler'); } else { - this.items.push(...response.body); - this.backlog = this.items; + this.backlog = response.body.filter(u => u.sprintid == null); + this.choosen = response.body.filter(u => u.sprintid == this.currentSprint.id); } }); backendService.getTasks().subscribe((response) => { @@ -68,7 +74,6 @@ export class BacklogComponent extends TableComponentBase< this.categories.push(...response.body); } }); - this.getCurrentSprint(); } public deleteUserstory(userstory: ScrumUserstory) { @@ -101,38 +106,6 @@ export class BacklogComponent extends TableComponentBase< return this.tasks.filter((t) => t.userstoryid === userstory.id).length; } - public sortById() { - this.doNumericSort('id', (us) => us.id); - } - - public sortByTitle() { - this.doStringSort('title', (us) => us.title); - } - - public sortByPrio() { - this.doNumericSort('priority', (us) => getNumberForPriority(us.priority)); - } - - public sortByTasks() { - this.doNumericSort('tasks', (us) => this.getNumberOfTasks(us)); - } - - sortByStatus() { - this.doNumericSort('statusid', (us) => us.statusid); - } - - sortByCategory() { - this.doNumericSort('categoryid', (us) => us.categoryid); - } - - getStatusTitleById(id) { - var status = this.status.find((x) => x.id === id); - if (!status) { - return 'N/A'; - } - return status.title; - } - getCategoryTitleById(id) { var category = this.categories.find((x) => x.id === id); if (!category) { @@ -147,23 +120,29 @@ export class BacklogComponent extends TableComponentBase< this.choosen.push(userstory); const index = this.backlog.indexOf(userstory); this.backlog.splice(index, 1); - + userstory.sprintid = this.currentSprint.id; + this.backendService.putUserstory(userstory).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); } - public deleteFromSprintBacklog(userstory: ScrumUserstory){ + public deleteFromSprintBacklog(userstory: ScrumUserstory){ const index = this.choosen.indexOf(userstory); this.choosen.splice(index, 1); - this.backlog.push(userstory); + this.backlog.push(userstory) + userstory.sprintid = null; + this.backendService.putUserstory(userstory).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); } - public getCurrentSprint() - { - this.backendService.getSprints().subscribe((response) => { - if (response.status > 399) { - } else { - const now = Date.now(); - this.currentSprint = response.body.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now); - }}); + public get currentSprint(): ScrumSprint { + const now = Date.now(); + return this.sprints.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now); } public openSprintForm(editSprint?: ScrumSprint) {