mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Add navigation to last/first page
This commit is contained in:
parent
f0e8323f19
commit
a46e702536
21 changed files with 109 additions and 16 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue