diff --git a/src/app/backlog-table copy/backlog-table.component.css b/src/app/backlog-table copy/backlog-table.component.css new file mode 100644 index 0000000..a268ac9 --- /dev/null +++ b/src/app/backlog-table copy/backlog-table.component.css @@ -0,0 +1,3 @@ +th.sortable:hover { + text-decoration: underline; +} \ No newline at end of file diff --git a/src/app/backlog-table copy/backlog-table.component.html b/src/app/backlog-table copy/backlog-table.component.html new file mode 100644 index 0000000..89da5a1 --- /dev/null +++ b/src/app/backlog-table copy/backlog-table.component.html @@ -0,0 +1,229 @@ +
+ +

Backlog

+
+
+
+
+ +
+
+
+
+

Verfügbare Userstories

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ID + + + + + + + Titel + + + + + + + Tasks + + + + + + + Status + + + + + + +
+
+ Priorität: +
+ {{filterPriority || "All"}} +
+ + +
+
+ + + + + +
+
+
+ Category + + + + + +
{{userstory.id}}{{userstory.title}} + + {{getNumberOfTasks(userstory)}} Tasks + + + + {{getStatusTitleById(userstory.statusid)}} + + {{userstory.priority}} + + {{getCategoryTitleById(userstory.categoryid)}} + + + + +
+
+
+ +
+ +

Sprint-Backlog

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ID + + + + + + + Titel + + + + + + + Tasks + + + + + + + Status + + + + + + +
+
+ Priorität: +
+ {{filterPriority || "All"}} +
+ + +
+
+ + + + + +
+
+
+ Category + + + + + +
{{userstory.id}}{{userstory.title}} + + {{getNumberOfTasks(userstory)}} Tasks + + + + {{getStatusTitleById(userstory.statusid)}} + + {{userstory.priority}} + + {{getCategoryTitleById(userstory.categoryid)}} + + + +
+
+
+
\ No newline at end of file diff --git a/src/app/backlog-table copy/backlog-table.component.ts b/src/app/backlog-table copy/backlog-table.component.ts new file mode 100644 index 0000000..2d799c4 --- /dev/null +++ b/src/app/backlog-table copy/backlog-table.component.ts @@ -0,0 +1,185 @@ +import { Component } from '@angular/core'; +import { + BackendService, + ScrumTask, + ScrumUserstory, + ScrumStatus, + ScrumCategory, + ScrumSprint, + ScrumUser, +} 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, ParamMap, Router } from '@angular/router'; +import { SprintFormComponent } from '../sprint-form/sprint-form.component'; + + +@Component({ + selector: 'app-userstory-table', + templateUrl: './userstory-table.component.html', + styleUrls: ['./userstory-table.component.css'], +}) +export class UserstoryTableComponent extends TableComponentBase< + ScrumUserstory +> { + public tasks: ScrumTask[] = []; + public filterPriority: string | null = null; + public highlightId: number; + public status: ScrumStatus[] = []; + public categories: ScrumCategory[] = []; + + public choosen: ScrumUserstory[] = []; + + public get filteredItems() { + return this.items.filter( + (task) => + this.filterPriority === null || task.priority === this.filterPriority + ); + } + + constructor( + private backendService: BackendService, + private modalService: NgbModal, + private route: ActivatedRoute, + private router: Router + ) { + super(); + + this.applyFilterParameters(this.route.snapshot.paramMap); + this.route.paramMap.subscribe((map) => this.applyFilterParameters(map)); + + backendService.getUserstories().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.items.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'); + } else { + this.status.push(...response.body); + } + }); + backendService.getCategories().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.categories.push(...response.body); + } + }); + } + + private applyFilterParameters(params: ParamMap) { + if (params.has('id')) { + this.highlightId = parseInt(params.get('id')); + } + } + + 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); + } + } + + 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; + } + + public getNumberOfTasks(userstory: ScrumUserstory) { + 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) { + return 'N/A'; + } + return category.title; + } + + // Sprint-Backlog + + public addToSprintBacklog(userstory: ScrumUserstory) { + this.choosen.push(userstory); + } + public deleteFromSprintBacklog(userstory: ScrumUserstory){ + + const index = this.choosen.indexOf(userstory); + this.choosen.splice(index, 1); + } + + public addToSprint(choosen: ScrumUserstory[]){ + + } + + public openSprintForm(editSprint?: ScrumSprint) { + const modalRef = this.modalService.open(SprintFormComponent, { + backdrop: 'static', + keyboard: true, + }); + if (editSprint === null) { + modalRef.result.then(result => { + this.items.push(result); + }); + } + modalRef.componentInstance.sprint = editSprint; + } +}