aboutsummaryrefslogtreecommitdiff
path: root/internal/ui/pagination.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/ui/pagination.go')
-rw-r--r--internal/ui/pagination.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/ui/pagination.go b/internal/ui/pagination.go
index 5a31192a..e7c63a16 100644
--- a/internal/ui/pagination.go
+++ b/internal/ui/pagination.go
@@ -9,17 +9,30 @@ type pagination struct {
Offset int
ItemsPerPage int
ShowNext bool
+ ShowLast bool
+ ShowFirst bool
ShowPrev bool
NextOffset int
+ LastOffset int
PrevOffset int
+ FirstOffset int
SearchQuery string
}
func getPagination(route string, total, offset, nbItemsPerPage int) pagination {
nextOffset := 0
prevOffset := 0
+
+ firstOffset := 0
+ lastOffset := (total / nbItemsPerPage) * nbItemsPerPage
+ if lastOffset == total {
+ lastOffset -= nbItemsPerPage
+ }
+
showNext := (total - offset) > nbItemsPerPage
showPrev := offset > 0
+ showLast := showNext
+ showFirst := showPrev
if showNext {
nextOffset = offset + nbItemsPerPage
@@ -35,8 +48,12 @@ func getPagination(route string, total, offset, nbItemsPerPage int) pagination {
Offset: offset,
ItemsPerPage: nbItemsPerPage,
ShowNext: showNext,
+ ShowLast: showLast,
NextOffset: nextOffset,
+ LastOffset: lastOffset,
ShowPrev: showPrev,
+ ShowFirst: showFirst,
PrevOffset: prevOffset,
+ FirstOffset: firstOffset,
}
}