diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 959d1cd..5dda508 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -3,10 +3,12 @@ import { Routes, RouterModule } from '@angular/router'; import {UserstoryTableComponent} from './userstory-table/userstory-table.component'; import {TaskTableComponent} from './task-table/task-table.component'; +import { SprintTableComponent } from './sprint-table/sprint-table.component'; const routes: Routes = [ { path: 'tasks', component: TaskTableComponent }, { path: 'userstories', component: UserstoryTableComponent }, + { path: 'sprints', component: SprintTableComponent }, { path: '', redirectTo: '/tasks', pathMatch: 'full' }, ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 95551f4..d407a5e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -13,6 +13,7 @@ import { SprintFormComponent } from './sprint-form/sprint-form.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { UserstoryTableComponent } from './userstory-table/userstory-table.component'; import { TaskTableComponent } from './task-table/task-table.component'; +import { SprintTableComponent } from './sprint-table/sprint-table.component'; @NgModule({ declarations: [ @@ -22,7 +23,8 @@ import { TaskTableComponent } from './task-table/task-table.component'; UserstoryTableComponent, UserstoryFormComponent, UserstoryTableComponent, - SprintFormComponent + SprintFormComponent, + SprintTableComponent ], imports: [ BrowserModule, diff --git a/src/app/sprint-component/sprint-table.component.css b/src/app/sprint-component/sprint-table.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/sprint-component/sprint-table.component.ts b/src/app/sprint-component/sprint-table.component.ts deleted file mode 100644 index b10f296..0000000 --- a/src/app/sprint-component/sprint-table.component.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; -import { BackendService, ScrumSprint } from '../services/backend.service'; -import { SprintFormComponent } from '../sprint-form/sprint-form.component'; - -@Component({ - selector: 'app-sprint', - templateUrl: './sprint-table.component.html', - styleUrls: ['./sprint-table.component.css'] -}) -export class SprintComponent implements OnInit { - - public sprints: ScrumSprint[] = []; - - constructor(private backendService: BackendService, private modalService: NgbModal) { - backendService.getSprints().subscribe(response => { - if (response.status > 399) { - alert('Fehler'); - } - else { - this.sprints.push(...response.body); - } - }); - } - - ngOnInit(): void { - } - - public deleteSprint(sprint: ScrumSprint) { - this.backendService.deleteSprint(sprint).subscribe(response => { - if (response.status > 399) { - alert('Fehler'); - } - }); - const index = this.sprints.indexOf(sprint); - if (index !== -1) { - this.sprints.splice(index, 1); - } - } - - public openSprintForm(editSprint: ScrumSprint) { - const modalRef = this.modalService.open(SprintFormComponent, { - backdrop: 'static', - keyboard: true, - }); - if (editSprint === null) { - modalRef.result.then(result => { - this.sprints.push(result); - }); - } - modalRef.componentInstance.userstory = editSprint; - } - -} diff --git a/src/app/sprint-table/sprint-table.component.css b/src/app/sprint-table/sprint-table.component.css new file mode 100644 index 0000000..5b74f7f --- /dev/null +++ b/src/app/sprint-table/sprint-table.component.css @@ -0,0 +1,8 @@ +table { + table-layout: fixed; + } + + th.sortable:hover { + text-decoration: underline; + } + \ No newline at end of file diff --git a/src/app/sprint-component/sprint-table.component.html b/src/app/sprint-table/sprint-table.component.html similarity index 100% rename from src/app/sprint-component/sprint-table.component.html rename to src/app/sprint-table/sprint-table.component.html diff --git a/src/app/sprint-table/sprint-table.component.ts b/src/app/sprint-table/sprint-table.component.ts new file mode 100644 index 0000000..aa17134 --- /dev/null +++ b/src/app/sprint-table/sprint-table.component.ts @@ -0,0 +1,79 @@ +import {Component} from '@angular/core'; +import {BackendService, ScrumSprint} from '../services/backend.service'; +import {TableComponentBase} from '../services/table-component.base'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {ActivatedRoute, ParamMap, Router} from '@angular/router'; +import { SprintFormComponent } from '../sprint-form/sprint-form.component'; + +@Component({ + selector: 'app-sprint', + templateUrl: './sprint-table.component.html', + styleUrls: ['./sprint-table.component.css'] +}) +export class SprintTableComponent extends TableComponentBase { + public filterSprintId: number | null = null; + public highlightId: number; + + public get filteredItems() { + return this.items.filter(sprint => + (this.filterSprintId === null || sprint.id === this.filterSprintId) + ); + } + + constructor( + 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)); + + backendService.getSprints().subscribe(response => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.items.push(...response.body); + } + }); + } + + private applyFilterParameters(params: ParamMap) { + if (params.has('id')) { + this.highlightId = parseInt(params.get('id')); + } + } + + public deleteSprint(sprint: ScrumSprint) { + this.backendService.deleteSprint(sprint).subscribe(response => { + if (response.status > 399) { + alert('Fehler'); + } + }); + const index = this.items.indexOf(sprint); + if (index !== -1) { + this.items.splice(index, 1); + } + } + + 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; + } + + sortById() { + this.doNumericSort('id', sprint => sprint.id); + } + + sortByTitle() { + this.doStringSort('title', sprint => sprint.title); + } +} diff --git a/src/app/task-table/task-table.component.ts b/src/app/task-table/task-table.component.ts index 20ded7a..769a19d 100644 --- a/src/app/task-table/task-table.component.ts +++ b/src/app/task-table/task-table.component.ts @@ -5,8 +5,6 @@ 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 { Title } from '@angular/platform-browser'; -import { isNumber } from 'util'; @Component({ selector: 'app-userstory-table',