mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 18:04:53 +09:00
Ticket summary widget
This commit is contained in:
parent
7ebf189e93
commit
fe7aeb5162
5 changed files with 108 additions and 10 deletions
|
@ -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")
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
.#{todoC}
|
||||
.#{cTodo}
|
||||
color: #{dark red}
|
||||
|
||||
.#{doneC}
|
||||
.#{cDone}
|
||||
color: #{dark green}
|
||||
|
|
|
@ -13,10 +13,10 @@ $# with this software. If not, see
|
|||
$# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
$if ticketDone ticket
|
||||
<span .#{doneC}>
|
||||
<span .#{cDone}>
|
||||
☒
|
||||
$else
|
||||
<span .#{todoC}>
|
||||
<span .#{cTodo}>
|
||||
☐
|
||||
<a href=@{TicketR shr prj $ ticketNumber ticket}>
|
||||
#{ticketTitle ticket}
|
||||
|
|
20
templates/ticket/widget/summary.cassius
Normal file
20
templates/ticket/widget/summary.cassius
Normal 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}
|
47
templates/ticket/widget/summary.hamlet
Normal file
47
templates/ticket/widget/summary.hamlet
Normal 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}">
|
Loading…
Reference in a new issue