code cleanup and comments.

This commit is contained in:
test 2020-07-07 13:18:53 +02:00
parent 62730d53b6
commit f64f7439ea
5 changed files with 72 additions and 44 deletions

View File

@ -1,4 +1,4 @@
<!--Popup form to create a new sprint-->
<!--Popup form to create an modify sprints-->
<div class="card" style="width: 100%;">
<div class="container">

View File

@ -1,3 +1,5 @@
<!--Popup form to create and modify a task-->
<div class="card" style="width: 100%;">
<div class="container">
<div class="card-body">
@ -46,7 +48,6 @@
{{p}}</option>
</div>
</div>
<!-- Section to choose, create or delete a random status for the userstory. -->
<div class="form-group">
<div ngbDropdown class="dropdown" [autoClose]="false">
<button ngbDropdownToggle class="btn btn-secondary dropdown-toggle" type="button"
@ -71,7 +72,7 @@
</div>
</div>
<div class="dropdown-menu">
<select class="form-control custom-select mr-sm-2" id="prio" required name="prio"
<select class="form-control custom-select mr-sm-2" id="status" required name="status"
[(ngModel)]="task.statusid">
<option *ngFor="let status of allStatus" [value]="status.id">{{
status.title
@ -79,7 +80,6 @@
</select>
</div>
</div>
<!-- Section to choose an author for the userstory. -->
<div class="form-group">
<div ngbDropdown class="dropdown" [autoClose]="true">
<button ngbDropdownToggle class="btn btn-secondary dropdown-toggle" type="button"
@ -94,7 +94,7 @@
</div>
</div>
<div class="dropdown-menu">
<select class="form-control custom-select mr-sm-2" id="prio" required name="prio"
<select class="form-control custom-select mr-sm-2" id="assignedto" required name="assignedto"
[(ngModel)]="task.assignedtoid">
<option *ngFor="let user of allUser" [value]="user.id">{{
user.name
@ -115,4 +115,4 @@
</form>
</div>
</div>
</div>
</div>

View File

@ -1,3 +1,4 @@
// Importing necessary components and interfaces.
import { Component, OnInit, Input } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import {
@ -16,8 +17,10 @@ import { HttpResponse } from '@angular/common/http';
@Component({
selector: 'app-task-form',
templateUrl: './task-form.component.html',
styleUrls: [ './task-form.component.css' ]
styleUrls: ['./task-form.component.css']
})
// Class implements the logic for a popup window form to create and modify tasks.
export class TaskFormComponent implements OnInit {
@Input() public task: ScrumTask;
public editing: boolean;
@ -25,7 +28,7 @@ export class TaskFormComponent implements OnInit {
public userstoryId: string;
public userstories: any[] = [];
public allStatus: any[] = [];
public status: ScrumStatus = {title: "", description: ""};
public status: ScrumStatus = { title: "", description: "" };
public allUser: any[] = [];
public user: ScrumUser = { name: "" };
@ -35,6 +38,8 @@ export class TaskFormComponent implements OnInit {
this.getAllUsers();
}
// If no task exists a new one will be created.
// In other cases the task exists and gets modifiable.
ngOnInit(): void {
if (this.task === null || this.task === undefined) {
this.task = { title: '' };
@ -48,7 +53,8 @@ export class TaskFormComponent implements OnInit {
document.getElementById('titleField').focus();
this.getRelatedStory();
}
// A new created task will be saved in backend (POST).
// If a task already exists, modifying results an update (PUT) to the backend.
onSubmit() {
if (this.editing) {
this.backendService.putTask(this.task).subscribe((response) => {
@ -63,16 +69,19 @@ export class TaskFormComponent implements OnInit {
}
});
}
// Closes the popup window after submitting/canceling.
this.activeModalService.close(this.task);
}
// Closes the popup form window (by clicking "close button").
onClose() {
this.activeModalService.dismiss(this.task);
}
// Getting the userstory which is related to a task.
// The related story will be shown in popup window of a task.
getRelatedStory() {
if(!this.task.userstoryid)
{
if (!this.task.userstoryid) {
return null;
}
this.backendService.getUserstory(this.task.userstoryid).subscribe((response) => {
@ -84,6 +93,7 @@ export class TaskFormComponent implements OnInit {
});
}
// Getting all userstories from backend to show in a dropdown in popup window.
getUserStories() {
this.backendService.getUserstories().subscribe((response) => {
if (response.status > 399) {
@ -94,6 +104,7 @@ export class TaskFormComponent implements OnInit {
});
}
// Getting all available status from backend to list it in status-dropdown in popup window.
getTaskStatus() {
this.backendService.getAllStatus().subscribe((response) => {
if (response.status > 399) {
@ -104,63 +115,67 @@ export class TaskFormComponent implements OnInit {
});
}
createTaskStatus(status:ScrumStatus) {
// If desired a new arbitrary status (such as "Waiting") can be created, which will be stored in an array.
// The new status is available to all tasks.
createTaskStatus(status: ScrumStatus) {
this.backendService.postStatus(status).subscribe((response) => {
if (response.status > 399) {
alert('Fehler');
}
else
{
else {
this.allStatus.push(response.body);
}
});
}
// A custom status can even be deleted if not used anymore.
// This will remove the status from status-array.
deleteStatus(id: number) {
var status = this.allStatus.find((x) => x.id === id);
this.backendService.deleteStatus(status).subscribe((response) => {
if (response.status > 399) {
alert('Fehler');
}
else
{
else {
const index = this.allStatus.indexOf(status);
if (index !== -1) {
this.allStatus.splice(index, 1);
this.allStatus.splice(index, 1);
}
}
this.task.statusid=null;
this.task.statusid = null;
});
}
// Getting the values of the Priority enum to be shown in a dropdown in popup window.
getAllPriorities(): Priority[] {
return Object.values(Priority);
}
getUserstoryTitleById(id: number): string{
// necessary?????????????????????????????????????????????????????
getUserstoryTitleById(id: number): string {
if (!id) {
return null;
}
}
var story = this.userstories.find((x) => x.id === id);
if (!story) {
return null;
}
}
return story.title;
}
getStatusTitleById(id: number) :string{
// Shows the before choosen status in the status-field in the popup window.
getStatusTitleById(id: number): string {
if (!id) {
return null;
}
}
var status = this.allStatus.find((x) => x.id === id);
if (!status) {
return null;
}
}
return status.title;
}
// Methods for choosing creator of a userstory.
// Getting all taskboard users from backend to show in a dropdown in popup window.
getAllUsers() {
this.backendService.getUsers().subscribe((response) => {
if (response.status > 399) {
@ -171,6 +186,7 @@ export class TaskFormComponent implements OnInit {
});
}
// Shows the before assigned user in the author-field in the popup window.
getAuthorById(id: number): string {
if (!id) {
return null;
@ -181,4 +197,4 @@ export class TaskFormComponent implements OnInit {
}
return user.name;
}
}
}

View File

@ -1,3 +1,5 @@
<!--Popup form to create and modify a task-->
<div class="card" style="width: 100%;">
<div class="container">
<div class="card-body">
@ -36,8 +38,6 @@
{{p}}</option>
</div>
</div>
<!-- Section to choose, create or delete a random status for the userstory. -->
<div class="form-group">
<div ngbDropdown class="dropdown" [autoClose]="false">
<button ngbDropdownToggle class="btn btn-secondary dropdown-toggle" type="button"
@ -70,8 +70,6 @@
</select>
</div>
</div>
<!-- Section to choose, create or delete a random category for the userstory. -->
<div class="form-group">
<div ngbDropdown class="dropdown" [autoClose]="false">
<button ngbDropdownToggle class="btn btn-secondary dropdown-toggle" type="button"
@ -104,8 +102,6 @@
</select>
</div>
</div>
<!-- Section to choose an author for the userstory. -->
<div class="form-group">
<div ngbDropdown class="dropdown" [autoClose]="true">
<button ngbDropdownToggle class="btn btn-secondary dropdown-toggle" type="button"

View File

@ -1,3 +1,4 @@
// Importing necessary components and interfaces.
import { Component, OnInit, Input } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { BackendService, ScrumUserstory, Priority } from '../services/backend.service';
@ -14,6 +15,8 @@ import {
templateUrl: './userstory-form.component.html',
styleUrls: ['./userstory-form.component.css']
})
// Class implements the logic for a popup window form to create and modify userstories.
export class UserstoryFormComponent implements OnInit {
@Input() public userstory: ScrumUserstory;
public allStatus: any[] = [];
@ -21,16 +24,17 @@ export class UserstoryFormComponent implements OnInit {
public allUser: any[] = [];
public user: ScrumUser = { name: "" };
public allCategories: any[] = [];
public category: ScrumCategory = { title: ""};
public category: ScrumCategory = { title: "" };
private editing: boolean;
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {
this.getUserstoryStatus();
this.getAllUsers();
this.getUserstoryCategory();
}
// If no userstory exists a new one will be created.
// In other cases the userstory exists and gets modifiable.
ngOnInit(): void {
if (this.userstory === null || this.userstory === undefined) {
this.userstory = { title: '' };
@ -41,6 +45,8 @@ export class UserstoryFormComponent implements OnInit {
document.getElementById('titleField').focus();
}
// A new created userstory will be saved in backend (POST).
// If a userstory already exists, modifying results an update (PUT) to the backend.
onSubmit() {
if (this.editing) {
this.backendService.putUserstory(this.userstory).subscribe((response) => {
@ -55,14 +61,16 @@ export class UserstoryFormComponent implements OnInit {
}
});
}
// Closes the popup window after submitting/canceling.
this.activeModalService.close(this.userstory);
}
// Closes the popup form window (by clicking "close button").
onClose() {
this.activeModalService.dismiss(this.userstory);
}
// Methods for adding, choosing and deleting random status tags.
// Getting all available status from backend to list it in status-dropdown in popup window.
getUserstoryStatus() {
this.backendService.getAllStatus().subscribe((response) => {
if (response.status > 399) {
@ -73,6 +81,8 @@ export class UserstoryFormComponent implements OnInit {
});
}
// If desired a new arbitrary status (such as "Waiting") can be created, which will be stored in an array.
// The new status is available to all userstories.
createUserstoryStatus(status: ScrumStatus) {
this.backendService.postStatus(status).subscribe((response) => {
if (response.status > 399) {
@ -84,6 +94,8 @@ export class UserstoryFormComponent implements OnInit {
});
}
// A custom status can even be deleted if not used anymore.
// This will remove the status from status-array.
deleteStatus(id: number) {
var status = this.allStatus.find((x) => x.id === id);
this.backendService.deleteStatus(status).subscribe((response) => {
@ -100,10 +112,12 @@ export class UserstoryFormComponent implements OnInit {
});
}
// Getting the values of the Priority enum to be shown in a dropdown in popup window.
getAllPriorities(): Priority[] {
return Object.values(Priority);
}
// Shows the before choosen status in the status-field in the popup window.
getStatusTitleById(id: number): string {
if (!id) {
return null;
@ -115,8 +129,7 @@ export class UserstoryFormComponent implements OnInit {
return status.title;
}
// Methods for choosing creator of a userstory.
// Getting all taskboard users from backend to show in a dropdown in popup window.
getAllUsers() {
this.backendService.getUsers().subscribe((response) => {
if (response.status > 399) {
@ -127,6 +140,7 @@ export class UserstoryFormComponent implements OnInit {
});
}
// Shows the before assigned user in the author-field in the popup window.
getAuthorById(id: number): string {
if (!id) {
return null;
@ -138,8 +152,7 @@ export class UserstoryFormComponent implements OnInit {
return user.name;
}
// Methods for creating, choosing and deleting categories for a userstory.
// Getting all available categories from backend to list it in status-dropdown in popup window.
getUserstoryCategory() {
this.backendService.getCategories().subscribe((response) => {
if (response.status > 399) {
@ -150,6 +163,8 @@ export class UserstoryFormComponent implements OnInit {
});
}
// If desired a new arbitrary category can be created, which will be stored in an array.
// The new category is available to all userstories.
createUserstoryCategory(category: ScrumCategory) {
this.backendService.postCategory(category).subscribe((response) => {
if (response.status > 399) {
@ -161,6 +176,8 @@ export class UserstoryFormComponent implements OnInit {
});
}
// A custom category can even be deleted if not used anymore.
// This will remove the category from category-array.
deleteCategory(id: number) {
var category = this.allCategories.find((x) => x.id === id);
this.backendService.deleteCategory(category).subscribe((response) => {
@ -176,7 +193,7 @@ export class UserstoryFormComponent implements OnInit {
this.userstory.categoryid = null;
});
}
// Shows the before choosen category in the category-field in the popup window.
getCategoryById(id: number): string {
if (!id) {
return null;
@ -187,5 +204,4 @@ export class UserstoryFormComponent implements OnInit {
}
return category.title;
}
}
}