diff options
| author | benal01 <bja4245@rit.edu> | 2025-03-30 00:46:50 -0400 | 
|---|---|---|
| committer | benal01 <bja4245@rit.edu> | 2025-03-30 00:46:50 -0400 | 
| commit | 760b8efef4d683d26404ebca75b7a9c44a1db3a9 (patch) | |
| tree | 0d13fe8cc3907dd1f926757b39657f4efc24a206 | |
| parent | daae556a1be7a30bc6f4606bd1b1567b713d054a (diff) | |
| download | JellySolutions-760b8efef4d683d26404ebca75b7a9c44a1db3a9.tar.gz JellySolutions-760b8efef4d683d26404ebca75b7a9c44a1db3a9.tar.bz2 JellySolutions-760b8efef4d683d26404ebca75b7a9c44a1db3a9.zip  | |
urgency sorting
Diffstat (limited to '')
| -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>();  | 
