From 5f556b60be42522de117b6c690a6de55a69e3d5a Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Mon, 20 Feb 2023 17:19:38 -0500 Subject: [PATCH] Fix admin page list paging (#35) --- src/MyWebLog/Handlers/Page.fs | 7 ++++++- src/admin-theme/page-list.liquid | 6 +++--- src/admin-theme/post-list.liquid | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/MyWebLog/Handlers/Page.fs b/src/MyWebLog/Handlers/Page.fs index 5dee988..6ddeae8 100644 --- a/src/MyWebLog/Handlers/Page.fs +++ b/src/MyWebLog/Handlers/Page.fs @@ -12,9 +12,14 @@ let all pageNbr : HttpHandler = requireAccess Author >=> fun next ctx -> task { return! hashForPage "Pages" |> withAntiCsrf ctx - |> addToHash "pages" (pages |> List.map (DisplayPage.fromPageMinimal ctx.WebLog)) + |> addToHash "pages" (pages + |> Seq.ofList + |> Seq.truncate 25 + |> Seq.map (DisplayPage.fromPageMinimal ctx.WebLog) + |> List.ofSeq) |> addToHash "page_nbr" pageNbr |> addToHash "prev_page" (if pageNbr = 2 then "" else $"/page/{pageNbr - 1}") + |> addToHash "has_next" (List.length pages > 25) |> addToHash "next_page" $"/page/{pageNbr + 1}" |> adminView "page-list" next ctx } diff --git a/src/admin-theme/page-list.liquid b/src/admin-theme/page-list.liquid index 1a38b51..f22871f 100644 --- a/src/admin-theme/page-list.liquid +++ b/src/admin-theme/page-list.liquid @@ -6,7 +6,7 @@ {%- assign title_col = "col-12 col-md-5" -%} {%- assign link_col = "col-12 col-md-5" -%} {%- assign upd8_col = "col-12 col-md-2" -%} -
+
@@ -49,7 +49,7 @@
{%- endfor %} - {% if page_nbr > 1 or page_count == 25 %} + {% if page_nbr > 1 or has_next %}
{% if page_nbr > 1 %} @@ -61,7 +61,7 @@ {% endif %}
- {% if page_count == 25 %} + {% if has_next %}

Next » diff --git a/src/admin-theme/post-list.liquid b/src/admin-theme/post-list.liquid index 7b46939..b597187 100644 --- a/src/admin-theme/post-list.liquid +++ b/src/admin-theme/post-list.liquid @@ -3,7 +3,7 @@ Write a New Post {%- assign post_count = model.posts | size -%} {%- if post_count > 0 %} -

+ {%- assign date_col = "col-xs-12 col-md-3 col-lg-2" -%} {%- assign title_col = "col-xs-12 col-md-7 col-lg-6 col-xl-5 col-xxl-4" -%}