created new sprint form component draft
This commit is contained in:
54
src/app/sprint-component/sprint.component.ts
Normal file
54
src/app/sprint-component/sprint.component.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user