Add pagination controls with proper state handling in BansComponent

Introduced "First", "Previous", "Next", and "Last page" buttons with state-dependent activations for improved navigation. Refactored pagination logic to utilize a constant PAGE_SIZE and adjusted calculations for max page determination. Ensured page transitions and state updates are accurate and consistent.
This commit is contained in:
2025-04-12 17:41:44 +02:00
parent 81807b107c
commit 3ed5fcfc0f
2 changed files with 33 additions and 13 deletions
+18
View File
@@ -50,6 +50,24 @@
<app-history [userType]="userType" [punishmentType]="punishmentType"
[page]="page" [searchTerm]="finalSearchTerm"></app-history>
</div>
<div>
<button [ngClass]="{'active': buttonActive(0)}" [disabled]="!buttonActive(0)"
(click)="setPage(0)">
First page
</button>
<button [ngClass]="{'active': buttonActive(0)}" [disabled]="!buttonActive(0)"
(click)="previousPage()">
Previous page
</button>
<button [ngClass]="{'active': buttonActive(getMaxPage())}" [disabled]="!buttonActive(getMaxPage())"
(click)="nextPage()">
Next page
</button>
<button [ngClass]="{'active': buttonActive(getMaxPage())}" [disabled]="!buttonActive(getMaxPage())"
(click)="setPage(getMaxPage())">
Last page
</button>
</div>
</div>
</section>
</main>