Add navigation to last/first page
This commit is contained in:
parent
f0e8323f19
commit
a46e702536
21 changed files with 109 additions and 16 deletions
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Suche",
|
"search.label": "Suche",
|
||||||
"search.placeholder": "Suche...",
|
"search.placeholder": "Suche...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Nächste",
|
"pagination.next": "Nächste",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Vorherige",
|
"pagination.previous": "Vorherige",
|
||||||
"entry.status.unread": "Ungelesen",
|
"entry.status.unread": "Ungelesen",
|
||||||
"entry.status.read": "Gelesen",
|
"entry.status.read": "Gelesen",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Αναζήτηση",
|
"search.label": "Αναζήτηση",
|
||||||
"search.placeholder": "Αναζήτηση...",
|
"search.placeholder": "Αναζήτηση...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Επόμενη",
|
"pagination.next": "Επόμενη",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Προηγούμενη",
|
"pagination.previous": "Προηγούμενη",
|
||||||
"entry.status.unread": "Μη αναγνωσμένο",
|
"entry.status.unread": "Μη αναγνωσμένο",
|
||||||
"entry.status.read": "Αναγνωσμένο",
|
"entry.status.read": "Αναγνωσμένο",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Search",
|
"search.label": "Search",
|
||||||
"search.placeholder": "Search…",
|
"search.placeholder": "Search…",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Next",
|
"pagination.next": "Next",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Previous",
|
"pagination.previous": "Previous",
|
||||||
"entry.status.unread": "Unread",
|
"entry.status.unread": "Unread",
|
||||||
"entry.status.read": "Read",
|
"entry.status.read": "Read",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Buscar",
|
"search.label": "Buscar",
|
||||||
"search.placeholder": "Búsqueda...",
|
"search.placeholder": "Búsqueda...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Ultimo",
|
||||||
"pagination.next": "Siguiente",
|
"pagination.next": "Siguiente",
|
||||||
|
"pagination.first": "Primero",
|
||||||
"pagination.previous": "Anterior",
|
"pagination.previous": "Anterior",
|
||||||
"entry.status.unread": "No leído",
|
"entry.status.unread": "No leído",
|
||||||
"entry.status.read": "Leído",
|
"entry.status.read": "Leído",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Haku",
|
"search.label": "Haku",
|
||||||
"search.placeholder": "Hae...",
|
"search.placeholder": "Hae...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Seuraava",
|
"pagination.next": "Seuraava",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Edellinen",
|
"pagination.previous": "Edellinen",
|
||||||
"entry.status.unread": "Lukematon",
|
"entry.status.unread": "Lukematon",
|
||||||
"entry.status.read": "Luettu",
|
"entry.status.read": "Luettu",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Recherche",
|
"search.label": "Recherche",
|
||||||
"search.placeholder": "Recherche...",
|
"search.placeholder": "Recherche...",
|
||||||
"search.submit": "Rechercher",
|
"search.submit": "Rechercher",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Suivant",
|
"pagination.next": "Suivant",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Précédent",
|
"pagination.previous": "Précédent",
|
||||||
"entry.status.unread": "Non lu",
|
"entry.status.unread": "Non lu",
|
||||||
"entry.status.read": "Lu",
|
"entry.status.read": "Lu",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "खोजे",
|
"search.label": "खोजे",
|
||||||
"search.placeholder": "खोजे...",
|
"search.placeholder": "खोजे...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "अगला",
|
"pagination.next": "अगला",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "पिछला",
|
"pagination.previous": "पिछला",
|
||||||
"entry.status.unread": "अपठित",
|
"entry.status.unread": "अपठित",
|
||||||
"entry.status.read": "पढ़े",
|
"entry.status.read": "पढ़े",
|
||||||
|
|
|
@ -56,6 +56,8 @@
|
||||||
"search.placeholder": "Cari...",
|
"search.placeholder": "Cari...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
"pagination.next": "Berikutnya",
|
"pagination.next": "Berikutnya",
|
||||||
|
"pagination.last": "Last",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Sebelumnya",
|
"pagination.previous": "Sebelumnya",
|
||||||
"entry.status.unread": "Belum dibaca",
|
"entry.status.unread": "Belum dibaca",
|
||||||
"entry.status.read": "Telah dibaca",
|
"entry.status.read": "Telah dibaca",
|
||||||
|
|
|
@ -56,6 +56,8 @@
|
||||||
"search.placeholder": "Cerca...",
|
"search.placeholder": "Cerca...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
"pagination.next": "Successivo",
|
"pagination.next": "Successivo",
|
||||||
|
"pagination.last": "Last",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Precedente",
|
"pagination.previous": "Precedente",
|
||||||
"entry.status.unread": "Da leggere",
|
"entry.status.unread": "Da leggere",
|
||||||
"entry.status.read": "Letto",
|
"entry.status.read": "Letto",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "検索",
|
"search.label": "検索",
|
||||||
"search.placeholder": "…を検索",
|
"search.placeholder": "…を検索",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "次",
|
"pagination.next": "次",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "前",
|
"pagination.previous": "前",
|
||||||
"entry.status.unread": "未読にする",
|
"entry.status.unread": "未読にする",
|
||||||
"entry.status.read": "既読にする",
|
"entry.status.read": "既読にする",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Zoeken",
|
"search.label": "Zoeken",
|
||||||
"search.placeholder": "Zoeken...",
|
"search.placeholder": "Zoeken...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Volgende",
|
"pagination.next": "Volgende",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Vorige",
|
"pagination.previous": "Vorige",
|
||||||
"entry.status.unread": "Ongelezen",
|
"entry.status.unread": "Ongelezen",
|
||||||
"entry.status.read": "Gelezen",
|
"entry.status.read": "Gelezen",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Szukaj",
|
"search.label": "Szukaj",
|
||||||
"search.placeholder": "Szukaj...",
|
"search.placeholder": "Szukaj...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Ostatni",
|
||||||
"pagination.next": "Następny",
|
"pagination.next": "Następny",
|
||||||
|
"pagination.first": "Pierwszy",
|
||||||
"pagination.previous": "Poprzedni",
|
"pagination.previous": "Poprzedni",
|
||||||
"entry.status.unread": "Nieprzeczytane",
|
"entry.status.unread": "Nieprzeczytane",
|
||||||
"entry.status.read": "Przeczytane",
|
"entry.status.read": "Przeczytane",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Buscar",
|
"search.label": "Buscar",
|
||||||
"search.placeholder": "Buscar por...",
|
"search.placeholder": "Buscar por...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Próximo",
|
"pagination.next": "Próximo",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Anterior",
|
"pagination.previous": "Anterior",
|
||||||
"entry.status.unread": "Não lido",
|
"entry.status.unread": "Não lido",
|
||||||
"entry.status.read": "Lido",
|
"entry.status.read": "Lido",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Поиск",
|
"search.label": "Поиск",
|
||||||
"search.placeholder": "Поиск…",
|
"search.placeholder": "Поиск…",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Следующая",
|
"pagination.next": "Следующая",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Предыдущая",
|
"pagination.previous": "Предыдущая",
|
||||||
"entry.status.unread": "Не прочитано",
|
"entry.status.unread": "Не прочитано",
|
||||||
"entry.status.read": "Прочитано",
|
"entry.status.read": "Прочитано",
|
||||||
|
|
|
@ -485,7 +485,9 @@
|
||||||
"page.users.title": "Kullanıcılar",
|
"page.users.title": "Kullanıcılar",
|
||||||
"page.users.username": "Kullanıcı adı",
|
"page.users.username": "Kullanıcı adı",
|
||||||
"page.webauthn_rename.title": "Passkey'i Yeniden Adlandır",
|
"page.webauthn_rename.title": "Passkey'i Yeniden Adlandır",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Sonraki",
|
"pagination.next": "Sonraki",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Önceki",
|
"pagination.previous": "Önceki",
|
||||||
"search.label": "Ara",
|
"search.label": "Ara",
|
||||||
"search.placeholder": "Ara...",
|
"search.placeholder": "Ara...",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "Пошук",
|
"search.label": "Пошук",
|
||||||
"search.placeholder": "Шукати...",
|
"search.placeholder": "Шукати...",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "Вперед",
|
"pagination.next": "Вперед",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "Назад",
|
"pagination.previous": "Назад",
|
||||||
"entry.status.unread": "Непрочитане",
|
"entry.status.unread": "Непрочитане",
|
||||||
"entry.status.read": "Прочитане",
|
"entry.status.read": "Прочитане",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "搜索",
|
"search.label": "搜索",
|
||||||
"search.placeholder": "搜索…",
|
"search.placeholder": "搜索…",
|
||||||
"search.submit": "Search",
|
"search.submit": "Search",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "下一页",
|
"pagination.next": "下一页",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "上一页",
|
"pagination.previous": "上一页",
|
||||||
"entry.status.unread": "标为未读",
|
"entry.status.unread": "标为未读",
|
||||||
"entry.status.read": "标为已读",
|
"entry.status.read": "标为已读",
|
||||||
|
|
|
@ -55,7 +55,9 @@
|
||||||
"search.label": "搜尋",
|
"search.label": "搜尋",
|
||||||
"search.placeholder": "搜尋…",
|
"search.placeholder": "搜尋…",
|
||||||
"search.submit": "送出",
|
"search.submit": "送出",
|
||||||
|
"pagination.last": "Last",
|
||||||
"pagination.next": "下一頁",
|
"pagination.next": "下一頁",
|
||||||
|
"pagination.first": "First",
|
||||||
"pagination.previous": "上一頁",
|
"pagination.previous": "上一頁",
|
||||||
"entry.status.unread": "標為未讀",
|
"entry.status.unread": "標為未讀",
|
||||||
"entry.status.read": "標為已讀",
|
"entry.status.read": "標為已讀",
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
{{ define "pagination" }}
|
{{ define "pagination" }}
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
|
<div class="pagination-backward">
|
||||||
|
<div class="pagination-first {{ if not .ShowFirst }}disabled{{end}}">
|
||||||
|
{{ if .ShowFirst }}
|
||||||
|
<a href="{{ .Route }}{{ if gt .FirstOffset 0 }}?offset={{ .FirstOffset }}{{ if .SearchQuery }}&q={{ .SearchQuery }}{{ end }}{{ else }}{{ if .SearchQuery }}?q={{ .SearchQuery }}{{ end }}{{ end }}" data-page="first">{{ t "pagination.first" }}</a>
|
||||||
|
{{ else }}
|
||||||
|
{{ t "pagination.first" }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pagination-prev {{ if not .ShowPrev }}disabled{{end}}">
|
<div class="pagination-prev {{ if not .ShowPrev }}disabled{{end}}">
|
||||||
{{ if .ShowPrev }}
|
{{ if .ShowPrev }}
|
||||||
<a href="{{ .Route }}{{ if gt .PrevOffset 0 }}?offset={{ .PrevOffset }}{{ if .SearchQuery }}&q={{ .SearchQuery }}{{ end }}{{ else }}{{ if .SearchQuery }}?q={{ .SearchQuery }}{{ end }}{{ end }}" data-page="previous" rel="prev">{{ t "pagination.previous" }}</a>
|
<a href="{{ .Route }}{{ if gt .PrevOffset 0 }}?offset={{ .PrevOffset }}{{ if .SearchQuery }}&q={{ .SearchQuery }}{{ end }}{{ else }}{{ if .SearchQuery }}?q={{ .SearchQuery }}{{ end }}{{ end }}" data-page="previous" rel="prev">{{ t "pagination.previous" }}</a>
|
||||||
|
@ -7,7 +16,9 @@
|
||||||
{{ t "pagination.previous" }}
|
{{ t "pagination.previous" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pagination-forward">
|
||||||
<div class="pagination-next {{ if not .ShowNext }}disabled{{end}}">
|
<div class="pagination-next {{ if not .ShowNext }}disabled{{end}}">
|
||||||
{{ if .ShowNext }}
|
{{ if .ShowNext }}
|
||||||
<a href="{{ .Route }}?offset={{ .NextOffset }}{{ if .SearchQuery }}&q={{ .SearchQuery }}{{ end }}" data-page="next" rel="next">{{ t "pagination.next" }}</a>
|
<a href="{{ .Route }}?offset={{ .NextOffset }}{{ if .SearchQuery }}&q={{ .SearchQuery }}{{ end }}" data-page="next" rel="next">{{ t "pagination.next" }}</a>
|
||||||
|
@ -15,5 +26,14 @@
|
||||||
{{ t "pagination.next" }}
|
{{ t "pagination.next" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pagination-last {{ if not .ShowLast }}disabled{{end}}">
|
||||||
|
{{ if .ShowLast }}
|
||||||
|
<a href="{{ .Route }}?offset={{ .LastOffset }}{{ if .SearchQuery }}&q={{ .SearchQuery }}{{ end }}" data-page="last" >{{ t "pagination.last" }}</a>
|
||||||
|
{{ else }}
|
||||||
|
{{ t "pagination.last" }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -9,17 +9,30 @@ type pagination struct {
|
||||||
Offset int
|
Offset int
|
||||||
ItemsPerPage int
|
ItemsPerPage int
|
||||||
ShowNext bool
|
ShowNext bool
|
||||||
|
ShowLast bool
|
||||||
|
ShowFirst bool
|
||||||
ShowPrev bool
|
ShowPrev bool
|
||||||
NextOffset int
|
NextOffset int
|
||||||
|
LastOffset int
|
||||||
PrevOffset int
|
PrevOffset int
|
||||||
|
FirstOffset int
|
||||||
SearchQuery string
|
SearchQuery string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPagination(route string, total, offset, nbItemsPerPage int) pagination {
|
func getPagination(route string, total, offset, nbItemsPerPage int) pagination {
|
||||||
nextOffset := 0
|
nextOffset := 0
|
||||||
prevOffset := 0
|
prevOffset := 0
|
||||||
|
|
||||||
|
firstOffset := 0
|
||||||
|
lastOffset := (total / nbItemsPerPage) * nbItemsPerPage
|
||||||
|
if lastOffset == total {
|
||||||
|
lastOffset -= nbItemsPerPage
|
||||||
|
}
|
||||||
|
|
||||||
showNext := (total - offset) > nbItemsPerPage
|
showNext := (total - offset) > nbItemsPerPage
|
||||||
showPrev := offset > 0
|
showPrev := offset > 0
|
||||||
|
showLast := showNext
|
||||||
|
showFirst := showPrev
|
||||||
|
|
||||||
if showNext {
|
if showNext {
|
||||||
nextOffset = offset + nbItemsPerPage
|
nextOffset = offset + nbItemsPerPage
|
||||||
|
@ -35,8 +48,12 @@ func getPagination(route string, total, offset, nbItemsPerPage int) pagination {
|
||||||
Offset: offset,
|
Offset: offset,
|
||||||
ItemsPerPage: nbItemsPerPage,
|
ItemsPerPage: nbItemsPerPage,
|
||||||
ShowNext: showNext,
|
ShowNext: showNext,
|
||||||
|
ShowLast: showLast,
|
||||||
NextOffset: nextOffset,
|
NextOffset: nextOffset,
|
||||||
|
LastOffset: lastOffset,
|
||||||
ShowPrev: showPrev,
|
ShowPrev: showPrev,
|
||||||
|
ShowFirst: showFirst,
|
||||||
PrevOffset: prevOffset,
|
PrevOffset: prevOffset,
|
||||||
|
FirstOffset: firstOffset,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -710,6 +710,7 @@ template {
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-top {
|
.pagination-top {
|
||||||
|
@ -732,21 +733,40 @@ template {
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination > div {
|
.pagination > div {
|
||||||
flex: 1;
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination > div.pagination-backward > div {
|
||||||
|
padding-right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination > div.pagination-forward > div {
|
||||||
|
padding-left: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-next {
|
.pagination-next {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-prev:before {
|
.pagination-next:after {
|
||||||
content: "« ";
|
content: " ›";
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-next:after {
|
.pagination-last {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-last:after {
|
||||||
content: " »";
|
content: " »";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pagination-prev:before {
|
||||||
|
content: "‹ ";
|
||||||
|
}
|
||||||
|
.pagination-first:before {
|
||||||
|
content: "« ";
|
||||||
|
}
|
||||||
|
|
||||||
.pagination a {
|
.pagination a {
|
||||||
color: var(--pagination-link-color);
|
color: var(--pagination-link-color);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue