Backlog now actually does stuff, when you move userstorys

This commit is contained in:
Nicolai Ort 2020-07-07 11:39:45 +02:00
parent 971994aee0
commit f1ab3156e5
2 changed files with 28 additions and 49 deletions

View File

@ -36,7 +36,7 @@
<div class="col-lg-6 container-fluid"> <div class="col-lg-6 container-fluid">
<h4>Sprint-Backlog - y</h4> <h4>Sprint-Backlog - Aktueller Sprint: {{this.currentSprint.title}}</h4>
<div *ngFor="let story of choosen" class="col-lg-6 container-fluid"> <div *ngFor="let story of choosen" class="col-lg-6 container-fluid">
<div class="card" style="width: 150%;"> <div class="card" style="width: 150%;">
<div class="card-body"> <div class="card-body">

View File

@ -27,7 +27,7 @@ export class BacklogComponent extends TableComponentBase<
public filterPriority: string | null = null; public filterPriority: string | null = null;
public status: ScrumStatus[] = []; public status: ScrumStatus[] = [];
public categories: ScrumCategory[] = []; public categories: ScrumCategory[] = [];
public currentSprint: ScrumSprint; public sprints: ScrumSprint[] = [];
public backlog: ScrumUserstory[] = []; public backlog: ScrumUserstory[] = [];
public choosen: ScrumUserstory[] = []; public choosen: ScrumUserstory[] = [];
@ -38,13 +38,19 @@ export class BacklogComponent extends TableComponentBase<
private route: ActivatedRoute, private route: ActivatedRoute,
) { ) {
super(); super();
backendService.getSprints().subscribe((response) => {
if (response.status > 399) {
alert('Fehler');
} else {
this.sprints.push(...response.body);
}
});
backendService.getUserstories().subscribe((response) => { backendService.getUserstories().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} else { } else {
this.items.push(...response.body); this.backlog = response.body.filter(u => u.sprintid == null);
this.backlog = this.items; this.choosen = response.body.filter(u => u.sprintid == this.currentSprint.id);
} }
}); });
backendService.getTasks().subscribe((response) => { backendService.getTasks().subscribe((response) => {
@ -68,7 +74,6 @@ export class BacklogComponent extends TableComponentBase<
this.categories.push(...response.body); this.categories.push(...response.body);
} }
}); });
this.getCurrentSprint();
} }
public deleteUserstory(userstory: ScrumUserstory) { public deleteUserstory(userstory: ScrumUserstory) {
@ -101,38 +106,6 @@ export class BacklogComponent extends TableComponentBase<
return this.tasks.filter((t) => t.userstoryid === userstory.id).length; 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) { getCategoryTitleById(id) {
var category = this.categories.find((x) => x.id === id); var category = this.categories.find((x) => x.id === id);
if (!category) { if (!category) {
@ -147,23 +120,29 @@ export class BacklogComponent extends TableComponentBase<
this.choosen.push(userstory); this.choosen.push(userstory);
const index = this.backlog.indexOf(userstory); const index = this.backlog.indexOf(userstory);
this.backlog.splice(index, 1); 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); const index = this.choosen.indexOf(userstory);
this.choosen.splice(index, 1); 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() public get currentSprint(): ScrumSprint {
{
this.backendService.getSprints().subscribe((response) => {
if (response.status > 399) {
} else {
const now = Date.now(); const now = Date.now();
this.currentSprint = response.body.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now); return this.sprints.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now);
}});
} }
public openSprintForm(editSprint?: ScrumSprint) { public openSprintForm(editSprint?: ScrumSprint) {