diff --git a/src/app/components/sprint-table/sprint-table.component.spec.ts b/src/app/components/tabels/sprint/sprint-table.component.spec.ts similarity index 89% rename from src/app/components/sprint-table/sprint-table.component.spec.ts rename to src/app/components/tabels/sprint/sprint-table.component.spec.ts index 3776c34..d153a30 100644 --- a/src/app/components/sprint-table/sprint-table.component.spec.ts +++ b/src/app/components/tabels/sprint/sprint-table.component.spec.ts @@ -1,28 +1,28 @@ -import { TestBed, async } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { BackendService } from '../../services/backend.service'; -import { HttpClientModule } from '@angular/common/http'; -import { SprintTableComponent } from './sprint-table.component'; - -describe('SprintTableComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - RouterTestingModule, - HttpClientModule, - ], - declarations: [ - SprintTableComponent, - ], - providers: [ - BackendService, - ] - }).compileComponents(); - })); - - it('should create the component', () => { - const fixture = TestBed.createComponent(SprintTableComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - }); -}); +import { TestBed, async } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { BackendService } from '../../../services/backend.service'; +import { HttpClientModule } from '@angular/common/http'; +import { SprintTableComponent } from './sprint-table.component'; + +describe('SprintTableComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + RouterTestingModule, + HttpClientModule, + ], + declarations: [ + SprintTableComponent, + ], + providers: [ + BackendService, + ] + }).compileComponents(); + })); + + it('should create the component', () => { + const fixture = TestBed.createComponent(SprintTableComponent); + const app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + }); +}); diff --git a/src/app/components/tabels/sprint/sprint-table.component.ts b/src/app/components/tabels/sprint/sprint-table.component.ts index 51456f7..0ce42b8 100644 --- a/src/app/components/tabels/sprint/sprint-table.component.ts +++ b/src/app/components/tabels/sprint/sprint-table.component.ts @@ -1,93 +1,92 @@ -import { Component } from '@angular/core'; -import { BackendService, ScrumSprint } from '../../../services/backend.service'; -import { TableComponentBase } from '../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 { - /** - * Constructor that establishes the initial backend communication. - * @param backendService backendService object for backend communication - * @param modalService angular modalService to handle modals for the Form popups - * @param route route object to extract parameters from - */ - constructor( - private backendService: BackendService, - private modalService: NgbModal, - protected route: ActivatedRoute - ) { - super(route); - - backendService.getSprints().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.items.push(...response.body); - } - }); - } - - //#region getters - //#endregion getters - - //#region sprintTableFunctions - /** - * Deletes a sprint by calling the delete method via the backendService and removing it from the tabel's items array. - * @param sprint sprint that will be deleted - */ - 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); - } - } - //#endregion sprintTableFunctions - - //#region sorters - /** - * Sorts the tabel's items by startDate - */ - sortByStartDate() { - this.doStringSort('startDate', (sprint) => sprint.startDate); - } - - /** - * Sorts the tabel's items by endDate - */ - sortByEndDate() { - this.doStringSort('endDate', (sprint) => sprint.endDate); - } - //#endregion sorters - - //#region modals - /** - * Opens a SprintForm popup for editing a existing sprint or creating a new one. - * @param editSprint optional: sprint to edit (only needed if a task should be edited, not newly created) - */ - public openSprintForm(editSprint?: ScrumSprint) { - const modalRef = this.modalService.open(SprintFormComponent, { - backdrop: 'static', - keyboard: true, - size: 'md', - }); - if (editSprint == null) { - modalRef.result.then((result) => { - alert("hi"); - this.items.push(result); - }); - } - modalRef.componentInstance.sprint = editSprint; - } - //#endregion modals -} +import { Component } from '@angular/core'; +import { BackendService, ScrumSprint } from '../../../services/backend.service'; +import { TableComponentBase } from '../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 { + /** + * Constructor that establishes the initial backend communication. + * @param backendService backendService object for backend communication + * @param modalService angular modalService to handle modals for the Form popups + * @param route route object to extract parameters from + */ + constructor( + private backendService: BackendService, + private modalService: NgbModal, + protected route: ActivatedRoute + ) { + super(route); + + backendService.getSprints().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.items.push(...response.body); + } + }); + } + + //#region getters + //#endregion getters + + //#region sprintTableFunctions + /** + * Deletes a sprint by calling the delete method via the backendService and removing it from the tabel's items array. + * @param sprint sprint that will be deleted + */ + 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); + } + } + //#endregion sprintTableFunctions + + //#region sorters + /** + * Sorts the tabel's items by startDate + */ + sortByStartDate() { + this.doStringSort('startDate', (sprint) => sprint.startDate); + } + + /** + * Sorts the tabel's items by endDate + */ + sortByEndDate() { + this.doStringSort('endDate', (sprint) => sprint.endDate); + } + //#endregion sorters + + //#region modals + /** + * Opens a SprintForm popup for editing a existing sprint or creating a new one. + * @param editSprint optional: sprint to edit (only needed if a task should be edited, not newly created) + */ + public openSprintForm(editSprint?: ScrumSprint) { + const modalRef = this.modalService.open(SprintFormComponent, { + backdrop: 'static', + keyboard: true, + size: 'md', + }); + if (editSprint == null) { + modalRef.result.then((result) => { + this.items.push(result); + }); + } + modalRef.componentInstance.sprint = editSprint; + } + //#endregion modals +}