From d1e1f3c0f7a59e2c97293e00641850443a745ce5 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Wed, 27 Jul 2016 08:35:50 +0000 Subject: [PATCH] Reverse dependencies page for tickets --- config/routes | 1 + src/Vervis/Foundation.hs | 3 +++ src/Vervis/Handler/Ticket.hs | 19 +++++++++++++++---- templates/ticket/one.hamlet | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/config/routes b/config/routes index 6ceafd7..9c5f9f6 100644 --- a/config/routes +++ b/config/routes @@ -110,5 +110,6 @@ /s/#ShrIdent/p/#PrjIdent/t/#Int/d/!reply TicketTopReplyR GET /s/#ShrIdent/p/#PrjIdent/t/#Int/d/#Int/reply TicketReplyR GET /s/#ShrIdent/p/#PrjIdent/t/#Int/deps TicketDepsR GET +/s/#ShrIdent/p/#PrjIdent/t/#Int/rdeps TicketReverseDepsR GET /s/#ShrIdent/p/#PrjIdent/w/+Texts WikiPageR GET diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index c1e443c..a75dfb4 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -495,5 +495,8 @@ instance YesodBreadcrumbs App where TicketDepsR shr prj num -> ( "Dependencies" , Just $ TicketR shr prj num ) + TicketReverseDepsR shr prj num -> ( "Dependants" + , Just $ TicketR shr prj num + ) WikiPageR shr prj _page -> ("Wiki", Just $ ProjectR shr prj) diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 3c11d95..76c8dca 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -41,6 +41,7 @@ module Vervis.Handler.Ticket , getTicketTopReplyR , getTicketReplyR , getTicketDepsR + , getTicketReverseDepsR ) where @@ -543,8 +544,12 @@ getTicketReplyR shar proj tnum cnum = (selectDiscussionId shar proj tnum) cnum -getTicketDepsR :: ShrIdent -> PrjIdent -> Int -> Handler Html -getTicketDepsR shr prj num = do +getTicketDeps :: Bool -> ShrIdent -> PrjIdent -> Int -> Handler Html +getTicketDeps forward shr prj num = do + let from' = + if forward then TicketDependencyParent else TicketDependencyChild + to' = + if forward then TicketDependencyChild else TicketDependencyParent rows <- runDB $ do Entity sid _ <- getBy404 $ UniqueSharer shr Entity jid _ <- getBy404 $ UniqueProject prj sid @@ -557,8 +562,8 @@ getTicketDepsR shr prj num = do ) -> do on $ person ^. PersonIdent E.==. sharer ^. SharerId on $ ticket ^. TicketCreator E.==. person ^. PersonId - on $ td ^. TicketDependencyChild E.==. ticket ^. TicketId - where_ $ td ^. TicketDependencyParent E.==. val tid + on $ td ^. to' E.==. ticket ^. TicketId + where_ $ td ^. from' E.==. val tid orderBy [asc $ ticket ^. TicketNumber] return ( ticket ^. TicketNumber @@ -567,3 +572,9 @@ getTicketDepsR shr prj num = do , ticket ^. TicketDone ) defaultLayout $(widgetFile "ticket/dep/list") + +getTicketDepsR :: ShrIdent -> PrjIdent -> Int -> Handler Html +getTicketDepsR = getTicketDeps True + +getTicketReverseDepsR :: ShrIdent -> PrjIdent -> Int -> Handler Html +getTicketReverseDepsR = getTicketDeps False diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index 5767037..b157ad4 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -77,6 +77,9 @@ $if not $ ticketDone ticket

Dependencies +

+ Dependants +

Status: # $if ticketDone ticket