diff --git a/config/models b/config/models index 59af360..2dd69aa 100644 --- a/config/models +++ b/config/models @@ -189,6 +189,13 @@ WorkflowFieldEnumCtor UniqueWorkflowFieldEnumCtor enum name +TicketParamText + ticket TicketId + field WorkflowFieldId + value Text + + UniqueTicketParamText ticket field + Ticket project ProjectId number Int diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 50c1916..08e0e68 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -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 diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index ceb469a..f4310b2 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -100,6 +100,22 @@ $if not $ ticketDone ticket ^{desc} +