modified and added comments

This commit is contained in:
Michael 2020-07-15 17:09:47 +02:00
parent 7d78c14033
commit b21ba7f58c
3 changed files with 480 additions and 425 deletions

View File

@ -6,22 +6,20 @@ import { BackendService, ScrumSprint } from '../../services/backend.service';
@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 implements the logic for a popup window form to create and modify sprints.
// Class implements the logic for a popup window form to create and modify sprints. 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
) {}
// If no sprint exists a new one will be created. /**
// In other cases the sprint exists and gets modifiable. * If no sprint exists a new one will be created.
* In other cases the sprint exists and gets modifiable.
*/
ngOnInit(): void { ngOnInit(): void {
if (this.sprint === null || this.sprint === undefined) { if (this.sprint === null || this.sprint === undefined) {
this.sprint = { title: '', startDate: '', endDate: '' }; this.sprint = { title: '', startDate: '', endDate: '' };
@ -32,8 +30,10 @@ export class SprintFormComponent implements OnInit {
document.getElementById('titleField').focus(); document.getElementById('titleField').focus();
} }
// A new created sprint will be saved in backend (POST). /**
// If a sprint already exists, modifying results an update (PUT) to the backend. * A new created sprint will be saved in the backend (POST).
* If a sprint already exists, modifiying results an update (PUT) to the backend.
*/
onSubmit() { onSubmit() {
if (this.editing) { if (this.editing) {
this.backendService.putSprint(this.sprint).subscribe((response) => { this.backendService.putSprint(this.sprint).subscribe((response) => {
@ -56,7 +56,9 @@ export class SprintFormComponent implements OnInit {
this.activeModalService.close(this.sprint); this.activeModalService.close(this.sprint);
} }
// Closes the popup form window (by clicking "close button"). /**
* Closes the popup form window (by clicking "close button"):
*/
onClose() { onClose() {
this.activeModalService.dismiss(this.sprint); this.activeModalService.dismiss(this.sprint);
} }

View File

@ -9,7 +9,7 @@ import {
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';
@ -17,11 +17,10 @@ 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 implements the logic for a popup window form to create and modify tasks.
// Class implements the logic for a popup window form to create and modify tasks. class TaskFormComponent implements OnInit {
export class TaskFormComponent implements OnInit {
@Input() public task: ScrumTask; @Input() public task: ScrumTask;
public editing: boolean; public editing: boolean;
public creating: boolean; public creating: boolean;
@ -32,17 +31,16 @@ export class TaskFormComponent implements OnInit {
public allUser: any[] = []; public allUser: any[] = [];
public user: ScrumUser = { name: '' }; public user: ScrumUser = { name: '' };
constructor( constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {
private backendService: BackendService,
private activeModalService: NgbActiveModal
) {
this.getUserStories(); this.getUserStories();
this.getTaskStatus(); this.getTaskStatus();
this.getAllUsers(); this.getAllUsers();
} }
// If no task exists a new one will be created. /**
// In other cases the task exists and gets modifiable. * If no task exists a new on will be created.
* In other cases the task exists and gets modifiable.
*/
ngOnInit(): void { ngOnInit(): void {
if (this.task === null || this.task === undefined) { if (this.task === null || this.task === undefined) {
this.task = { title: '' }; this.task = { title: '' };
@ -56,8 +54,11 @@ export class TaskFormComponent implements OnInit {
document.getElementById('titleField').focus(); document.getElementById('titleField').focus();
this.getRelatedStory(); 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. /**
* A new created task will be saved in the backend (POST).
* If a task already exists, modifying results an update (PUT) to the backend.
*/
onSubmit() { onSubmit() {
if (this.editing) { if (this.editing) {
this.backendService.putTask(this.task).subscribe((response) => { this.backendService.putTask(this.task).subscribe((response) => {
@ -79,20 +80,22 @@ export class TaskFormComponent implements OnInit {
this.activeModalService.close(this.task); this.activeModalService.close(this.task);
} }
// Closes the popup form window (by clicking "close button"). /**
* Closes the popup form window (by clicking "close button").
*/
onClose() { onClose() {
this.activeModalService.dismiss(this.task); 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. * Getting the userstory which is related to a task.
* The related story will be shown in popup window of a task.
*/
getRelatedStory() { getRelatedStory() {
if (!this.task.userstoryId) { if (!this.task.userstoryId) {
return null; return null;
} }
this.backendService this.backendService.getUserstory(this.task.userstoryId).subscribe((response) => {
.getUserstory(this.task.userstoryId)
.subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} else { } else {
@ -101,7 +104,9 @@ export class TaskFormComponent implements OnInit {
}); });
} }
// Getting all userstories from backend to show in a dropdown in popup window. /**
* Getting all userstories from backend to show in a dropdown in popup window.
*/
getUserStories() { getUserStories() {
this.backendService.getUserstories().subscribe((response) => { this.backendService.getUserstories().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -112,7 +117,9 @@ export class TaskFormComponent implements OnInit {
}); });
} }
// Getting all available status from backend to list it in status-dropdown in popup window. /**
* Getting all available status from backend to list it in status-dropdown in popup window.
*/
getTaskStatus() { getTaskStatus() {
this.backendService.getAllStatus().subscribe((response) => { this.backendService.getAllStatus().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -123,8 +130,11 @@ export class TaskFormComponent 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 tasks. * 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.
* @param status Scrumstatus to store in the database
*/
createTaskStatus(status: ScrumStatus) { createTaskStatus(status: ScrumStatus) {
this.backendService.postStatus(status).subscribe((response) => { this.backendService.postStatus(status).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -137,6 +147,11 @@ export class TaskFormComponent implements OnInit {
// A custom status can even be deleted if not used anymore. // A custom status can even be deleted if not used anymore.
// This will remove the status from status-array. // This will remove the status from status-array.
/**
* A custom status can even be deleted if not used anymore.
* This will remove the status from status-array
* @param id the id of the chosen status
*/
deleteStatus(id: number) { deleteStatus(id: number) {
var status = this.allStatus.find((x) => x.id === id); var status = this.allStatus.find((x) => x.id === id);
this.backendService.deleteStatus(status).subscribe((response) => { this.backendService.deleteStatus(status).subscribe((response) => {
@ -152,12 +167,18 @@ export class TaskFormComponent implements OnInit {
}); });
} }
// Getting the values of the Priority enum to be shown in a dropdown in popup window. /**
* Getting the value of the priority enum to be shown in a dropdown in popup window.
*/
getAllPriorities(): Priority[] { getAllPriorities(): Priority[] {
return Object.values(Priority); return Object.values(Priority);
} }
// necessary????????????????????????????????????????????????????? // necessary?????????????????????????????????????????????????????
/**
* Shows the before choosen userstory in the userstory-field in the popup window
* @param id reference to the userstory object
*/
getUserstoryTitleById(id: number): string { getUserstoryTitleById(id: number): string {
if (!id) { if (!id) {
return null; return null;
@ -169,7 +190,10 @@ export class TaskFormComponent implements OnInit {
return story.title; return story.title;
} }
// Shows the before choosen status in the status-field in the popup window. /**
* Shows the before choosen status in the status-field in the popup window.
* @param id reference to the status object
*/
getStatusTitleById(id: number): string { getStatusTitleById(id: number): string {
if (!id) { if (!id) {
return null; return null;
@ -181,7 +205,9 @@ export class TaskFormComponent implements OnInit {
return status.title; return status.title;
} }
// Getting all taskboard users from backend to show in a dropdown in popup window. /**
* Getting all taskboard users from the backend to show in a dropdown in popup window.
*/
getAllUsers() { getAllUsers() {
this.backendService.getUsers().subscribe((response) => { this.backendService.getUsers().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -192,7 +218,10 @@ export class TaskFormComponent implements OnInit {
}); });
} }
// Shows the before assigned user in the author-field in the popup window. /**
* Shows the before assigned user in the author-field in the popup window.
* @param id reference to the author object
*/
getAuthorById(id: number): string { getAuthorById(id: number): string {
if (!id) { if (!id) {
return null; return null;

View File

@ -1,27 +1,16 @@
// Importing necessary components and interfaces. // Importing necessary components and interfaces.
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, ScrumUserstory, Priority } from '../../services/backend.service';
BackendService, import { ScrumTask, ScrumStatus, ScrumCategory, ScrumUser, ScrumProject } from '../../services/backend.service';
ScrumUserstory,
Priority,
} from '../../services/backend.service';
import {
ScrumTask,
ScrumStatus,
ScrumCategory,
ScrumUser,
ScrumProject,
} from '../../services/backend.service';
@Component({ @Component({
selector: 'app-userstory-form', selector: 'app-userstory-form',
templateUrl: './userstory-form.component.html', templateUrl: './userstory-form.component.html',
styleUrls: ['./userstory-form.component.css'], styleUrls: [ './userstory-form.component.css' ]
}) })
export // Class implements the logic for a popup window form to create and modify userstories.
// Class implements the logic for a popup window form to create and modify userstories. class UserstoryFormComponent implements OnInit {
export class UserstoryFormComponent implements OnInit {
@Input() public userstory: ScrumUserstory; @Input() public userstory: ScrumUserstory;
public allStatus: any[] = []; public allStatus: any[] = [];
public status: ScrumStatus = { title: '', description: '' }; public status: ScrumStatus = { title: '', description: '' };
@ -31,17 +20,16 @@ export class UserstoryFormComponent implements OnInit {
public category: ScrumCategory = { title: '' }; public category: ScrumCategory = { title: '' };
public editing: boolean; public editing: boolean;
constructor( constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {
private backendService: BackendService,
private activeModalService: NgbActiveModal
) {
this.getUserstoryStatus(); this.getUserstoryStatus();
this.getAllUsers(); this.getAllUsers();
this.getUserstoryCategory(); this.getUserstoryCategory();
} }
// If no userstory exists a new one will be created. /**
// In other cases the userstory exists and gets modifiable. * If no userstory exists a new one will be created.
* In other cases the userstory exists and gets modifiable.
*/
ngOnInit(): void { ngOnInit(): void {
if (this.userstory === null || this.userstory === undefined) { if (this.userstory === null || this.userstory === undefined) {
this.userstory = { title: '' }; this.userstory = { title: '' };
@ -52,8 +40,10 @@ export class UserstoryFormComponent implements OnInit {
document.getElementById('titleField').focus(); 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. * A new created userstory will be saved in the backend (POST).
* If a userstory already exists, modifying results an update (PUT) to the backend.
*/
onSubmit() { onSubmit() {
if (this.editing) { if (this.editing) {
this.backendService.putUserstory(this.userstory).subscribe((response) => { this.backendService.putUserstory(this.userstory).subscribe((response) => {
@ -62,9 +52,7 @@ export class UserstoryFormComponent implements OnInit {
} }
}); });
} else { } else {
this.backendService this.backendService.postUserstory(this.userstory).subscribe((response) => {
.postUserstory(this.userstory)
.subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
alert('Fehler'); alert('Fehler');
} else { } else {
@ -77,12 +65,16 @@ export class UserstoryFormComponent implements OnInit {
this.activeModalService.close(this.userstory); this.activeModalService.close(this.userstory);
} }
// Closes the popup form window (by clicking "close button"). /**
* Closes the popup form window (by clicking "close button").
*/
onClose() { onClose() {
this.activeModalService.dismiss(this.userstory); this.activeModalService.dismiss(this.userstory);
} }
// Getting all available status from backend to list it in status-dropdown in popup window. /**
* Getting all available status from backend to list it in status-dropdown in popup window.
*/
getUserstoryStatus() { getUserstoryStatus() {
this.backendService.getAllStatus().subscribe((response) => { this.backendService.getAllStatus().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -93,8 +85,11 @@ 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. * 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.
* @param status the status object which will be created
*/
createUserstoryStatus(status: ScrumStatus) { createUserstoryStatus(status: ScrumStatus) {
this.backendService.postStatus(status).subscribe((response) => { this.backendService.postStatus(status).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -105,8 +100,11 @@ export class UserstoryFormComponent implements OnInit {
}); });
} }
// A custom status can even be deleted if not used anymore. /**
// This will remove the status from status-array. * A custom status can even be deleted if not used anymore.
* This will remove the status from status-array
* @param id reference to the deletable status object
*/
deleteStatus(id: number) { deleteStatus(id: number) {
var status = this.allStatus.find((x) => x.id === id); var status = this.allStatus.find((x) => x.id === id);
this.backendService.deleteStatus(status).subscribe((response) => { this.backendService.deleteStatus(status).subscribe((response) => {
@ -122,12 +120,17 @@ export class UserstoryFormComponent implements OnInit {
}); });
} }
// Getting the values of the Priority enum to be shown in a dropdown in popup window. /**
* Getting the values of the Priority enum to be shown in a dropdown in popup window.
*/
getAllPriorities(): Priority[] { getAllPriorities(): Priority[] {
return Object.values(Priority); return Object.values(Priority);
} }
// Shows the before choosen status in the status-field in the popup window. /**
* Shows the before choosen status in the status-field in the popup window.
* @param id reference to the status object
*/
getStatusTitleById(id: number): string { getStatusTitleById(id: number): string {
if (!id) { if (!id) {
return null; return null;
@ -139,7 +142,9 @@ export class UserstoryFormComponent implements OnInit {
return status.title; return status.title;
} }
// Getting all taskboard users from backend to show in a dropdown in popup window. /**
* Getting all taskboard users from backend to show in a dropdown in popup window.
*/
getAllUsers() { getAllUsers() {
this.backendService.getUsers().subscribe((response) => { this.backendService.getUsers().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -150,7 +155,10 @@ export class UserstoryFormComponent implements OnInit {
}); });
} }
// Shows the before assigned user in the author-field in the popup window. /**
* Shows the before assigned user in the author-field in the popup window.
* @param id reference to the author object
*/
getAuthorById(id: number): string { getAuthorById(id: number): string {
if (!id) { if (!id) {
return null; return null;
@ -162,7 +170,9 @@ export class UserstoryFormComponent implements OnInit {
return user.name; return user.name;
} }
// Getting all available categories from backend to list it in status-dropdown in popup window. /**
* Getting all available categories from backend to list it in status-dropdown in popup window.
*/
getUserstoryCategory() { getUserstoryCategory() {
this.backendService.getCategories().subscribe((response) => { this.backendService.getCategories().subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -175,6 +185,11 @@ export class UserstoryFormComponent implements OnInit {
// If desired a new arbitrary category can be created, which will be stored in an array. // If desired a new arbitrary category can be created, which will be stored in an array.
// The new category is available to all userstories. // The new category is available to all userstories.
/**
* If desired a new arbitrary category can be created, which will be stored in an array.
* The new category is available to all userstories.
* @param category the category object which will be created
*/
createUserstoryCategory(category: ScrumCategory) { createUserstoryCategory(category: ScrumCategory) {
this.backendService.postCategory(category).subscribe((response) => { this.backendService.postCategory(category).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -187,6 +202,11 @@ export class UserstoryFormComponent implements OnInit {
// A custom category can even be deleted if not used anymore. // A custom category can even be deleted if not used anymore.
// This will remove the category from category-array. // This will remove the category from category-array.
/**
* A custom category can even be deleted if not used anymore.
* This will remove the category from category-array.
* @param id reference to the deletable category
*/
deleteCategory(id: number) { deleteCategory(id: number) {
var category = this.allCategories.find((x) => x.id === id); var category = this.allCategories.find((x) => x.id === id);
this.backendService.deleteCategory(category).subscribe((response) => { this.backendService.deleteCategory(category).subscribe((response) => {
@ -201,7 +221,11 @@ export class UserstoryFormComponent implements OnInit {
this.userstory.categoryId = null; this.userstory.categoryId = null;
}); });
} }
// Shows the before choosen category in the category-field in the popup window.
/**
* Shows the before choosen category in the category-field in the popup window.
* @param id reference to the category
*/
getCategoryById(id: number): string { getCategoryById(id: number): string {
if (!id) { if (!id) {
return null; return null;