Display custom ticket field values in ticket page

This commit is contained in:
fr33domlover 2016-08-08 20:51:58 +00:00
parent ec7dd4ee7e
commit 35933061c9
3 changed files with 80 additions and 27 deletions

View file

@ -189,6 +189,13 @@ WorkflowFieldEnumCtor
UniqueWorkflowFieldEnumCtor enum name
TicketParamText
ticket TicketId
field WorkflowFieldId
value Text
UniqueTicketParamText ticket field
Ticket
project ProjectId
number Int

View file

@ -84,6 +84,7 @@ import Vervis.GraphProxy (ticketDepGraph)
import Vervis.MediaType (MediaType (Markdown))
import Vervis.Model
import Vervis.Model.Ident
import Vervis.Model.Workflow
import Vervis.Render (renderSourceT)
import Vervis.Settings (widgetFile)
import Vervis.Ticket
@ -175,33 +176,62 @@ getTicketNewR shar proj = do
getTicketR :: ShrIdent -> PrjIdent -> Int -> Handler Html
getTicketR shar proj num = do
mpid <- maybeAuthId
(author, massignee, closer, ticket, deps, rdeps) <- runDB $ do
Entity tid ticket <- do
Entity s _ <- getBy404 $ UniqueSharer shar
Entity p _ <- getBy404 $ UniqueProject proj s
getBy404 $ UniqueTicket p num
author <- do
person <- get404 $ ticketCreator ticket
get404 $ personIdent person
massignee <- for (ticketAssignee ticket) $ \ apid -> do
person <- get404 apid
sharer <- get404 $ personIdent person
return (sharer, fromMaybe False $ (== apid) <$> mpid)
closer <-
if ticketDone ticket
then do
person <- get404 $ ticketCloser ticket
get404 $ personIdent person
else return author
deps <- select $ from $ \ (dep `InnerJoin` t) -> do
on $ dep ^. TicketDependencyChild E.==. t ^. TicketId
where_ $ dep ^. TicketDependencyParent E.==. val tid
return t
rdeps <- select $ from $ \ (dep `InnerJoin` t) -> do
on $ dep ^. TicketDependencyParent E.==. t ^. TicketId
where_ $ dep ^. TicketDependencyChild E.==. val tid
return t
return (author, massignee, closer, ticket, deps, rdeps)
(wshr, wfl, author, massignee, closer, ticket, tparams, deps, rdeps) <-
runDB $ do
(jid, wshr, wid, wfl) <- do
Entity s sharer <- getBy404 $ UniqueSharer shar
Entity p project <- getBy404 $ UniqueProject proj s
w <- get404 $ projectWorkflow project
wsharer <-
if workflowSharer w == s
then return sharer
else get404 $ workflowSharer w
return
( p
, sharerIdent wsharer
, projectWorkflow project
, workflowIdent w
)
Entity tid ticket <- getBy404 $ UniqueTicket jid num
author <- do
person <- get404 $ ticketCreator ticket
get404 $ personIdent person
massignee <- for (ticketAssignee ticket) $ \ apid -> do
person <- get404 apid
sharer <- get404 $ personIdent person
return (sharer, fromMaybe False $ (== apid) <$> mpid)
closer <-
if ticketDone ticket
then do
person <- get404 $ ticketCloser ticket
get404 $ personIdent person
else return author
tparams <- select $ from $ \ (f `LeftOuterJoin` p) -> do
on $
just (f ^. WorkflowFieldId) E.==. p ?. TicketParamTextField
&&.
p ?. TicketParamTextTicket E.==. just (val tid)
where_ $
f ^. WorkflowFieldWorkflow E.==. val wid &&.
f ^. WorkflowFieldType E.==. val WFTText
return
( f ^. WorkflowFieldIdent
, f ^. WorkflowFieldName
, f ^. WorkflowFieldRequired
, p ?. TicketParamTextValue
)
deps <- select $ from $ \ (dep `InnerJoin` t) -> do
on $ dep ^. TicketDependencyChild E.==. t ^. TicketId
where_ $ dep ^. TicketDependencyParent E.==. val tid
return t
rdeps <- select $ from $ \ (dep `InnerJoin` t) -> do
on $ dep ^. TicketDependencyParent E.==. t ^. TicketId
where_ $ dep ^. TicketDependencyChild E.==. val tid
return t
return
( wshr, wfl
, author, massignee, closer, ticket, tparams, deps, rdeps
)
let desc = renderSourceT Markdown $ T.filter (/= '\r') $ ticketDesc ticket
discuss =
discussionW

View file

@ -100,6 +100,22 @@ $if not $ ticketDone ticket
^{desc}
<h3>Custom fields
<ul>
$forall (Value fld, Value name, Value req, Value mvalue) <- tparams
<li>
<a href=@{WorkflowFieldR wshr wfl fld}>
#{name}
:
$maybe value <- mvalue
#{value}
$nothing
$if req
NO VALUE FOR REQUIRED FIELD
$else
(none)
<h3>Discussion
^{discuss}