aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui
diff options
context:
space:
mode:
authorbenal01 <bja4245@rit.edu>2025-03-30 16:44:38 -0400
committerbenal01 <bja4245@rit.edu>2025-03-30 16:44:38 -0400
commit5eba2e924c57a7771c002fa3833beb5ed4275fd2 (patch)
treec75e9584b1f792536854c69afd08d4a9e669fc73 /ufund-ui
parentc44eb965652a96498bff057d6d282af42196473e (diff)
downloadJellySolutions-5eba2e924c57a7771c002fa3833beb5ed4275fd2.tar.gz
JellySolutions-5eba2e924c57a7771c002fa3833beb5ed4275fd2.tar.bz2
JellySolutions-5eba2e924c57a7771c002fa3833beb5ed4275fd2.zip
location filter, filter order change, and refresh() resets search field for increased usability
Diffstat (limited to 'ufund-ui')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts22
1 files changed, 20 insertions, 2 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 66e53e8..af8cab4 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
@@ -1,4 +1,5 @@
import {Component , Output, EventEmitter} from '@angular/core';
+import { NgForm } from '@angular/forms';
import {Need} from '../../models/Need';
import {CupboardService} from '../../services/cupboard.service';
import { UsersService } from '../../services/users.service';
@@ -48,6 +49,13 @@ const sortByPriority: sortAlgo = (a: Need, b: Need): number => {
return 1;
}
+const sortByLocation: sortAlgo = (a: Need, b: Need): number => {
+ if(a.location.toLocaleLowerCase() < b.location.toLocaleLowerCase()) {
+ return -1;
+ }
+ return 1;
+}
+
@Component({
selector: 'app-need-list',
standalone: false,
@@ -64,10 +72,11 @@ export class NeedListComponent {
sortSelection: string = 'sortByPriority';
SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [
+ {func:sortByPriority,name:"sortByPriority", display:["Highest Priority", "Lowest Priority"]},
{func:sortByName,name:"sortByName", display:["Name (A to Z)", "Name (Z to A)"]},
- {func:sortByGoal,name:"sortByGoal", display:["Largest Maximum Goal", "Smallest Maximum Goal"]},
+ {func:sortByLocation,name:"sortByLocation", display:["Location (A to Z)", "Location (Z to A)"]},
{func:sortByCompletion,name:"sortByCompletion", display:["Most Completed", "Least Completed"]},
- {func:sortByPriority,name:"sortByPriority", display:["Highest Priority", "Lowest Priority"]},
+ {func:sortByGoal,name:"sortByGoal", display:["Largest Maximum Goal", "Smallest Maximum Goal"]},
];
@Output() currentNeed = new EventEmitter<Need>();
@@ -87,6 +96,10 @@ export class NeedListComponent {
}
this.searchResults = this.needs;
});
+
+ const form = document.getElementById('search-form') as HTMLFormElement;
+ form.reset();
+ this.search(null);
}
ngOnInit(): void {
@@ -148,6 +161,7 @@ export class NeedListComponent {
this.cupboardService.deleteNeed(id).subscribe(() => {
this.needs = this.needs.filter(n => n.id !== id)
})
+ this.refresh();
}
isManager() {
@@ -226,3 +240,7 @@ export class NeedListComponent {
}
}
}
+function not(location: string) {
+ throw new Error('Function not implemented.');
+}
+