diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-30 18:52:45 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-03-30 18:52:45 -0400 |
commit | b29f29eca643648381bfb62a4b90ad29e17f48a7 (patch) | |
tree | 332ca5ed6e8dacb223fe30909376d9013d845a35 /ufund-ui/src/app/components/need-list | |
parent | fd3fcd8f0e13e32774c020aee1b46e91d9b96c50 (diff) | |
parent | 44323effa5ebdbf5146d028aa4d966cbb87a7f58 (diff) | |
download | JellySolutions-b29f29eca643648381bfb62a4b90ad29e17f48a7.tar.gz JellySolutions-b29f29eca643648381bfb62a4b90ad29e17f48a7.tar.bz2 JellySolutions-b29f29eca643648381bfb62a4b90ad29e17f48a7.zip |
Merge remote-tracking branch 'origin/list-and-cupboard-component-refactor' into list-and-cupboard-component-refactor
Diffstat (limited to 'ufund-ui/src/app/components/need-list')
-rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 22 |
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.'); +} + |