From e99e0aeb698c163dd33ed2bd066c3e85b72f65db Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Jun 2020 16:13:57 +0200 Subject: [PATCH] created delete and create function --- src/app/task-form/task-form.component.html | 6 +- src/app/task-form/task-form.component.ts | 179 +++++++++++---------- 2 files changed, 95 insertions(+), 90 deletions(-) diff --git a/src/app/task-form/task-form.component.html b/src/app/task-form/task-form.component.html index 08ca014..c83b8e6 100644 --- a/src/app/task-form/task-form.component.html +++ b/src/app/task-form/task-form.component.html @@ -51,15 +51,15 @@
- Neuer Status - Status löschen + Neuer Status + Status löschen
diff --git a/src/app/task-form/task-form.component.ts b/src/app/task-form/task-form.component.ts index 6fcf5d0..be575cb 100644 --- a/src/app/task-form/task-form.component.ts +++ b/src/app/task-form/task-form.component.ts @@ -1,106 +1,111 @@ import { Component, OnInit, Input } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { - BackendService, - ScrumTask, - Priority, - ScrumStatus, - ScrumCategory, - ScrumUser, - ScrumProject, - ScrumUserstory, + BackendService, + ScrumTask, + Priority, + ScrumStatus, + ScrumCategory, + ScrumUser, + ScrumProject, + ScrumUserstory } from '../services/backend.service'; import { Observable } from 'rxjs'; import { HttpResponse } from '@angular/common/http'; @Component({ - selector: 'app-task-form', - templateUrl: './task-form.component.html', - styleUrls: ['./task-form.component.css'], + selector: 'app-task-form', + templateUrl: './task-form.component.html', + styleUrls: [ './task-form.component.css' ] }) export class TaskFormComponent implements OnInit { - @Input() public task: ScrumTask; - public editing: Boolean; - public userstoryId: string; - public userstories: any[] = []; - public allStatus: any[] = []; - public status: ScrumStatus; + @Input() public task: ScrumTask; + public editing: Boolean; + public userstoryId: string; + public userstories: any[] = []; + public allStatus: any[] = []; + public status: ScrumStatus; - constructor( - private backendService: BackendService, - private activeModalService: NgbActiveModal - ) { - this.getUserStories(); - this.getTaskStatus(); - } + constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { + this.getUserStories(); + this.getTaskStatus(); + } - ngOnInit(): void { - if (this.task === null || this.task === undefined) { - this.task = { title: '' }; - this.editing = false; - } else { - this.editing = true; - } - document.getElementById('titleField').focus(); - this.getRelatedStory(); - } + ngOnInit(): void { + if (this.task === null || this.task === undefined) { + this.task = { title: '' }; + this.editing = false; + } else { + this.editing = true; + } + document.getElementById('titleField').focus(); + this.getRelatedStory(); + } - onSubmit() { - if (this.editing) { - this.backendService.putTask(this.task).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } else { - this.backendService.postTask(this.task).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } - this.activeModalService.close(this.task); - } + onSubmit() { + if (this.editing) { + this.backendService.putTask(this.task).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } else { + this.backendService.postTask(this.task).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + this.activeModalService.close(this.task); + } - onClose() { - this.activeModalService.dismiss(this.task); - } + onClose() { + this.activeModalService.dismiss(this.task); + } - getRelatedStory() { - this.backendService.getUserstory(2).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.userstoryId = response.body.title; - } - }); - } + getRelatedStory() { + this.backendService.getUserstory(2).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.userstoryId = response.body.title; + } + }); + } - getUserStories() { - this.backendService.getUserstories().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.userstories.push(...response.body); - } - }); - } + getUserStories() { + this.backendService.getUserstories().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.userstories.push(...response.body); + } + }); + } - getTaskStatus() { - this.backendService.getAllStatus().subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } else { - this.allStatus.push(...response.body); - } - }); - } + getTaskStatus() { + this.backendService.getAllStatus().subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } else { + this.allStatus.push(...response.body); + } + }); + } - createTaskStatus() { - this.backendService.postStatus(this.status).subscribe((response) => { - if (response.status > 399) { - alert('Fehler'); - } - }); - } + createTaskStatus() { + this.backendService.postStatus(this.status).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } + + deleteStatus() { + this.backendService.deleteStatus(this.status).subscribe((response) => { + if (response.status > 399) { + alert('Fehler'); + } + }); + } }