diff --git a/src/Vervis/Widget/Ticket.hs b/src/Vervis/Widget/Ticket.hs index 70f73c5..e79577f 100644 --- a/src/Vervis/Widget/Ticket.hs +++ b/src/Vervis/Widget/Ticket.hs @@ -14,26 +14,57 @@ -} module Vervis.Widget.Ticket - ( ticketDepW + ( TicketSummary (..) + , ticketDepW + , ticketSummaryW ) where import Prelude -import Yesod.Core (Route) -import Yesod.Core.Handler (getUrlRender) +import Control.Arrow ((***)) +import Data.HashMap.Lazy (HashMap) +import Data.Text (Text) +import Data.Time.Clock (UTCTime) +import Yesod.Core.Handler (getCurrentRoute) import Yesod.Core (newIdent) -import qualified Data.Text as T (unpack) +import qualified Data.HashMap.Lazy as M (toList) +import qualified Data.Text as T (pack, unpack) import Vervis.Foundation import Vervis.Model import Vervis.Model.Ident import Vervis.Settings (widgetFile) import Vervis.Style +import Vervis.Time (showDate) +import Vervis.Widget.Sharer (personLinkW) + +data TicketSummary = TicketSummary + { tsNumber :: Int + , tsCreatedBy :: Sharer + , tsCreatedAt :: UTCTime + , tsTitle :: Text + , tsDone :: Bool + , tsComments :: Int + } ticketDepW :: ShrIdent -> PrjIdent -> Ticket -> Widget ticketDepW shr prj ticket = do - todoC <- newIdent - doneC <- newIdent + cTodo <- newIdent + cDone <- newIdent $(widgetFile "ticket/widget/dep") + +ticketSummaryW + :: ShrIdent + -> PrjIdent + -> TicketSummary + -> Maybe (HashMap Int Int) + -> Widget +ticketSummaryW shr prj ts mcs = do + cTodo <- newIdent + cDone <- newIdent + let tshow = T.pack . show + mparams = map (tshow *** tshow) . M.toList <$> mcs + mroute <- getCurrentRoute + $(widgetFile "ticket/widget/summary") diff --git a/templates/ticket/widget/dep.cassius b/templates/ticket/widget/dep.cassius index 852398a..9456d48 100644 --- a/templates/ticket/widget/dep.cassius +++ b/templates/ticket/widget/dep.cassius @@ -13,8 +13,8 @@ * . */ -.#{todoC} +.#{cTodo} color: #{dark red} -.#{doneC} +.#{cDone} color: #{dark green} diff --git a/templates/ticket/widget/dep.hamlet b/templates/ticket/widget/dep.hamlet index f6f8083..771bff2 100644 --- a/templates/ticket/widget/dep.hamlet +++ b/templates/ticket/widget/dep.hamlet @@ -13,10 +13,10 @@ $# with this software. If not, see $# . $if ticketDone ticket - + ☒ $else - + #{ticketTitle ticket} diff --git a/templates/ticket/widget/summary.cassius b/templates/ticket/widget/summary.cassius new file mode 100644 index 0000000..9456d48 --- /dev/null +++ b/templates/ticket/widget/summary.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 + * . + */ + +.#{cTodo} + color: #{dark red} + +.#{cDone} + color: #{dark green} diff --git a/templates/ticket/widget/summary.hamlet b/templates/ticket/widget/summary.hamlet new file mode 100644 index 0000000..ac7a8cc --- /dev/null +++ b/templates/ticket/widget/summary.hamlet @@ -0,0 +1,47 @@ +$# 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 +$# . + +