diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e6c683f..a724a81 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,6 +11,7 @@ import { TaskListComponent } from './task-list/task-list.component'; import { TaskFormComponent } from './task-form/task-form.component'; import { UserstoryListComponent } from './userstory-list/userstory-list.component'; import { UserstoryFormComponent } from './userstory-form/userstory-form.component'; +import { SprintFormComponent } from './sprint-form/sprint-form.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; @NgModule({ @@ -19,7 +20,8 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; TaskListComponent, TaskFormComponent, UserstoryListComponent, - UserstoryFormComponent + UserstoryFormComponent, + SprintFormComponent ], imports: [ BrowserModule, diff --git a/src/app/services/backend.service.ts b/src/app/services/backend.service.ts index 239f82a..8682de8 100644 --- a/src/app/services/backend.service.ts +++ b/src/app/services/backend.service.ts @@ -232,7 +232,7 @@ export interface ScrumUserstory { export interface ScrumSprint{ id?: number; title: string; - description: string; + description?: string; startDate: Date; endDate: Date; project: number; diff --git a/src/app/sprint-component/sprint.component.css b/src/app/sprint-component/sprint.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/sprint-component/sprint.component.html b/src/app/sprint-component/sprint.component.html new file mode 100644 index 0000000..9190d3a --- /dev/null +++ b/src/app/sprint-component/sprint.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/sprint-component/sprint.component.ts b/src/app/sprint-component/sprint.component.ts new file mode 100644 index 0000000..d47b86b --- /dev/null +++ b/src/app/sprint-component/sprint.component.ts @@ -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; + } + +} diff --git a/src/app/sprint-form/sprint-form.component.css b/src/app/sprint-form/sprint-form.component.css new file mode 100644 index 0000000..717de4c --- /dev/null +++ b/src/app/sprint-form/sprint-form.component.css @@ -0,0 +1,4 @@ +.modal-footer { + border-top: 0px solid; + padding-top: 5%; +} \ No newline at end of file diff --git a/src/app/sprint-form/sprint-form.component.html b/src/app/sprint-form/sprint-form.component.html new file mode 100644 index 0000000..641a485 --- /dev/null +++ b/src/app/sprint-form/sprint-form.component.html @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/src/app/sprint-form/sprint-form.component.ts b/src/app/sprint-form/sprint-form.component.ts new file mode 100644 index 0000000..f19c1bb --- /dev/null +++ b/src/app/sprint-form/sprint-form.component.ts @@ -0,0 +1,62 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { + BackendService, + ScrumTask, + Priority, + ScrumStatus, + ScrumCategory, + ScrumUser, + ScrumProject, + ScrumUserstory, + ScrumSprint +} from '../services/backend.service'; +import { Observable } from 'rxjs'; +import { HttpResponse } from '@angular/common/http'; + +@Component({ + selector: 'app-task-form', + templateUrl: './sprint-form.component.html', + styleUrls: ['./sprint-form.component.css'], +}) +export class SprintFormComponent implements OnInit { + @Input() public sprint: ScrumSprint; + public editing: Boolean; + public sprintid: string; + + constructor( + private backendService: BackendService, + private activeModalService: NgbActiveModal + ) { } + + ngOnInit(): void { + if (this.sprint === null || this.sprint === undefined) { + this.sprint = { title: '', startDate: new Date(), endDate: new Date(), project: 0 }; //project id: static counter? + this.editing = false; + } else { + this.editing = true; + } + document.getElementById('titleField').focus(); + } + + onSubmit() { + if (this.editing) { + this.backendService.putSprint(this.sprint).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } else { + this.backendService.postSprint(this.sprint).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + this.activeModalService.close(this.sprint); + } + + onClose() { + this.activeModalService.dismiss(this.sprint); + } +}