Added comments and cleaned stuff up
This commit is contained in:
parent
33b24cd746
commit
13fda66525
|
@ -1,17 +1,12 @@
|
|||
import { Component } from '@angular/core';
|
||||
import {
|
||||
BackendService,
|
||||
ScrumTask,
|
||||
ScrumUserstory,
|
||||
ScrumStatus,
|
||||
ScrumCategory,
|
||||
ScrumSprint,
|
||||
} from '../../services/backend.service';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TableComponentBase } from '../../services/table-component.base';
|
||||
import { getNumberForPriority } from '../../services/sorting.service';
|
||||
import { UserstoryFormComponent } from '../userstory-form/userstory-form.component';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { SprintFormComponent } from '../sprint-form/sprint-form.component';
|
||||
|
||||
|
||||
|
@ -20,24 +15,24 @@ import { SprintFormComponent } from '../sprint-form/sprint-form.component';
|
|||
templateUrl: './backlog.component.html',
|
||||
styleUrls: ['./backlog.component.css'],
|
||||
})
|
||||
export class BacklogComponent extends TableComponentBase<
|
||||
ScrumUserstory
|
||||
> {
|
||||
public tasks: ScrumTask[] = [];
|
||||
public filterPriority: string | null = null;
|
||||
|
||||
|
||||
export class BacklogComponent{
|
||||
public status: ScrumStatus[] = [];
|
||||
public categories: ScrumCategory[] = [];
|
||||
public sprints: ScrumSprint[] = [];
|
||||
public storys: ScrumUserstory[] = [];
|
||||
|
||||
public selectedSprint: ScrumSprint;
|
||||
|
||||
/**
|
||||
* Constructor of the class that initialized the communication with the backend
|
||||
* @param backendService
|
||||
* @param modalService
|
||||
*/
|
||||
constructor(
|
||||
private backendService: BackendService,
|
||||
private modalService: NgbModal,
|
||||
private route: ActivatedRoute,
|
||||
) {
|
||||
super();
|
||||
backendService.getSprints().subscribe((response) => {
|
||||
if (response.status > 399) {
|
||||
alert('Fehler');
|
||||
|
@ -53,13 +48,6 @@ export class BacklogComponent extends TableComponentBase<
|
|||
this.storys.push(...response.body);
|
||||
}
|
||||
});
|
||||
backendService.getTasks().subscribe((response) => {
|
||||
if (response.status > 399) {
|
||||
alert('Fehler');
|
||||
} else {
|
||||
this.tasks.push(...response.body);
|
||||
}
|
||||
});
|
||||
backendService.getAllStatus().subscribe((response) => {
|
||||
if (response.status > 399) {
|
||||
alert('Fehler');
|
||||
|
@ -76,46 +64,54 @@ export class BacklogComponent extends TableComponentBase<
|
|||
});
|
||||
}
|
||||
|
||||
public deleteUserstory(userstory: ScrumUserstory) {
|
||||
this.backendService.deleteUserstory(userstory).subscribe((response) => {
|
||||
if (response.status > 399) {
|
||||
alert('Fehler');
|
||||
}
|
||||
});
|
||||
const index = this.items.indexOf(userstory);
|
||||
if (index !== -1) {
|
||||
this.items.splice(index, 1);
|
||||
}
|
||||
/**
|
||||
* Formats an ISO DateString to a simple date string in the format "DD.MM.YYYY"
|
||||
* @param isoFormatString date formatted as an ISO DateString (Date objects get converted implicitly)
|
||||
*/
|
||||
public toDateString(isoFormatString) {
|
||||
const date = new Date(isoFormatString);
|
||||
return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`;
|
||||
}
|
||||
|
||||
public openUserstoryForm(editUserstory?: ScrumUserstory) {
|
||||
const modalRef = this.modalService.open(UserstoryFormComponent, {
|
||||
backdrop: 'static',
|
||||
keyboard: true,
|
||||
size: 'lg'
|
||||
});
|
||||
if (editUserstory === null) {
|
||||
modalRef.result.then((result) => {
|
||||
this.items.push(result);
|
||||
});
|
||||
}
|
||||
modalRef.componentInstance.userstory = editUserstory;
|
||||
//#region getters
|
||||
|
||||
/**
|
||||
* Getter that returns an array with all userstories that are in the currently selected sprint.
|
||||
* The relation to the sprint is determined by the userstory's sprintid.
|
||||
* If no sprint is selected it just returns an empty array.
|
||||
*/
|
||||
public get choosen(): ScrumUserstory[]
|
||||
{
|
||||
if(this.selectedSprint === undefined){return null;}
|
||||
return this.storys.filter(u => u.sprintid == this.selectedSprint.id);
|
||||
}
|
||||
|
||||
public getNumberOfTasks(userstory: ScrumUserstory) {
|
||||
return this.tasks.filter((t) => t.userstoryid === userstory.id).length;
|
||||
/**
|
||||
* Getter that returns an array with all userstories that aren't in any sprint.
|
||||
* The relation to no sprint is determined by the userstory's sprintid being undefined.
|
||||
*/
|
||||
public get backlog(): ScrumUserstory[]
|
||||
{
|
||||
return this.storys.filter(u => u.sprintid === undefined);
|
||||
}
|
||||
|
||||
getCategoryTitleById(id) {
|
||||
var category = this.categories.find((x) => x.id === id);
|
||||
if (!category) {
|
||||
return 'N/A';
|
||||
}
|
||||
return category.title;
|
||||
/**
|
||||
* Getter that returns the current sprint.
|
||||
* The current sprint is selected by determining if todays date is between the startDate and the endDate of the sprint.
|
||||
*/
|
||||
public get currentSprint(): ScrumSprint {
|
||||
const now = Date.now();
|
||||
return this.sprints.find(s => Date.parse(s.startDate) < now && Date.parse(s.endDate) > now);
|
||||
}
|
||||
|
||||
// Sprint-Backlog
|
||||
//#endregion getters
|
||||
|
||||
//#region backlogFunctions
|
||||
|
||||
/**
|
||||
* Adds a userstory to the currently selected sprint by changing it's sprintid to the current sprint's id
|
||||
* @param userstory userstory object that shall be added to the selected sprint's backlog
|
||||
*/
|
||||
public addToSprintBacklog(userstory: ScrumUserstory) {
|
||||
userstory.sprintid = this.selectedSprint.id;
|
||||
this.backendService.putUserstory(userstory).subscribe((response) => {
|
||||
|
@ -125,6 +121,10 @@ export class BacklogComponent extends TableComponentBase<
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a userstory from the currently selected sprint by changing it's sprintid to undefined
|
||||
* @param userstory userstory object that shall be removed from the selected sprint's backlog
|
||||
*/
|
||||
public deleteFromSprintBacklog(userstory: ScrumUserstory){
|
||||
userstory.sprintid = undefined;
|
||||
this.backendService.putUserstory(userstory).subscribe((response) => {
|
||||
|
@ -134,37 +134,23 @@ 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);
|
||||
}
|
||||
//#endregion backlogFunctions
|
||||
|
||||
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) {
|
||||
//#region modals
|
||||
/**
|
||||
* Opens the SprintForm Modal to let the user create a new sprint.
|
||||
* The created sprint get pushed to the database and the local sprints array.
|
||||
*/
|
||||
public openSprintForm() {
|
||||
const modalRef = this.modalService.open(SprintFormComponent, {
|
||||
backdrop: 'static',
|
||||
keyboard: true,
|
||||
size: "lg",
|
||||
});
|
||||
|
||||
modalRef.result.then(result => {
|
||||
this.sprints.push(result);
|
||||
});
|
||||
if (editSprint === null) {
|
||||
modalRef.result.then(result => {
|
||||
this.items.push(result);
|
||||
});
|
||||
}
|
||||
modalRef.componentInstance.sprint = editSprint;
|
||||
}
|
||||
//#endregion modals
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue