diff options
author | Tyler Ferrari <69283684+Sowgro@users.noreply.github.com> | 2025-04-05 20:18:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-05 20:18:10 -0400 |
commit | 95798c2b81da7f950850a6bb3c5be28e0323d5ba (patch) | |
tree | 7c0cf1c24c9177ba77468141e245f2b2f111e50b /ufund-ui/src/app/components/need-list | |
parent | ef52495d781a3adcec79bfbc9067f70f5ec3c8ab (diff) | |
parent | 2f37b1de28399a361dc272b51ad624ac8902a562 (diff) | |
download | JellySolutions-95798c2b81da7f950850a6bb3c5be28e0323d5ba.tar.gz JellySolutions-95798c2b81da7f950850a6bb3c5be28e0323d5ba.tar.bz2 JellySolutions-95798c2b81da7f950850a6bb3c5be28e0323d5ba.zip |
Merge pull request #29 from RIT-SWEN-261-02/need-image
local persistence for need list data
Diffstat (limited to 'ufund-ui/src/app/components/need-list')
-rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 14 |
1 files changed, 9 insertions, 5 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 40af9f5..7ca0ae7 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 @@ -10,42 +10,46 @@ import {GoalType, Need} from '../../models/Need'; export class NeedListComponent implements OnChanges { @Input({required: true}) needs!: Need[] + @Input({required: true}) uid!: number @Input() itemsPerPage: number = 5; @Input() actionArea: TemplateRef<any> | null = null visibleNeeds: Need[] = []; - currentPage: number = 0; + currentPage: number = parseInt(localStorage.getItem('currentPage'+this.uid) ?? '0') ?? 0; totalPages: number = 0; - constructor( - - ) {} - ngOnChanges() { this.updateVisibleNeeds() + this.currentPage = parseInt(localStorage.getItem('currentPage'+this.uid) ?? '0') ?? 0; } getPrefix(need: Need) { return (need.type === GoalType.MONETARY) ? "$" : ""; } + //increment/decrement decrementPage() { this.currentPage--; + localStorage.setItem('currentPage'+this.uid, this.currentPage.toString()); this.updateVisibleNeeds(); } incrementPage() { this.currentPage++; + localStorage.setItem('currentPage'+this.uid, this.currentPage.toString()); this.updateVisibleNeeds(); } + //skipping pages lastPage() { this.currentPage = this.totalPages - 1 + localStorage.setItem('currentPage'+this.uid, this.currentPage.toString()); this.updateVisibleNeeds() } firstPage() { this.currentPage = 0 + localStorage.setItem('currentPage'+this.uid, this.currentPage.toString()); this.updateVisibleNeeds() } |