aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/need-list/need-list.component.ts
diff options
context:
space:
mode:
authorbenal01 <bja4245@rit.edu>2025-03-27 10:09:19 -0400
committerbenal01 <bja4245@rit.edu>2025-03-27 10:09:19 -0400
commitee4154df85a971f3a0f8e43fd6afdfa6a620ea99 (patch)
tree1dbbd0d14cabbcc7fb15a58376b270f7316a1bf1 /ufund-ui/src/app/components/need-list/need-list.component.ts
parent65590e6dfbed90e4acd342a72feb8d7b5120d70c (diff)
downloadJellySolutions-ee4154df85a971f3a0f8e43fd6afdfa6a620ea99.tar.gz
JellySolutions-ee4154df85a971f3a0f8e43fd6afdfa6a620ea99.tar.bz2
JellySolutions-ee4154df85a971f3a0f8e43fd6afdfa6a620ea99.zip
refactor change sort algo func with [(ngModel)] binding
Diffstat (limited to '')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts25
1 files changed, 11 insertions, 14 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 97be0cb..177d9f7 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
@@ -38,8 +38,9 @@ export class NeedListComponent {
needs: Need[] = [];
searchResults: Need[] = [];
sortMode = 'Ascending'
- sortSelection: string = '';
+
currentSortAlgo: sortAlgo = sortByGoal;
+ sortSelection: string = this.currentSortAlgo.name;
SortingAlgoArrays: {func:sortAlgo,name:string, display:string[]}[] = [
{func:sortByGoal,name:"sortByMaxGoal", display:["Max Goal", "Min Goal"]},
@@ -77,19 +78,6 @@ export class NeedListComponent {
this.search(form)
}
- changeSortAlgo(algoName: string, form: any) {
- console.log(algoName);
- this.SortingAlgoArrays.forEach(algo => {
- if(algo.name === algoName) {
- this.currentSortAlgo = algo.func;
- console.log("changed sorting algorithm to: ", algo.name + this.sortMode)
- return
- }
- });
- this.refresh()
- this.search(form);
- }
-
private searchDelay: any;
async search(form: any) {
@@ -103,6 +91,15 @@ export class NeedListComponent {
this.searchDelay = setTimeout(() => {
if (form) {
+ //sorting based on algo selected
+ this.SortingAlgoArrays.forEach(algo => {
+ if(algo.name === this.sortSelection) {
+ this.currentSortAlgo = algo.func;
+ console.log("changed sorting algorithm to: ", algo.name + this.sortMode)
+ return
+ }
+ });
+
const currentSearchValue = form.search; //latest value of the search
this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => {
if (this.sortMode == 'Ascending') {