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">
<label for="Inhalt">Status</label>
<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
}}</option>
</select>
</div>
<div class="dropdown-divider"></div>
<div class="form-group">
<a class="dropdown-item" href="#">Neuer Status</a>
<a class="dropdown-item" href="#">Status löschen</a>
<a class="dropdown-item" href="#" (click)="createTaskStatus()">Neuer Status</a>
<a class="dropdown-item" href="#" (click)="deleteStatus()">Status löschen</a>
<input type="text" class="form-control"/>
</div>
</div>

View File

@ -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');
}
});
}
}