Add filters by priority + highlighting

This commit is contained in:
Jakob Fahr
2020-06-22 11:21:25 +02:00
parent 03e8c96a1e
commit a81a26d989
7 changed files with 110 additions and 87 deletions

View File

@@ -1,33 +1,38 @@
import {sortByNumberAscending, sortByStringAscending} from './sorting.service';
import {Priority} from './backend.service';
export abstract class TableComponentBase<T> {
public sortBy: string;
public sortDescending = false;
public items: T[] = [];
public sortBy: string;
public sortDescending = false;
public items: T[] = [];
protected doNumericSort(by: string, key: (ScrumTask) => number) {
if (this.sortBy === by) {
this.sortDescending = !this.sortDescending;
} else {
this.sortBy = by;
}
this.items = sortByNumberAscending(this.items, key);
if (this.sortDescending) {
this.items = this.items.reverse();
}
protected doNumericSort(by: string, key: (item: T) => number) {
if (this.sortBy === by) {
this.sortDescending = !this.sortDescending;
} else {
this.sortBy = by;
}
protected doStringSort(by: string, key: (ScrumTask) => string) {
if (this.sortBy === by) {
this.sortDescending = !this.sortDescending;
} else {
this.sortBy = by;
}
this.items = sortByStringAscending(this.items, key);
if (this.sortDescending) {
this.items = this.items.reverse();
}
this.items = sortByNumberAscending(this.items, key);
if (this.sortDescending) {
this.items = this.items.reverse();
}
}
protected doStringSort(by: string, key: (item: T) => string) {
if (this.sortBy === by) {
this.sortDescending = !this.sortDescending;
} else {
this.sortBy = by;
}
this.items = sortByStringAscending(this.items, key);
if (this.sortDescending) {
this.items = this.items.reverse();
}
}
public getAllPriorities(): string[] {
return Object.values(Priority);
}
}