created delete and create function

This commit is contained in:
Michael 2020-06-30 16:13:57 +02:00
parent 42c3ffdda7
commit e99e0aeb69
2 changed files with 95 additions and 90 deletions

View File

@ -51,15 +51,15 @@
<div class="form-group"> <div class="form-group">
<label for="Inhalt">Status</label> <label for="Inhalt">Status</label>
<select class="form-control custom-select mr-sm-2" id="prio" required name="prio" [(ngModel)]="task.statusid"> <select class="form-control custom-select mr-sm-2" id="prio" required name="prio" [(ngModel)]="task.statusid">
<option *ngFor="let status of allStatus" [value]="status.title">{{ <option *ngFor="let status of allStatus" [value]="status.id">{{
status.title status.title
}}</option> }}</option>
</select> </select>
</div> </div>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<div class="form-group"> <div class="form-group">
<a class="dropdown-item" href="#">Neuer Status</a> <a class="dropdown-item" href="#" (click)="createTaskStatus()">Neuer Status</a>
<a class="dropdown-item" href="#">Status löschen</a> <a class="dropdown-item" href="#" (click)="deleteStatus()">Status löschen</a>
<input type="text" class="form-control"/> <input type="text" class="form-control"/>
</div> </div>
</div> </div>

View File

@ -1,106 +1,111 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { import {
BackendService, BackendService,
ScrumTask, ScrumTask,
Priority, Priority,
ScrumStatus, ScrumStatus,
ScrumCategory, ScrumCategory,
ScrumUser, ScrumUser,
ScrumProject, ScrumProject,
ScrumUserstory, ScrumUserstory
} from '../services/backend.service'; } from '../services/backend.service';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { HttpResponse } from '@angular/common/http'; import { HttpResponse } from '@angular/common/http';
@Component({ @Component({
selector: 'app-task-form', selector: 'app-task-form',
templateUrl: './task-form.component.html', templateUrl: './task-form.component.html',
styleUrls: ['./task-form.component.css'], styleUrls: [ './task-form.component.css' ]
}) })
export class TaskFormComponent implements OnInit { export class TaskFormComponent implements OnInit {
@Input() public task: ScrumTask; @Input() public task: ScrumTask;
public editing: Boolean; public editing: Boolean;
public userstoryId: string; public userstoryId: string;
public userstories: any[] = []; public userstories: any[] = [];
public allStatus: any[] = []; public allStatus: any[] = [];
public status: ScrumStatus; public status: ScrumStatus;
constructor( constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {
private backendService: BackendService, this.getUserStories();
private activeModalService: NgbActiveModal this.getTaskStatus();
) { }
this.getUserStories();
this.getTaskStatus();
}
ngOnInit(): void { ngOnInit(): void {
if (this.task === null || this.task === undefined) { if (this.task === null || this.task === undefined) {
this.task = { title: '' }; this.task = { title: '' };
this.editing = false; this.editing = false;
} else { } else {
this.editing = true; this.editing = true;
} }
document.getElementById('titleField').focus(); document.getElementById('titleField').focus();
this.getRelatedStory(); this.getRelatedStory();
} }
onSubmit() { onSubmit() {
if (this.editing) { if (this.editing) {
this.backendService.putTask(this.task).subscribe((response) => { this.backendService.putTask(this.task).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} }
}); });
} else { } else {
this.backendService.postTask(this.task).subscribe((response) => { this.backendService.postTask(this.task).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} }
}); });
} }
this.activeModalService.close(this.task); this.activeModalService.close(this.task);
} }
onClose() { onClose() {
this.activeModalService.dismiss(this.task); this.activeModalService.dismiss(this.task);
} }
getRelatedStory() { getRelatedStory() {
this.backendService.getUserstory(2).subscribe((response) => { this.backendService.getUserstory(2).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} else { } else {
this.userstoryId = response.body.title; this.userstoryId = response.body.title;
} }
}); });
} }
getUserStories() { getUserStories() {
this.backendService.getUserstories().subscribe((response) => { this.backendService.getUserstories().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} else { } else {
this.userstories.push(...response.body); this.userstories.push(...response.body);
} }
}); });
} }
getTaskStatus() { getTaskStatus() {
this.backendService.getAllStatus().subscribe((response) => { this.backendService.getAllStatus().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} else { } else {
this.allStatus.push(...response.body); this.allStatus.push(...response.body);
} }
}); });
} }
createTaskStatus() { createTaskStatus() {
this.backendService.postStatus(this.status).subscribe((response) => { this.backendService.postStatus(this.status).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} }
}); });
} }
deleteStatus() {
this.backendService.deleteStatus(this.status).subscribe((response) => {
if (response.status > 399) {
alert('Fehler');
}
});
}
} }