From f53768de7e8913e51b993410e1fec079449dc3ef Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 6 Jun 2016 14:05:06 +0000 Subject: [PATCH] Paginate list of sharers on the server --- src/Vervis/Handler/Sharer.hs | 8 +++++++- templates/sharer/list.hamlet | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Vervis/Handler/Sharer.hs b/src/Vervis/Handler/Sharer.hs index e014275..4515e20 100644 --- a/src/Vervis/Handler/Sharer.hs +++ b/src/Vervis/Handler/Sharer.hs @@ -32,12 +32,18 @@ import Yesod.Persist.Core (runDB, getBy404) import Vervis.Foundation import Vervis.Model import Vervis.Model.Ident (ShrIdent, shr2text) +import Vervis.Paginate import Vervis.Settings (widgetFile) import Vervis.Widget.Sharer (sharerLinkW) getSharersR :: Handler Html getSharersR = do - sharers <- runDB $ selectList [] [Asc SharerIdent] + (sharers, navModel) <- getPageAndNav $ \ off lim -> + runDB $ do + total <- count ([] :: [Filter Sharer]) + ss <- selectList [] [OffsetBy off, LimitTo lim, Asc SharerIdent] + return (total, ss) + let pageNav = navWidget navModel defaultLayout $(widgetFile "sharer/list") getSharerR :: ShrIdent -> Handler Html diff --git a/templates/sharer/list.hamlet b/templates/sharer/list.hamlet index 2d3828b..83a5d78 100644 --- a/templates/sharer/list.hamlet +++ b/templates/sharer/list.hamlet @@ -15,7 +15,11 @@ $# .

These are the people and groups registered in this Vervis instance. +^{pageNav} +