Added comments to the table component base
This commit is contained in:
parent
5d636a7cb0
commit
cf722381d6
|
@ -9,6 +9,10 @@ export abstract class TableComponentBase<T extends ScrumTask | ScrumUserstory |
|
|||
public highlightId: number;
|
||||
protected route: ActivatedRoute;
|
||||
|
||||
/**
|
||||
* Constructor that handels ParamMap extraction from given route and calls the applyFilterParameters method with the extracted ParamMap.
|
||||
* @param route ActivatedRoute object to get ParamMap from.
|
||||
*/
|
||||
public constructor(route: ActivatedRoute)
|
||||
{
|
||||
this.route = route;
|
||||
|
@ -17,12 +21,21 @@ export abstract class TableComponentBase<T extends ScrumTask | ScrumUserstory |
|
|||
}
|
||||
|
||||
//#region getters
|
||||
/**
|
||||
* Returns a string array containing all possible values of the enum Priority.
|
||||
*/
|
||||
public getAllPriorities(): string[] {
|
||||
return Object.values(Priority);
|
||||
}
|
||||
//#endregion getters
|
||||
|
||||
//#region tableFunctions
|
||||
|
||||
/**
|
||||
* Parses ParamMap from url (route) and sets parsed params accordingly.
|
||||
* Only used to extract the id from the ParamMap to highlight a certain item.
|
||||
* @param params ParamMap read from url
|
||||
*/
|
||||
private applyFilterParameters(params: ParamMap) {
|
||||
if (params.has('id')) {
|
||||
this.highlightId = parseInt(params.get('id'));
|
||||
|
@ -31,6 +44,12 @@ export abstract class TableComponentBase<T extends ScrumTask | ScrumUserstory |
|
|||
//#endregion tableFunctions
|
||||
|
||||
//#region sorters
|
||||
|
||||
/**
|
||||
* Sorts items by number of a provided kay
|
||||
* @param by TODO:
|
||||
* @param key property/key to sort the items by
|
||||
*/
|
||||
protected doNumericSort(by: string, key: (item: T) => number) {
|
||||
if (this.sortBy === by) {
|
||||
this.sortDescending = !this.sortDescending;
|
||||
|
@ -44,6 +63,11 @@ export abstract class TableComponentBase<T extends ScrumTask | ScrumUserstory |
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts items by string of a provided kay
|
||||
* @param by TODO:
|
||||
* @param key property/key to sort the items by
|
||||
*/
|
||||
protected doStringSort(by: string, key: (item: T) => string) {
|
||||
if (this.sortBy === by) {
|
||||
this.sortDescending = !this.sortDescending;
|
||||
|
@ -57,6 +81,11 @@ export abstract class TableComponentBase<T extends ScrumTask | ScrumUserstory |
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts items by date of a provided kay
|
||||
* @param by TODO:
|
||||
* @param key property/key to sort the items by
|
||||
*/
|
||||
protected doDateSort(by: string, key: (item: T) => Date) {
|
||||
if (this.sortBy === by) {
|
||||
this.sortDescending = !this.sortDescending;
|
||||
|
@ -70,10 +99,16 @@ export abstract class TableComponentBase<T extends ScrumTask | ScrumUserstory |
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts this tabel's items by id
|
||||
*/
|
||||
public sortById() {
|
||||
this.doNumericSort('id', (obj) => obj.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts this tabel's items by title
|
||||
*/
|
||||
public sortByTitle() {
|
||||
this.doStringSort('title', (obj) => obj.title);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue