aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/need-list
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/need-list')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts
index 37a3775..4ae8f4a 100644
--- a/ufund-ui/src/app/components/need-list/need-list.component.ts
+++ b/ufund-ui/src/app/components/need-list/need-list.component.ts
@@ -26,6 +26,16 @@ const sortByGoal: sortAlgo = (a: Need, b: Need): number => {
return 1;
}
+const sortByPriority: sortAlgo = (a: Need, b: Need): number => {
+ if(a.urgent == b.urgent) {
+ return sortByGoal(a,b);
+ }
+ else if(a.urgent && !b.urgent) {
+ return -1;
+ }
+ return 1;
+}
+
@Component({
selector: 'app-need-list',
standalone: false,
@@ -38,13 +48,13 @@ export class NeedListComponent {
searchResults: Need[] = [];
sortMode = 'Ascending'
- currentSortAlgo: sortAlgo = sortByName;
- sortSelection: string = 'sortByName';
+ currentSortAlgo: sortAlgo = sortByPriority;
+ sortSelection: string = 'sortByPriority';
SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [
{func:sortByName,name:"sortByName", display:["Name (Alphabetical)", "Name (Reverse)"]},
{func:sortByGoal,name:"sortByGoal", display:["Largest Maximum Goal", "Smallest Maximum Goal"]},
- {func:sortByName,name:"sortByPriority", display:["Highest Priority", "Lowest Priority"]},
+ {func:sortByPriority,name:"sortByPriority", display:["Highest Priority", "Lowest Priority"]},
];
@Output() currentNeed = new EventEmitter<Need>();