Added comments and prettified

This commit is contained in:
Nicolai Ort 2020-07-10 22:36:58 +02:00
parent ce56cab766
commit 91e30ef491

View File

@ -1,23 +1,30 @@
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 { 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']
styleUrls: ['./sprint-table.component.css'],
})
export class SprintTableComponent extends TableComponentBase<ScrumSprint> {
/**
* 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, private router: Router
private backendService: BackendService,
private modalService: NgbModal,
protected route: ActivatedRoute
) {
super(route);
backendService.getSprints().subscribe(response => {
backendService.getSprints().subscribe((response) => {
if (response.status > 399) {
alert('Fehler');
} else {
@ -30,8 +37,12 @@ export class SprintTableComponent extends TableComponentBase<ScrumSprint> {
//#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 => {
this.backendService.deleteSprint(sprint).subscribe((response) => {
if (response.status > 399) {
alert('Fehler');
}
@ -44,28 +55,38 @@ export class SprintTableComponent extends TableComponentBase<ScrumSprint> {
//#endregion sprintTableFunctions
//#region sorters
/**
* Sorts the tabel's items by startDate
*/
sortByStartDate() {
this.doStringSort('startDate', sprint => sprint.startDate);
this.doStringSort('startDate', (sprint) => sprint.startDate);
}
/**
* Sorts the tabel's items by endDate
*/
sortByEndDate() {
this.doStringSort('endDate', sprint => sprint.endDate);
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",
size: 'md',
});
if (editSprint === null) {
modalRef.result.then(result => {
modalRef.result.then((result) => {
this.items.push(result);
});
}
modalRef.componentInstance.sprint = editSprint;
}
//#endregion modals
}
}