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 users: ScrumUser[] = [];
public categories: ScrumCategory[] = []; 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( constructor(
private backendService: BackendService, private backendService: BackendService,
private modalService: NgbModal, private modalService: NgbModal,
protected route: ActivatedRoute, protected route: ActivatedRoute,
private router: Router
) { ) {
super(route); super(route);
@ -64,6 +69,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
} }
//#region getters //#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() { public get filteredItems() {
return this.items.filter( return this.items.filter(
(task) => (task) =>
@ -72,6 +81,11 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
(this.filterPriority === null || task.priority === this.filterPriority) (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) { getStatusTitleById(id) {
var status = this.status.find((x) => x.id === id); var status = this.status.find((x) => x.id === id);
if (!status) { if (!status) {
@ -80,6 +94,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
return status.title; return status.title;
} }
/**
* Returns the name of the iser that has the provided id.
* @param id id of the searched user
*/
getUserNameById(id) { getUserNameById(id) {
var user = this.users.find((x) => x.id === id); var user = this.users.find((x) => x.id === id);
if (!user) { if (!user) {
@ -88,6 +106,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
return user.name; return user.name;
} }
/**
* Returns the title of the category that has the provided id.
* @param id id of the searched category
*/
getCategoryTitleById(id) { getCategoryTitleById(id) {
var category = this.categories.find((x) => x.id === id); var category = this.categories.find((x) => x.id === id);
if (!category) { if (!category) {
@ -99,6 +121,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
//#endregion getters //#endregion getters
//#region taskTableFunctions //#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) { public deleteTask(task: ScrumTask) {
this.backendService.deleteTask(task).subscribe((response) => { this.backendService.deleteTask(task).subscribe((response) => {
if (response.status > 399) { if (response.status > 399) {
@ -113,22 +139,39 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
//#endregion taskTableFunctions //#endregion taskTableFunctions
//#region sorters //#region sorters
/**
* Sorts the tabel's items by priority.
*/
sortByPrio() { sortByPrio() {
this.doNumericSort('priority', (task) => this.doNumericSort('priority', (task) =>
getNumberForPriority(task.priority) getNumberForPriority(task.priority)
); );
} }
/**
* Sorts the tabel's items by userstoryid.
*/
sortByTasks() { sortByTasks() {
this.doNumericSort('userstory', (task) => task.userstoryid); this.doNumericSort('userstory', (task) => task.userstoryid);
} }
/**
* Sorts the tabel's items by statusid
*/
sortByStatus() { sortByStatus() {
this.doNumericSort('statusid', (task) => task.statusid); this.doNumericSort('statusid', (task) => task.statusid);
} }
/**
* Sorts the tabel's items by assignedtoid
*/
sortByAssigned() { sortByAssigned() {
this.doNumericSort('assignedtoid', (task) => task.assignedtoid); this.doNumericSort('assignedtoid', (task) => task.assignedtoid);
} }
/**
* Sorts the tabel's items by categoryid
*/
sortByCategory() { sortByCategory() {
this.doNumericSort('categoryid', (task) => task.categoryid); this.doNumericSort('categoryid', (task) => task.categoryid);
} }
@ -136,6 +179,10 @@ export class TaskTableComponent extends TableComponentBase<ScrumTask> {
//#region modals //#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) { public openTaskForm(editTask?: ScrumTask) {
const modalRef = this.modalService.open(TaskFormComponent, { const modalRef = this.modalService.open(TaskFormComponent, {
backdrop: 'static', backdrop: 'static',