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 creator PersonId
title Text title Text
desc Text -- Assume this is Pandoc Markdown desc Text -- Assume this is Pandoc Markdown
assignee PersonId Maybe
done Bool done Bool
closed UTCTime closed UTCTime
closer PersonId closer PersonId

View file

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

View file

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

View file

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