55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
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.component.html',
|
|
styleUrls: ['./sprint.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;
|
|
}
|
|
|
|
}
|