1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 01:54:50 +09:00

Ticket summary widget

This commit is contained in:
fr33domlover 2016-08-04 00:40:29 +00:00
parent 7ebf189e93
commit fe7aeb5162
5 changed files with 108 additions and 10 deletions

View file

@ -14,26 +14,57 @@
-} -}
module Vervis.Widget.Ticket module Vervis.Widget.Ticket
( ticketDepW ( TicketSummary (..)
, ticketDepW
, ticketSummaryW
) )
where where
import Prelude import Prelude
import Yesod.Core (Route) import Control.Arrow ((***))
import Yesod.Core.Handler (getUrlRender) import Data.HashMap.Lazy (HashMap)
import Data.Text (Text)
import Data.Time.Clock (UTCTime)
import Yesod.Core.Handler (getCurrentRoute)
import Yesod.Core (newIdent) 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.Foundation
import Vervis.Model import Vervis.Model
import Vervis.Model.Ident import Vervis.Model.Ident
import Vervis.Settings (widgetFile) import Vervis.Settings (widgetFile)
import Vervis.Style 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 :: ShrIdent -> PrjIdent -> Ticket -> Widget
ticketDepW shr prj ticket = do ticketDepW shr prj ticket = do
todoC <- newIdent cTodo <- newIdent
doneC <- newIdent cDone <- newIdent
$(widgetFile "ticket/widget/dep") $(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")

View file

@ -13,8 +13,8 @@
* <http://creativecommons.org/publicdomain/zero/1.0/>. * <http://creativecommons.org/publicdomain/zero/1.0/>.
*/ */
.#{todoC} .#{cTodo}
color: #{dark red} color: #{dark red}
.#{doneC} .#{cDone}
color: #{dark green} color: #{dark green}

View file

@ -13,10 +13,10 @@ $# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>. $# <http://creativecommons.org/publicdomain/zero/1.0/>.
$if ticketDone ticket $if ticketDone ticket
<span .#{doneC}> <span .#{cDone}>
$else $else
<span .#{todoC}> <span .#{cTodo}>
<a href=@{TicketR shr prj $ ticketNumber ticket}> <a href=@{TicketR shr prj $ ticketNumber ticket}>
#{ticketTitle ticket} #{ticketTitle ticket}

View file

@ -0,0 +1,20 @@
/* This file is part of Vervis.
*
* Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
*
* ♡ 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
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
.#{cTodo}
color: #{dark red}
.#{cDone}
color: #{dark green}

View file

@ -0,0 +1,47 @@
$# This file is part of Vervis.
$#
$# Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
$#
$# ♡ 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
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
<div>
$if tsDone ts
<span .#{cDone}>
$else
<span .#{cTodo}>
<a href=@{TicketR shr prj $ tsNumber ts}>
#{tsNumber ts}
<span>
#{showDate $ tsCreatedAt ts}
^{personLinkW $ tsCreatedBy ts}
<a href=@{TicketR shr prj $ tsNumber ts}>
#{tsTitle ts}
$if tsComments ts > 0
<span>
💬
#{tsComments ts}
$maybe params <- mparams
<div>
<a href="#node-#{tsNumber ts}" title="Jump to subtree">
$maybe route <- mroute
<a href=@?{(route, params)} title="Move subtree here">
$nothing
<a id="node-#{tsNumber ts}">