Added comments to table component

This commit is contained in:
Nicolai Ort 2020-07-10 22:33:55 +02:00
parent 1445d5f8e1
commit 3874a34489

View File

@ -25,11 +25,16 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
public users: ScrumUser[] = [];
public categories: ScrumCategory[] = [];
/**
* Constructor that establishes the initial backend communication.
* @param backendService backendService object for backend communication
* @param modalService angular modalService to handle modals for the Form popups
* @param route route object to extract parameters from
*/
constructor(
private backendService: BackendService,
private modalService: NgbModal,
protected route: ActivatedRoute,
private router: Router
) {
super(route);
@ -64,6 +69,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
}
//#region getters
/**
* Returns a filtered list of all tasks that have a selected priority or belong to a certain userstory.
* If no pritority or userstory to be filtered for is defined it just returns all tasks.
*/
public get filteredItems() {
return this.items.filter(
(task) =>
@ -72,6 +81,11 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
(this.filterPriority === null || task.priority === this.filterPriority)
);
}
/**
* Returns the title of the status that has the provided id.
* @param id id of the searched status
*/
getStatusTitleById(id) {
var status = this.status.find((x) => x.id === id);
if (!status) {
@ -80,6 +94,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
return status.title;
}
/**
* Returns the name of the iser that has the provided id.
* @param id id of the searched user
*/
getUserNameById(id) {
var user = this.users.find((x) => x.id === id);
if (!user) {
@ -88,6 +106,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
return user.name;
}
/**
* Returns the title of the category that has the provided id.
* @param id id of the searched category
*/
getCategoryTitleById(id) {
var category = this.categories.find((x) => x.id === id);
if (!category) {
@ -99,6 +121,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
//#endregion getters
//#region taskTableFunctions
/**
* Deletes a task by calling the delete method via the backendService and removing it from the tabel's items array.
* @param userstory task that will be deleted
*/
public deleteTask(task: ScrumTask) {
this.backendService.deleteTask(task).subscribe((response) => {
if (response.status > 399) {
@ -113,22 +139,39 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
//#endregion taskTableFunctions
//#region sorters
/**
* Sorts the tabel's items by priority.
*/
sortByPrio() {
this.doNumericSort('priority', (task) =>
getNumberForPriority(task.priority)
);
}
/**
* Sorts the tabel's items by userstoryid.
*/
sortByTasks() {
this.doNumericSort('userstory', (task) => task.userstoryid);
}
/**
* Sorts the tabel's items by statusid
*/
sortByStatus() {
this.doNumericSort('statusid', (task) => task.statusid);
}
/**
* Sorts the tabel's items by assignedtoid
*/
sortByAssigned() {
this.doNumericSort('assignedtoid', (task) => task.assignedtoid);
}
/**
* Sorts the tabel's items by categoryid
*/
sortByCategory() {
this.doNumericSort('categoryid', (task) => task.categoryid);
}
@ -136,6 +179,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
//#region modals
/**
* Opens a TaskForm popup for editing a existing task or creating a new one.
* @param editTask optional: task to edit (only needed if a task should be edited, not newly created)
*/
public openTaskForm(editTask?: ScrumTask) {
const modalRef = this.modalService.open(TaskFormComponent, {
backdrop: 'static',