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-31 23:54:04 -0400
committerGitHub <noreply@github.com>2025-03-31 23:54:04 -0400
commit982e00e128add3e8dc1f0b27f393fc8e63797059 (patch)
tree829843f70736781c18536040b14c72c1bd48a019 /ufund-ui/src/app/components/need-list/need-list.component.ts
parent896e1219526a19400c7143b274193f8b818d6156 (diff)
parentbb2e7b50e1ca96120fc42eed1f090cf0e1c98258 (diff)
downloadJellySolutions-982e00e128add3e8dc1f0b27f393fc8e63797059.tar.gz
JellySolutions-982e00e128add3e8dc1f0b27f393fc8e63797059.tar.bz2
JellySolutions-982e00e128add3e8dc1f0b27f393fc8e63797059.zip
Merge pull request #24 from RIT-SWEN-261-02/need-pages
needs per page
Diffstat (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts34
1 files changed, 32 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 d641acf..cd3d9bd 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
@@ -66,7 +66,36 @@ export class NeedListComponent {
selectedNeed: Need | null = null;
needs: Need[] = [];
searchResults: Need[] = [];
+ visibleNeeds: Need[] = [];
sortMode: 'Ascending' | 'Descending' = 'Ascending'
+ currentPage: number = 0;
+ itemsPerPage: number = 5;
+ totalPages: number = Math.ceil(this.needs.length / this.itemsPerPage);
+
+ decrementPage() {
+ this.currentPage--;
+ this.updateVisibleNeeds();
+ }
+
+ incrementPage() {
+ this.currentPage++;
+ this.updateVisibleNeeds();
+ }
+
+ editNeedsPerPage(amount: number) {
+ this.itemsPerPage = amount;
+ this.updateVisibleNeeds();
+ }
+
+ updateVisibleNeeds() {
+ this.totalPages = Math.ceil(this.searchResults.length / this.itemsPerPage);
+ this.visibleNeeds = this.searchResults.slice(this.currentPage * this.itemsPerPage, (this.currentPage + 1) * this.itemsPerPage);
+ }
+
+ resetVisibleNeeds() {
+ this.currentPage = 0;
+ this.updateVisibleNeeds();
+ }
currentSortAlgo: sortAlgo = sortByPriority;
sortSelection: string = 'sortByPriority';
@@ -96,6 +125,7 @@ export class NeedListComponent {
this.needs = n.sort(this.currentSortAlgo).reverse();
}
this.searchResults = this.needs;
+ this.updateVisibleNeeds();
});
const form = document.getElementById('search-form') as HTMLFormElement;
@@ -105,6 +135,7 @@ export class NeedListComponent {
ngOnInit(): void {
this.refresh()
+
}
changeSortMode(form : any) {
@@ -145,8 +176,7 @@ export class NeedListComponent {
} else {
this.searchResults = n.sort(this.currentSortAlgo).reverse();
}
-
- console.log(currentSearchValue, this.searchResults);
+ this.updateVisibleNeeds();
});
}
}, 250);