From fcb68ceea7954dc1bfcf344775b592f5b27ef59c Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 4 Jul 2016 09:58:25 +0000 Subject: [PATCH] List ticket deps and reverse deps in ticket page --- src/Vervis/Handler/Ticket.hs | 18 +++++++++---- src/Vervis/Widget/Ticket.hs | 39 +++++++++++++++++++++++++++++ templates/ticket/one.hamlet | 18 +++++++++++-- templates/ticket/widget/dep.cassius | 20 +++++++++++++++ templates/ticket/widget/dep.hamlet | 22 ++++++++++++++++ vervis.cabal | 1 + 6 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 src/Vervis/Widget/Ticket.hs create mode 100644 templates/ticket/widget/dep.cassius create mode 100644 templates/ticket/widget/dep.hamlet diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 2a4b8a8..3c11d95 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -81,6 +81,7 @@ import Vervis.TicketFilter (filterTickets) import Vervis.Time (showDate) import Vervis.Widget.Discussion (discussionW) import Vervis.Widget.Sharer (personLinkW) +import Vervis.Widget.Ticket getTicketsR :: ShrIdent -> PrjIdent -> Handler Html getTicketsR shar proj = do @@ -154,12 +155,11 @@ getTicketNewR shar proj = do getTicketR :: ShrIdent -> PrjIdent -> Int -> Handler Html getTicketR shar proj num = do mpid <- maybeAuthId - (author, massignee, closer, ticket) <- runDB $ do - ticket <- do + (author, massignee, closer, ticket, deps, rdeps) <- runDB $ do + Entity tid ticket <- do Entity s _ <- getBy404 $ UniqueSharer shar Entity p _ <- getBy404 $ UniqueProject proj s - Entity _ t <- getBy404 $ UniqueTicket p num - return t + getBy404 $ UniqueTicket p num author <- do person <- get404 $ ticketCreator ticket get404 $ personIdent person @@ -173,7 +173,15 @@ getTicketR shar proj num = do person <- get404 $ ticketCloser ticket get404 $ personIdent person else return author - return (author, massignee, closer, ticket) + deps <- select $ from $ \ (dep `InnerJoin` t) -> do + on $ dep ^. TicketDependencyChild E.==. t ^. TicketId + where_ $ dep ^. TicketDependencyParent E.==. val tid + return t + rdeps <- select $ from $ \ (dep `InnerJoin` t) -> do + on $ dep ^. TicketDependencyParent E.==. t ^. TicketId + where_ $ dep ^. TicketDependencyChild E.==. val tid + return t + return (author, massignee, closer, ticket, deps, rdeps) let desc = renderSourceT Markdown $ T.filter (/= '\r') $ ticketDesc ticket discuss = discussionW diff --git a/src/Vervis/Widget/Ticket.hs b/src/Vervis/Widget/Ticket.hs new file mode 100644 index 0000000..70f73c5 --- /dev/null +++ b/src/Vervis/Widget/Ticket.hs @@ -0,0 +1,39 @@ +{- This file is part of Vervis. + - + - Written in 2016 by fr33domlover . + - + - ♡ Copying is an act of love. Please copy, reuse and share. + - + - The author(s) have dedicated all copyright and related and neighboring + - rights to this software to the public domain worldwide. This software is + - distributed without any warranty. + - + - You should have received a copy of the CC0 Public Domain Dedication along + - with this software. If not, see + - . + -} + +module Vervis.Widget.Ticket + ( ticketDepW + ) +where + +import Prelude + +import Yesod.Core (Route) +import Yesod.Core.Handler (getUrlRender) +import Yesod.Core (newIdent) + +import qualified Data.Text as T (unpack) + +import Vervis.Foundation +import Vervis.Model +import Vervis.Model.Ident +import Vervis.Settings (widgetFile) +import Vervis.Style + +ticketDepW :: ShrIdent -> PrjIdent -> Ticket -> Widget +ticketDepW shr prj ticket = do + todoC <- newIdent + doneC <- newIdent + $(widgetFile "ticket/widget/dep") diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index bc16390..5767037 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -20,10 +20,24 @@ $# .

- Depended by: TODO + Depended by: + +

    + $if null rdeps +
  • (none) + $else + $forall Entity _ t <- rdeps + ^{ticketDepW shar proj t}

    - Depends on: TODO + Depends on: + +

      + $if null deps +
    • (none) + $else + $forall Entity _ t <- deps + ^{ticketDepW shar proj t}

      Created on #{showDate $ ticketCreated ticket} by diff --git a/templates/ticket/widget/dep.cassius b/templates/ticket/widget/dep.cassius new file mode 100644 index 0000000..852398a --- /dev/null +++ b/templates/ticket/widget/dep.cassius @@ -0,0 +1,20 @@ +/* This file is part of Vervis. + * + * Written in 2016 by fr33domlover . + * + * ♡ Copying is an act of love. Please copy, reuse and share. + * + * The author(s) have dedicated all copyright and related and neighboring + * rights to this software to the public domain worldwide. This software is + * distributed without any warranty. + * + * You should have received a copy of the CC0 Public Domain Dedication along + * with this software. If not, see + * . + */ + +.#{todoC} + color: #{dark red} + +.#{doneC} + color: #{dark green} diff --git a/templates/ticket/widget/dep.hamlet b/templates/ticket/widget/dep.hamlet new file mode 100644 index 0000000..f6f8083 --- /dev/null +++ b/templates/ticket/widget/dep.hamlet @@ -0,0 +1,22 @@ +$# This file is part of Vervis. +$# +$# Written in 2016 by fr33domlover . +$# +$# ♡ Copying is an act of love. Please copy, reuse and share. +$# +$# The author(s) have dedicated all copyright and related and neighboring +$# rights to this software to the public domain worldwide. This software is +$# distributed without any warranty. +$# +$# You should have received a copy of the CC0 Public Domain Dedication along +$# with this software. If not, see +$# . + +$if ticketDone ticket + + ☒ +$else + + ☐ + + #{ticketTitle ticket} diff --git a/vervis.cabal b/vervis.cabal index deede81..bb31068 100644 --- a/vervis.cabal +++ b/vervis.cabal @@ -151,6 +151,7 @@ library Vervis.Widget.Repo Vervis.Widget.Role Vervis.Widget.Sharer + Vervis.Widget.Ticket Vervis.Wiki -- other-modules: default-extensions: TemplateHaskell