From ad651c44ce2515d497c8e5214147c69126e25903 Mon Sep 17 00:00:00 2001 From: sowgro Date: Thu, 3 Apr 2025 19:48:54 -0400 Subject: abstraction working with search and sort --- ufund-ui/src/app/components/need-list/need-list.component.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts') 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 d027690..cd7debb 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 @@ -11,10 +11,10 @@ import {Observable} from 'rxjs'; export class NeedListComponent implements OnChanges { @Input({required: true}) needs!: Need[] + @Input() itemsPerPage: number = 5; visibleNeeds: Need[] = []; currentPage: number = 0; - itemsPerPage: number = 5; totalPages: number = 0; constructor( @@ -45,19 +45,9 @@ export class NeedListComponent implements OnChanges { this.updateVisibleNeeds() } - editNeedsPerPage(amount: number) { - this.itemsPerPage = amount; - this.updateVisibleNeeds(); - } - updateVisibleNeeds() { this.totalPages = Math.ceil(this.needs.length / this.itemsPerPage); this.visibleNeeds = this.needs.slice(this.currentPage * this.itemsPerPage, (this.currentPage + 1) * this.itemsPerPage); } - - resetVisibleNeeds() { - this.currentPage = 0; - this.updateVisibleNeeds(); - } } -- cgit v1.2.3