aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/need-list
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/need-list')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts15
1 files changed, 13 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 ae6bc99..ca92eeb 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
@@ -68,34 +68,41 @@ export class NeedListComponent {
searchResults: Need[] = [];
visibleNeeds: Need[] = [];
sortMode: 'Ascending' | 'Descending' = 'Ascending'
- currentPage: number = 0;
- itemsPerPage: number = 5;
+ currentPage: number = localStorage.getItem('currentPage') ? parseInt(localStorage.getItem('currentPage')!) : 0;
+ itemsPerPage: number = localStorage.getItem('itemsPerPage') ? parseInt(localStorage.getItem('itemsPerPage')!) : 5;
totalPages: number = Math.ceil(this.needs.length / this.itemsPerPage);
getPrefix(need: Need) {
return (need.type === GoalType.MONETARY) ? "$" : "";
}
+ //increment/decrement
decrementPage() {
this.currentPage--;
+ localStorage.setItem('currentPage', this.currentPage.toString());
this.updateVisibleNeeds();
}
incrementPage() {
this.currentPage++;
+ localStorage.setItem('currentPage', this.currentPage.toString());
this.updateVisibleNeeds();
}
+ //skipping pages
lastPage() {
this.currentPage = this.totalPages - 1
+ localStorage.setItem('currentPage', this.currentPage.toString());
this.updateVisibleNeeds()
}
firstPage() {
this.currentPage = 0
+ localStorage.setItem('currentPage', this.currentPage.toString());
this.updateVisibleNeeds()
}
+ //user editing needs per page
editNeedsPerPage() {
if (this.itemsPerPage > this.searchResults.length) {
this.itemsPerPage = this.searchResults.length;
@@ -103,16 +110,20 @@ export class NeedListComponent {
if (this.itemsPerPage < 1) {
this.itemsPerPage = 1;
}
+ localStorage.setItem('itemsPerPage', this.itemsPerPage.toString());
this.resetVisibleNeeds();
}
+ //refresing visible needs
updateVisibleNeeds() {
this.totalPages = Math.ceil(this.searchResults.length / this.itemsPerPage);
this.visibleNeeds = this.searchResults.slice(this.currentPage * this.itemsPerPage, (this.currentPage + 1) * this.itemsPerPage);
}
+ //reset back to first page and refresh needs
resetVisibleNeeds() {
this.currentPage = 0;
+ localStorage.setItem('currentPage', this.currentPage.toString());
this.updateVisibleNeeds();
}