Ticket assignee field

This commit is contained in:
fr33domlover 2016-06-01 16:20:19 +00:00
parent 4e0e8cb736
commit e398c86854
4 changed files with 45 additions and 29 deletions

View file

@ -123,6 +123,7 @@ Ticket
creator PersonId
title Text
desc Text -- Assume this is Pandoc Markdown
assignee PersonId Maybe
done Bool
closed UTCTime
closer PersonId

View file

@ -70,6 +70,7 @@ editTicketAForm ticket pid = fmap fixDone $ Ticket
"Description (Markdown)"
(Just $ Just $ Textarea $ ticketDesc ticket)
)
<*> pure (ticketAssignee ticket)
<*> areq checkBoxField "Done*" (Just $ ticketDone ticket)
<*> now
<*> pure (ticketCloser ticket)

View file

@ -40,6 +40,7 @@ import Data.Text (Text)
import Data.Time.Calendar (Day (..))
import Data.Time.Clock (UTCTime (..), getCurrentTime)
import Data.Time.Format (formatTime, defaultTimeLocale)
import Data.Traversable (for)
import Database.Esqueleto hiding ((==.), (+=.), update)
import Database.Persist
import Text.Blaze.Html (Html, toHtml)
@ -112,6 +113,7 @@ postTicketsR shar proj = do
, ticketCreator = author
, ticketTitle = ntTitle nt
, ticketDesc = ntDesc nt
, ticketAssignee = Nothing
, ticketDone = False
, ticketClosed = UTCTime (ModifiedJulianDay 0) 0
, ticketCloser = author
@ -135,19 +137,25 @@ getTicketNewR shar proj = do
getTicketR :: ShrIdent -> PrjIdent -> Int -> Handler Html
getTicketR shar proj num = do
(author, closer, ticket) <- runDB $ do
Entity sid _sharer <- getBy404 $ UniqueSharer shar
Entity pid _project <- getBy404 $ UniqueProject proj sid
Entity _tid ticket <- getBy404 $ UniqueTicket pid num
(author, massignee, closer, ticket) <- runDB $ do
ticket <- do
Entity s _ <- getBy404 $ UniqueSharer shar
Entity p _ <- getBy404 $ UniqueProject proj s
Entity _ t <- getBy404 $ UniqueTicket p num
return t
author <- do
person <- get404 $ ticketCreator ticket
author <- get404 $ personIdent person
get404 $ personIdent person
massignee <- for (ticketAssignee ticket) $ \ pid -> do
person <- get404 pid
get404 $ personIdent person
closer <-
if ticketDone ticket
then do
person' <- get404 $ ticketCloser ticket
get404 $ personIdent person'
person <- get404 $ ticketCloser ticket
get404 $ personIdent person
else return author
return (author, closer, ticket)
return (author, massignee, closer, ticket)
let desc = renderSourceT Markdown $ T.filter (/= '\r') $ ticketDesc ticket
discuss =
discussionW

View file

@ -23,6 +23,12 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
Created on #{formatTime defaultTimeLocale "%F" $ ticketCreated ticket} by
^{personLinkW author}
<p>
$maybe assignee <- massignee
Assigned to ^{personLinkW assignee}
$nothing
Not assigned
<p>
Status:
$if ticketDone ticket