Status dropdown now w/ add and delete working
This commit is contained in:
parent
5b0e1a24c7
commit
18160c4127
@ -53,21 +53,17 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div ngbDropdown class="dropdown">
|
<div ngbDropdown class="dropdown">
|
||||||
<button ngbDropdownToggle class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<button ngbDropdownToggle class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
Status
|
Status: {{task.statusid}}
|
||||||
</button>
|
</button>
|
||||||
<div ngbDropdownMenu class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
<div ngbDropdownMenu class="dropdown-menu" aria-labelledby="dropdownMenu2">
|
||||||
<label for="Inhalt">Status wählen</label>
|
<label for="Inhalt">Status wählen</label>
|
||||||
<select class="custom-select mr-sm-2" id="prio" required name="prio" [(ngModel)]="task.statusid">
|
<option ngbDropdownItem *ngFor="let status of allStatus" (click)="task.statusid = status.id">{{ status.title }}</option>
|
||||||
<option *ngFor="let status of allStatus" [value]="status.id">{{
|
|
||||||
status.title
|
|
||||||
}}</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<label for="Inhalt">Neuer Status</label>
|
<label for="Inhalt">Neuer Status</label>
|
||||||
<input type="text" class="form-control" [(ngModel)]="status.title">
|
<input #statusname type="text" id="statusname" class="form-control" (change)="status.title=statusname.value">
|
||||||
<button ngbDropdownItem class="dropdown-item" type="button" (click)="createTaskStatus()">Status anlegen</button>
|
<button ngbDropdownItem class="dropdown-item" type="button" (click)="createTaskStatus(status)">Status anlegen</button>
|
||||||
<button ngbDropdownItem class="dropdown-item" type="button" (click)="deleteStatus()">Status löschen</button>
|
<button ngbDropdownItem class="dropdown-item" type="button" (click)="deleteStatus(task.statusid)">Status löschen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
|
@ -25,7 +25,7 @@ export class TaskFormComponent implements OnInit {
|
|||||||
public userstoryId: string;
|
public userstoryId: string;
|
||||||
public userstories: any[] = [];
|
public userstories: any[] = [];
|
||||||
public allStatus: any[] = [];
|
public allStatus: any[] = [];
|
||||||
public status: ScrumStatus = { title: '', description: '' };
|
public status: ScrumStatus = {title: "", description: ""};
|
||||||
|
|
||||||
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {
|
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {
|
||||||
this.getUserStories();
|
this.getUserStories();
|
||||||
@ -97,19 +97,32 @@ export class TaskFormComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createTaskStatus() {
|
createTaskStatus(status:ScrumStatus) {
|
||||||
this.backendService.postStatus(this.status).subscribe((response) => {
|
this.backendService.postStatus(status).subscribe((response) => {
|
||||||
if (response.status > 399) {
|
if (response.status > 399) {
|
||||||
alert('Fehler');
|
alert('Fehler');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.allStatus.push(response.body);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteStatus() {
|
deleteStatus(id: number) {
|
||||||
this.backendService.deleteStatus(this.status).subscribe((response) => {
|
var status = this.allStatus.find((x) => x.id === id);
|
||||||
|
this.backendService.deleteStatus(status).subscribe((response) => {
|
||||||
if (response.status > 399) {
|
if (response.status > 399) {
|
||||||
alert('Fehler');
|
alert('Fehler');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const index = this.allStatus.indexOf(status);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.allStatus.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.task.statusid=null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user