diff options
Diffstat (limited to 'ufund-ui')
-rw-r--r-- | ufund-ui/src/app/components/cupboard/cupboard.component.ts | 2 | ||||
-rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index 540a058..ad68c38 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -121,7 +121,7 @@ export class CupboardComponent implements OnInit { id: 0, maxGoal: form.maxGoal, type: form.type, - urgent: form.urgent, + urgent: form.urgent ? true : false, filterAttributes: [], current: 0 }; 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>(); |