added userstory select for tasks

This commit is contained in:
Michael 2020-06-29 22:47:52 +02:00
parent 75b964402a
commit 74418ff0dd
3 changed files with 114 additions and 104 deletions

View File

@ -1,62 +1,60 @@
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,
ScrumSprint ScrumSprint
} 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: './sprint-form.component.html', templateUrl: './sprint-form.component.html',
styleUrls: ['./sprint-form.component.css'], styleUrls: [ './sprint-form.component.css' ]
}) })
export class SprintFormComponent implements OnInit { export class SprintFormComponent implements OnInit {
@Input() public sprint: ScrumSprint; @Input() public sprint: ScrumSprint;
public editing: Boolean; public editing: Boolean;
public sprintid: string; public sprintid: string;
constructor( constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {}
private backendService: BackendService,
private activeModalService: NgbActiveModal
) { }
ngOnInit(): void { ngOnInit(): void {
if (this.sprint === null || this.sprint === undefined) { if (this.sprint === null || this.sprint === undefined) {
this.sprint = { title: '', startDate: new Date(), endDate: new Date(), project: 0 }; //project id: static counter? this.sprint = { title: '', startDate: new Date(), endDate: new Date(), project: 0 }; //project id: static counter?
this.editing = false; this.editing = false;
} else { } else {
this.editing = true; this.editing = true;
} }
document.getElementById('titleField').focus(); document.getElementById('titleField').focus();
} }
onSubmit() { onSubmit() {
if (this.editing) { if (this.editing) {
this.backendService.putSprint(this.sprint).subscribe((response) => { this.backendService.putSprint(this.sprint).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} }
}); });
} else { } else {
this.backendService.postSprint(this.sprint).subscribe((response) => { this.backendService.postSprint(this.sprint).subscribe((response) => {
if (response.status > 399) { console.log('Sprint gespeichert!');
alert('Fehler'); if (response.status > 399) {
} alert('Fehler');
}); }
} });
this.activeModalService.close(this.sprint); }
} this.activeModalService.close(this.sprint);
}
onClose() { onClose() {
this.activeModalService.dismiss(this.sprint); this.activeModalService.dismiss(this.sprint);
} }
} }

View File

@ -7,7 +7,10 @@
<tr> <tr>
<h6 class="modal-caption text-muted"> Gehört zu Story: <a href="#" id="userstoryTitle">{{this.userstoryId}}</a></h6> <h6 class="modal-caption text-muted"> Gehört zu Story: <a href="#" id="userstoryTitle">{{this.userstoryId}}</a></h6>
</tr> </tr>
<!--getUserstory fehlt noch--> <select class="form-control custom-select mr-sm-2" id="prio" required name="prio"
[(ngModel)]="task.priority" *ngFor="let userstory of userstories">
<option value="low">{{userstory}}</option>
</select>
</table> </table>
<button (click)="onClose()" type="button" class="close" aria-label="Close"> <button (click)="onClose()" type="button" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>

View File

@ -1,72 +1,81 @@
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[];
constructor( constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {}
private backendService: BackendService,
private activeModalService: NgbActiveModal
) {}
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();
} this.getUserStories();
}
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() {
this.backendService.getUserstories().subscribe((response) => {
if (response.status > 399) {
alert('Fehler');
} else {
this.userstories.push(...response.body);
}
});
}
} }