From b480d9507b17b90493cd17fcb66149acb16d9e97 Mon Sep 17 00:00:00 2001 From: moshyfawn Date: Thu, 15 Jan 2026 11:06:12 +0000 Subject: [PATCH] appview: add reusable pagination template Extract pagination UI into a shared template for reuse across pages. Refactored issues listing to use it with no behavior change Signed-off-by: moshyfawn Signed-off-by: Seongmin Lee --- appview/pages/templates/fragments/pagination.html | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ appview/pages/templates/repo/issues/issues.html | 113 ++++++++++------------------------------------------------------------------------------------------------------- 2 file(s) changed, 105 insertion(s)(+), 103 deletion(s)(-) diff --git a/appview/pages/templates/fragments/pagination.html b/appview/pages/templates/fragments/pagination.html new file mode 100644 --- /dev/null +++ b/appview/pages/templates/fragments/pagination.html @@ -0,0 +1,95 @@ +{{ define "fragments/pagination" }} + {{/* Params: Page (pagination.Page), TotalCount (int), BasePath (string), QueryParams (string) */}} + {{ $page := .Page }} + {{ $totalCount := .TotalCount }} + {{ $basePath := .BasePath }} + {{ $queryParams := .QueryParams }} + + {{ $prev := $page.Previous.Offset }} + {{ $next := $page.Next.Offset }} + {{ $lastPage := sub $totalCount (mod $totalCount $page.Limit) }} + +
+ + {{ i "chevron-left" "w-4 h-4" }} + previous + + + {{ if gt $page.Offset 0 }} + + 1 + + {{ end }} + + {{ if gt $prev $page.Limit }} + ... + {{ end }} + + {{ if gt $prev 0 }} + + {{ add (div $prev $page.Limit) 1 }} + + {{ end }} + + + {{ add (div $page.Offset $page.Limit) 1 }} + + + {{ if lt $next $lastPage }} + + {{ add (div $next $page.Limit) 1 }} + + {{ end }} + + {{ if lt $next (sub $totalCount (mul 2 $page.Limit)) }} + ... + {{ end }} + + {{ if lt $page.Offset $lastPage }} + + {{ add (div $lastPage $page.Limit) 1 }} + + {{ end }} + + + next + {{ i "chevron-right" "w-4 h-4" }} + +
+{{ end }} diff --git a/appview/pages/templates/repo/issues/issues.html b/appview/pages/templates/repo/issues/issues.html --- a/appview/pages/templates/repo/issues/issues.html +++ b/appview/pages/templates/repo/issues/issues.html @@ -71,109 +71,16 @@ {{ define "repoAfter" }}
{{ template "repo/issues/fragments/issueListing" (dict "Issues" .Issues "RepoPrefix" .RepoInfo.FullName "LabelDefs" .LabelDefs) }}
- {{if gt .IssueCount .Page.Limit }} - {{ block "pagination" . }} {{ end }} - {{ end }} -{{ end }} - -{{ define "pagination" }} -
- {{ $currentState := "closed" }} - {{ if .FilteringByOpen }} - {{ $currentState = "open" }} - {{ end }} - - {{ $prev := .Page.Previous.Offset }} - {{ $next := .Page.Next.Offset }} - {{ $lastPage := sub .IssueCount (mod .IssueCount .Page.Limit) }} - - - {{ i "chevron-left" "w-4 h-4" }} - previous - - - - {{ if gt .Page.Offset 0 }} - - 1 - - {{ end }} - - - {{ if gt $prev .Page.Limit }} - ... + {{ template "fragments/pagination" (dict + "Page" .Page + "TotalCount" .IssueCount + "BasePath" (printf "/%s/issues" .RepoInfo.FullName) + "QueryParams" (printf "state=%s&q=%s" $state .FilterQuery) + ) }} {{ end }} - - - {{ if gt $prev 0 }} - - {{ add (div $prev .Page.Limit) 1 }} - - {{ end }} - - - - {{ add (div .Page.Offset .Page.Limit) 1 }} - - - - {{ if lt $next $lastPage }} - - {{ add (div $next .Page.Limit) 1 }} - - {{ end }} - - - {{ if lt ($next) (sub .IssueCount (mul (2) .Page.Limit)) }} - ... - {{ end }} - - - {{ if lt .Page.Offset $lastPage }} - - {{ add (div $lastPage .Page.Limit) 1 }} - - {{ end }} - - - next - {{ i "chevron-right" "w-4 h-4" }} - -
{{ end }} -- tangled.sh