diff --git a/src/app/task-table/task-table.component.html b/src/app/task-table/task-table.component.html index 7462e64..9afb260 100644 --- a/src/app/task-table/task-table.component.html +++ b/src/app/task-table/task-table.component.html @@ -1,114 +1,113 @@
-

- - Userstory #{{filterUserstoryId}} > - - Tasks -

-
- Alle Tasks anzeigen -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Tasks + +
+ Alle Tasks anzeigen +
-
- ID - - - - - - Titel - - - - - - Userstory - - - - - - Status - - - - - - Priorität - - - - - - - Assigned To - - - - - - Category - - - - -
{{task.id}}{{task.title}} - - US #{{task.userstoryid}} +

+ + Userstory #{{filterUserstoryId}} + > -

- - Status: {{task.statusid}} - - {{task.priority}} - - User: {{task.assignedtoid}} - - - - Category: {{task.categoryid}} - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ID + + + + + + Titel + + + + + + Userstory + + + + + + Status + + + + + + Priorität + + + + + + + Assigned To + + + + + + Category + + + + +
{{task.id}}{{task.title}} + + US #{{task.userstoryid}} + + + + {{getStatusTitleById(task.statusid)}} + + {{task.priority}} + + {{getUserNameById(task.assignedtoid)}} + + + + {{getCategoryTitleById(task.categoryid)}} + + + + +
+ diff --git a/src/app/task-table/task-table.component.ts b/src/app/task-table/task-table.component.ts index ae9dc1b..6e850ad 100644 --- a/src/app/task-table/task-table.component.ts +++ b/src/app/task-table/task-table.component.ts @@ -1,44 +1,78 @@ -import {Component} from '@angular/core'; -import {BackendService, ScrumTask} from '../services/backend.service'; -import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; -import {TaskFormComponent} from '../task-form/task-form.component'; -import {TableComponentBase} from '../services/table-component.base'; -import {ActivatedRoute, ParamMap, Router} from '@angular/router'; -import {getNumberForPriority} from '../services/sorting.service'; +import { Component } from '@angular/core'; +import { + BackendService, + ScrumTask, + ScrumStatus, + ScrumUser, + ScrumCategory, +} from '../services/backend.service'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; +import { TaskFormComponent } from '../task-form/task-form.component'; +import { TableComponentBase } from '../services/table-component.base'; +import { ActivatedRoute, ParamMap, Router } from '@angular/router'; +import { getNumberForPriority } from '../services/sorting.service'; @Component({ selector: 'app-userstory-table', templateUrl: './task-table.component.html', - styleUrls: ['./task-table.component.css'] + styleUrls: ['./task-table.component.css'], }) export class TaskTableComponent extends TableComponentBase { public filterUserstoryId: number | null = null; public filterPriority: string | null = null; public highlightId: number; + public status: ScrumStatus[] = []; + public users: ScrumUser[] = []; + public categories: ScrumCategory[] = []; public get filteredItems() { - return this.items.filter(task => - (this.filterUserstoryId === null || task.userstoryid === this.filterUserstoryId) - && (this.filterPriority === null || task.priority === this.filterPriority) + return this.items.filter( + (task) => + (this.filterUserstoryId === null || + task.userstoryid === this.filterUserstoryId) && + (this.filterPriority === null || task.priority === this.filterPriority) ); } constructor( - private backendService: BackendService, private modalService: NgbModal, - private route: ActivatedRoute, private router: Router + private backendService: BackendService, + private modalService: NgbModal, + private route: ActivatedRoute, + private router: Router ) { super(); this.applyFilterParameters(route.snapshot.paramMap); - route.paramMap.subscribe(map => this.applyFilterParameters(map)); + route.paramMap.subscribe((map) => this.applyFilterParameters(map)); - backendService.getTasks().subscribe(response => { + backendService.getTasks().subscribe((response) => { if (response.status > 399) { alert('Fehler'); } else { this.items.push(...response.body); } }); + backendService.getAllStatus().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.status.push(...response.body); + } + }); + backendService.getUsers().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.users.push(...response.body); + } + }); + backendService.getCategories().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.categories.push(...response.body); + } + }); } private applyFilterParameters(params: ParamMap) { @@ -53,7 +87,7 @@ export class TaskTableComponent extends TableComponentBase { } public deleteTask(task: ScrumTask) { - this.backendService.deleteTask(task).subscribe(response => { + this.backendService.deleteTask(task).subscribe((response) => { if (response.status > 399) { alert('Fehler'); } @@ -70,7 +104,7 @@ export class TaskTableComponent extends TableComponentBase { keyboard: true, }); if (editTask === null) { - modalRef.result.then(result => { + modalRef.result.then((result) => { this.items.push(result); }); } @@ -78,32 +112,58 @@ export class TaskTableComponent extends TableComponentBase { } sortById() { - this.doNumericSort('id', task => task.id); + this.doNumericSort('id', (task) => task.id); } sortByTitle() { - this.doStringSort('title', task => task.title); + this.doStringSort('title', (task) => task.title); } sortByPrio() { - this.doNumericSort('priority', task => getNumberForPriority(task.priority)); + this.doNumericSort('priority', (task) => + getNumberForPriority(task.priority) + ); } sortByTasks() { - this.doNumericSort('userstory', task => task.userstoryid); + this.doNumericSort('userstory', (task) => task.userstoryid); } sortByStatus() { - this.doNumericSort('statusid', task => task.statusid); + this.doNumericSort('statusid', (task) => task.statusid); } sortByAssigned() { - this.doNumericSort('assignedtoid', task => task.assignedtoid); + this.doNumericSort('assignedtoid', (task) => task.assignedtoid); } sortByCategory() { - this.doNumericSort('categoryid', task => task.categoryid); + this.doNumericSort('categoryid', (task) => task.categoryid); } private findTaskById(id: number): ScrumTask { - return this.items.find(t => t.id === id); + return this.items.find((t) => t.id === id); + } + + getStatusTitleById(id) { + var status = this.status.find((x) => x.id === id); + if (!status) { + return 'N/A'; + } + return status.title; + } + + getUserNameById(id) { + var user = this.users.find((x) => x.id === id); + if (!user) { + return 'N/A'; + } + return user.name; + } + + getCategoryTitleById(id) { + var category = this.categories.find((x) => x.id === id); + if (!category) { + return 'N/A'; + } + return category.title; } } diff --git a/src/app/userstory-table/userstory-table.component.html b/src/app/userstory-table/userstory-table.component.html index e174985..502aa3f 100644 --- a/src/app/userstory-table/userstory-table.component.html +++ b/src/app/userstory-table/userstory-table.component.html @@ -71,13 +71,13 @@ - Status: {{userstory.statusid}} + {{getStatusTitleById(userstory.statusid)}} {{userstory.priority}} - Category: {{userstory.categoryid}} + {{getCategoryTitleById(userstory.categoryid)}} diff --git a/src/app/userstory-table/userstory-table.component.ts b/src/app/userstory-table/userstory-table.component.ts index 194d88a..ac42ac5 100644 --- a/src/app/userstory-table/userstory-table.component.ts +++ b/src/app/userstory-table/userstory-table.component.ts @@ -1,48 +1,77 @@ -import {Component} from '@angular/core'; -import {BackendService, ScrumTask, ScrumUserstory} 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 { Component } from '@angular/core'; +import { + BackendService, + ScrumTask, + ScrumUserstory, + ScrumStatus, + ScrumCategory, +} 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'; @Component({ selector: 'app-userstory-table', templateUrl: './userstory-table.component.html', - styleUrls: ['./userstory-table.component.css'] + styleUrls: ['./userstory-table.component.css'], }) -export class UserstoryTableComponent extends TableComponentBase { +export class UserstoryTableComponent extends TableComponentBase< + ScrumUserstory +> { public tasks: ScrumTask[] = []; public filterPriority: string | null = null; public highlightId: number; + public status: ScrumStatus[] = []; + public categories: ScrumCategory[] = []; public get filteredItems() { - return this.items.filter(task => this.filterPriority === null || task.priority === this.filterPriority); + 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 + 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)); + this.route.paramMap.subscribe((map) => this.applyFilterParameters(map)); - backendService.getUserstories().subscribe(response => { + backendService.getUserstories().subscribe((response) => { if (response.status > 399) { alert('Fehler'); } else { this.items.push(...response.body); } }); - backendService.getTasks().subscribe(response => { + 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) { @@ -52,7 +81,7 @@ export class UserstoryTableComponent extends TableComponentBase } public deleteUserstory(userstory: ScrumUserstory) { - this.backendService.deleteUserstory(userstory).subscribe(response => { + this.backendService.deleteUserstory(userstory).subscribe((response) => { if (response.status > 399) { alert('Fehler'); } @@ -69,7 +98,7 @@ export class UserstoryTableComponent extends TableComponentBase keyboard: true, }); if (editUserstory === null) { - modalRef.result.then(result => { + modalRef.result.then((result) => { this.items.push(result); }); } @@ -77,29 +106,45 @@ export class UserstoryTableComponent extends TableComponentBase } public getNumberOfTasks(userstory: ScrumUserstory) { - 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); + this.doNumericSort('id', (us) => us.id); } public sortByTitle() { - this.doStringSort('title', us => us.title); + this.doStringSort('title', (us) => us.title); } public sortByPrio() { - this.doNumericSort('priority', us => getNumberForPriority(us.priority)); + this.doNumericSort('priority', (us) => getNumberForPriority(us.priority)); } public sortByTasks() { - this.doNumericSort('tasks', us => this.getNumberOfTasks(us)); + this.doNumericSort('tasks', (us) => this.getNumberOfTasks(us)); } sortByStatus() { - this.doNumericSort('statusid', us => us.statusid); + this.doNumericSort('statusid', (us) => us.statusid); } sortByCategory() { - this.doNumericSort('categoryid', us => us.categoryid); + 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; } }