Added comments and prettified
This commit is contained in:
parent
ce56cab766
commit
91e30ef491
@ -1,23 +1,30 @@
|
|||||||
import {Component} from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {BackendService, ScrumSprint} from '../../../services/backend.service';
|
import { BackendService, ScrumSprint } from '../../../services/backend.service';
|
||||||
import {TableComponentBase} from '../table-component.base';
|
import { TableComponentBase } from '../table-component.base';
|
||||||
import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {ActivatedRoute, ParamMap, Router} from '@angular/router';
|
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||||
import { SprintFormComponent } from '../../sprint-form/sprint-form.component';
|
import { SprintFormComponent } from '../../sprint-form/sprint-form.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sprint',
|
selector: 'app-sprint',
|
||||||
templateUrl: './sprint-table.component.html',
|
templateUrl: './sprint-table.component.html',
|
||||||
styleUrls: ['./sprint-table.component.css']
|
styleUrls: ['./sprint-table.component.css'],
|
||||||
})
|
})
|
||||||
export class SprintTableComponent extends TableComponentBase<ScrumSprint> {
|
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(
|
constructor(
|
||||||
private backendService: BackendService, private modalService: NgbModal,
|
private backendService: BackendService,
|
||||||
protected route: ActivatedRoute, private router: Router
|
private modalService: NgbModal,
|
||||||
|
protected route: ActivatedRoute
|
||||||
) {
|
) {
|
||||||
super(route);
|
super(route);
|
||||||
|
|
||||||
backendService.getSprints().subscribe(response => {
|
backendService.getSprints().subscribe((response) => {
|
||||||
if (response.status > 399) {
|
if (response.status > 399) {
|
||||||
alert('Fehler');
|
alert('Fehler');
|
||||||
} else {
|
} else {
|
||||||
@ -30,8 +37,12 @@ export class SprintTableComponent extends TableComponentBase<ScrumSprint> {
|
|||||||
//#endregion getters
|
//#endregion getters
|
||||||
|
|
||||||
//#region sprintTableFunctions
|
//#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) {
|
public deleteSprint(sprint: ScrumSprint) {
|
||||||
this.backendService.deleteSprint(sprint).subscribe(response => {
|
this.backendService.deleteSprint(sprint).subscribe((response) => {
|
||||||
if (response.status > 399) {
|
if (response.status > 399) {
|
||||||
alert('Fehler');
|
alert('Fehler');
|
||||||
}
|
}
|
||||||
@ -44,28 +55,38 @@ export class SprintTableComponent extends TableComponentBase<ScrumSprint> {
|
|||||||
//#endregion sprintTableFunctions
|
//#endregion sprintTableFunctions
|
||||||
|
|
||||||
//#region sorters
|
//#region sorters
|
||||||
|
/**
|
||||||
|
* Sorts the tabel's items by startDate
|
||||||
|
*/
|
||||||
sortByStartDate() {
|
sortByStartDate() {
|
||||||
this.doStringSort('startDate', sprint => sprint.startDate);
|
this.doStringSort('startDate', (sprint) => sprint.startDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts the tabel's items by endDate
|
||||||
|
*/
|
||||||
sortByEndDate() {
|
sortByEndDate() {
|
||||||
this.doStringSort('endDate', sprint => sprint.endDate);
|
this.doStringSort('endDate', (sprint) => sprint.endDate);
|
||||||
}
|
}
|
||||||
//#endregion sorters
|
//#endregion sorters
|
||||||
|
|
||||||
//#region modals
|
//#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) {
|
public openSprintForm(editSprint?: ScrumSprint) {
|
||||||
const modalRef = this.modalService.open(SprintFormComponent, {
|
const modalRef = this.modalService.open(SprintFormComponent, {
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
keyboard: true,
|
keyboard: true,
|
||||||
size: "md",
|
size: 'md',
|
||||||
});
|
});
|
||||||
if (editSprint === null) {
|
if (editSprint === null) {
|
||||||
modalRef.result.then(result => {
|
modalRef.result.then((result) => {
|
||||||
this.items.push(result);
|
this.items.push(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
modalRef.componentInstance.sprint = editSprint;
|
modalRef.componentInstance.sprint = editSprint;
|
||||||
}
|
}
|
||||||
//#endregion modals
|
//#endregion modals
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user