From 36876874570c13bc82a872d31b4a8b55004a440c Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Wed, 25 May 2016 16:03:58 +0000 Subject: [PATCH] Add group members page and breadcrumbs for group routes --- config/routes | 1 + src/Vervis/Foundation.hs | 5 +++++ src/Vervis/Handler/Group.hs | 11 ++++++++++- templates/group/{one.hamlet => members.hamlet} | 0 4 files changed, 16 insertions(+), 1 deletion(-) rename templates/group/{one.hamlet => members.hamlet} (100%) diff --git a/config/routes b/config/routes index 0e45eb2..bdd7fed 100644 --- a/config/routes +++ b/config/routes @@ -42,6 +42,7 @@ /g GroupsR GET POST /g/!new GroupNewR GET /g/#ShrIdent GroupR GET +/g/#ShrIdent/m GroupMembersR GET /k KeysR GET POST /k/!new KeyNewR GET diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 93124a7..3e907dc 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -263,6 +263,11 @@ instance YesodBreadcrumbs App where PersonNewR -> ("New", Just PeopleR) PersonR shar -> (shr2text shar, Just PeopleR) + GroupsR -> ("Groups", Just HomeR) + GroupNewR -> ("New", Just GroupsR) + GroupR shar -> (shr2text shar, Just GroupsR) + GroupMembersR shar -> ("Members", Just $ GroupR shar) + KeysR -> ("Keys", Just HomeR) KeyNewR -> ("New", Just KeysR) KeyR key -> (ky2text key, Just KeysR) diff --git a/src/Vervis/Handler/Group.hs b/src/Vervis/Handler/Group.hs index ceb69c6..92bec28 100644 --- a/src/Vervis/Handler/Group.hs +++ b/src/Vervis/Handler/Group.hs @@ -18,6 +18,7 @@ module Vervis.Handler.Group , postGroupsR , getGroupNewR , getGroupR + , getGroupMembersR ) where @@ -91,6 +92,14 @@ getGroupNewR = do getGroupR :: ShrIdent -> Handler Html getGroupR shar = do + group <- runDB $ do + Entity sid _s <- getBy404 $ UniqueSharer shar + Entity _gid g <- getBy404 $ UniqueGroup sid + return g + defaultLayout $ return () + +getGroupMembersR :: ShrIdent -> Handler Html +getGroupMembersR shar = do (group, members) <- runDB $ do Entity sid s <- getBy404 $ UniqueSharer shar Entity gid _g <- getBy404 $ UniqueGroup sid @@ -105,4 +114,4 @@ getGroupR shar = do ] return sharer return (s, ms) - defaultLayout $(widgetFile "group/one") + defaultLayout $(widgetFile "group/members") diff --git a/templates/group/one.hamlet b/templates/group/members.hamlet similarity index 100% rename from templates/group/one.hamlet rename to templates/group/members.hamlet