UI, DB: Switch ticket filter to use TicketResolve instead of TicketStatus

This commit is contained in:
fr33domlover 2022-10-16 23:44:16 +00:00
parent 7ddb79d78d
commit d8c65930ca
6 changed files with 45 additions and 55 deletions

View file

@ -262,18 +262,9 @@ claimRequestForm = renderDivs claimRequestAForm
-} -}
ticketFilterAForm :: AForm Handler TicketFilter ticketFilterAForm :: AForm Handler TicketFilter
ticketFilterAForm = mk ticketFilterAForm = TicketFilter
<$> areq checkBoxField "New" (Just True) <$> areq checkBoxField "Open" (Just True)
<*> areq checkBoxField "To-do" (Just True)
<*> areq checkBoxField "Closed" (Just False) <*> areq checkBoxField "Closed" (Just False)
where
mk new todo closed =
TicketFilter $
catMaybes
[result new TSNew, result todo TSTodo, result closed TSClosed]
where
result False _ = Nothing
result True s = Just s
ticketFilterForm :: Form TicketFilter ticketFilterForm :: Form TicketFilter
ticketFilterForm = renderDivs ticketFilterAForm ticketFilterForm = renderDivs ticketFilterAForm

View file

@ -97,7 +97,7 @@ import Vervis.Widget.Ticket
-- | Get summaries of all the tickets in the given project. -- | Get summaries of all the tickets in the given project.
getTicketSummaries getTicketSummaries
:: Maybe (E.SqlExpr (Entity Ticket) -> E.SqlExpr (E.Value Bool)) :: Maybe (E.SqlExpr (Maybe (Entity TicketResolve)) -> E.SqlExpr (E.Value Bool))
-> Maybe (E.SqlExpr (Entity Ticket) -> [E.SqlExpr E.OrderBy]) -> Maybe (E.SqlExpr (Entity Ticket) -> [E.SqlExpr E.OrderBy])
-> Maybe (Int, Int) -> Maybe (Int, Int)
-> DeckId -> DeckId
@ -108,12 +108,15 @@ getTicketSummaries mfilt morder offlim deckID = do
`E.InnerJoin` td `E.InnerJoin` td
`E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` a) `E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` a)
`E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i) `E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i)
`E.LeftOuterJoin` tr
`E.InnerJoin` d `E.InnerJoin` d
`E.LeftOuterJoin` m `E.LeftOuterJoin` m
) -> do ) -> do
E.on $ E.just (d E.^. DiscussionId) E.==. m E.?. MessageRoot E.on $ E.just (d E.^. DiscussionId) E.==. m E.?. MessageRoot
E.on $ t E.^. TicketDiscuss E.==. d E.^. DiscussionId E.on $ t E.^. TicketDiscuss E.==. d E.^. DiscussionId
E.on $ E.just (t E.^. TicketId) E.==. tr E.?. TicketResolveTicket
E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId
E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId
E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId
@ -127,11 +130,12 @@ getTicketSummaries mfilt morder offlim deckID = do
E.where_ $ td E.^. TicketDeckDeck E.==. E.val deckID E.where_ $ td E.^. TicketDeckDeck E.==. E.val deckID
E.groupBy E.groupBy
( t E.^. TicketId, td E.^. TicketDeckId ( (t E.^. TicketId, td E.^. TicketDeckId)
, tr E.?. TicketResolveId
, tal E.?. TicketAuthorLocalId, p E.?. PersonId, a E.?. ActorId , tal E.?. TicketAuthorLocalId, p E.?. PersonId, a E.?. ActorId
, ra E.?. RemoteActorId, ro E.?. RemoteObjectId, i E.?. InstanceId , ra E.?. RemoteActorId, ro E.?. RemoteObjectId, i E.?. InstanceId
) )
for_ mfilt $ \ filt -> E.where_ $ filt t for_ mfilt $ \ filt -> E.where_ $ filt tr
for_ morder $ \ order -> E.orderBy $ order t for_ morder $ \ order -> E.orderBy $ order t
for_ offlim $ \ (off, lim) -> do for_ offlim $ \ (off, lim) -> do
E.offset $ fromIntegral off E.offset $ fromIntegral off
@ -144,12 +148,12 @@ getTicketSummaries mfilt morder offlim deckID = do
, i, ro, ra , i, ro, ra
, t E.^. TicketCreated , t E.^. TicketCreated
, t E.^. TicketTitle , t E.^. TicketTitle
, t E.^. TicketStatus , tr E.?. TicketResolveId
, E.count $ m E.?. MessageId , E.count $ m E.?. MessageId
) )
for tickets $ for tickets $
\ (E.Value tid, E.Value tdid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value d, E.Value r) -> do \ (E.Value tid, E.Value tdid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value mc, E.Value r) -> do
labels <- E.select $ E.from $ \ (tpc `E.InnerJoin` wf) -> do labels <- E.select $ E.from $ \ (tpc `E.InnerJoin` wf) -> do
E.on $ tpc E.^. TicketParamClassField E.==. wf E.^. WorkflowFieldId E.on $ tpc E.^. TicketParamClassField E.==. wf E.^. WorkflowFieldId
E.where_ $ tpc E.^. TicketParamClassTicket E.==. E.val tid E.where_ $ tpc E.^. TicketParamClassTicket E.==. E.val tid
@ -166,12 +170,12 @@ getTicketSummaries mfilt morder offlim deckID = do
, tsCreatedAt = c , tsCreatedAt = c
, tsTitle = t , tsTitle = t
, tsLabels = map entityVal labels , tsLabels = map entityVal labels
, tsStatus = d , tsClosed = isJust mc
, tsComments = r , tsComments = r
} }
getClothSummaries getClothSummaries
:: Maybe (E.SqlExpr (Entity Ticket) -> E.SqlExpr (E.Value Bool)) :: Maybe (E.SqlExpr (Maybe (Entity TicketResolve)) -> E.SqlExpr (E.Value Bool))
-> Maybe (E.SqlExpr (Entity Ticket) -> [E.SqlExpr E.OrderBy]) -> Maybe (E.SqlExpr (Entity Ticket) -> [E.SqlExpr E.OrderBy])
-> Maybe (Int, Int) -> Maybe (Int, Int)
-> LoomId -> LoomId
@ -182,12 +186,15 @@ getClothSummaries mfilt morder offlim loomID = do
`E.InnerJoin` tl `E.InnerJoin` tl
`E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` a) `E.LeftOuterJoin` (tal `E.InnerJoin` p `E.InnerJoin` a)
`E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i) `E.LeftOuterJoin` (tar `E.InnerJoin` ra `E.InnerJoin` ro `E.InnerJoin` i)
`E.LeftOuterJoin` tr
`E.InnerJoin` d `E.InnerJoin` d
`E.LeftOuterJoin` m `E.LeftOuterJoin` m
) -> do ) -> do
E.on $ E.just (d E.^. DiscussionId) E.==. m E.?. MessageRoot E.on $ E.just (d E.^. DiscussionId) E.==. m E.?. MessageRoot
E.on $ t E.^. TicketDiscuss E.==. d E.^. DiscussionId E.on $ t E.^. TicketDiscuss E.==. d E.^. DiscussionId
E.on $ E.just (t E.^. TicketId) E.==. tr E.?. TicketResolveTicket
E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId E.on $ ro E.?. RemoteObjectInstance E.==. i E.?. InstanceId
E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId E.on $ ra E.?. RemoteActorIdent E.==. ro E.?. RemoteObjectId
E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId E.on $ tar E.?. TicketAuthorRemoteAuthor E.==. ra E.?. RemoteActorId
@ -201,11 +208,12 @@ getClothSummaries mfilt morder offlim loomID = do
E.where_ $ tl E.^. TicketLoomLoom E.==. E.val loomID E.where_ $ tl E.^. TicketLoomLoom E.==. E.val loomID
E.groupBy E.groupBy
( t E.^. TicketId, tl E.^. TicketLoomId ( (t E.^. TicketId, tl E.^. TicketLoomId)
, tr E.?. TicketResolveId
, tal E.?. TicketAuthorLocalId, p E.?. PersonId, a E.?. ActorId , tal E.?. TicketAuthorLocalId, p E.?. PersonId, a E.?. ActorId
, ra E.?. RemoteActorId, ro E.?. RemoteObjectId, i E.?. InstanceId , ra E.?. RemoteActorId, ro E.?. RemoteObjectId, i E.?. InstanceId
) )
for_ mfilt $ \ filt -> E.where_ $ filt t for_ mfilt $ \ filt -> E.where_ $ filt tr
for_ morder $ \ order -> E.orderBy $ order t for_ morder $ \ order -> E.orderBy $ order t
for_ offlim $ \ (off, lim) -> do for_ offlim $ \ (off, lim) -> do
E.offset $ fromIntegral off E.offset $ fromIntegral off
@ -218,12 +226,12 @@ getClothSummaries mfilt morder offlim loomID = do
, i, ro, ra , i, ro, ra
, t E.^. TicketCreated , t E.^. TicketCreated
, t E.^. TicketTitle , t E.^. TicketTitle
, t E.^. TicketStatus , tr E.?. TicketResolveId
, E.count $ m E.?. MessageId , E.count $ m E.?. MessageId
) )
for tickets $ for tickets $
\ (E.Value tid, E.Value tlid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value d, E.Value r) -> do \ (E.Value tid, E.Value tlid, mp, ma, mi, mro, mra, E.Value c, E.Value t, E.Value mc, E.Value r) -> do
labels <- E.select $ E.from $ \ (tpc `E.InnerJoin` wf) -> do labels <- E.select $ E.from $ \ (tpc `E.InnerJoin` wf) -> do
E.on $ tpc E.^. TicketParamClassField E.==. wf E.^. WorkflowFieldId E.on $ tpc E.^. TicketParamClassField E.==. wf E.^. WorkflowFieldId
E.where_ $ tpc E.^. TicketParamClassTicket E.==. E.val tid E.where_ $ tpc E.^. TicketParamClassTicket E.==. E.val tid
@ -240,7 +248,7 @@ getClothSummaries mfilt morder offlim loomID = do
, csCreatedAt = c , csCreatedAt = c
, csTitle = t , csTitle = t
, csLabels = map entityVal labels , csLabels = map entityVal labels
, csStatus = d , csClosed = isJust mc
, csComments = r , csComments = r
} }

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis. {- This file is part of Vervis.
- -
- Written in 2016, 2018, 2019 by fr33domlover <fr33domlover@riseup.net>. - Written in 2016, 2018, 2019, 2022 by fr33domlover <fr33domlover@riseup.net>.
- -
- Copying is an act of love. Please copy, reuse and share. - Copying is an act of love. Please copy, reuse and share.
- -
@ -26,19 +26,18 @@ import Vervis.Model
import Vervis.Model.Ticket import Vervis.Model.Ticket
data TicketFilter = TicketFilter data TicketFilter = TicketFilter
{ tfStatus :: [TicketStatus] { tfOpen :: Bool
, tfClosed :: Bool
} }
instance Default TicketFilter where instance Default TicketFilter where
def = TicketFilter def = TicketFilter True True
{ tfStatus = []
}
filterTickets filterTickets
:: Esqueleto q e b :: Esqueleto q e b
=> TicketFilter => TicketFilter
-> Maybe (e (Entity Ticket) -> e (Value Bool)) -> Maybe (e (Maybe (Entity TicketResolve)) -> e (Value Bool))
filterTickets (TicketFilter s) = filterTickets (TicketFilter False False) = Just $ \ _ -> val (0::Int) ==. val 1
if null s filterTickets (TicketFilter False True) = Just $ \ t -> not_ $ isNothing $ t ?. TicketResolveId
then Nothing filterTickets (TicketFilter True False) = Just $ \ t -> isNothing $ t ?. TicketResolveId
else Just $ \ t -> t ^. TicketStatus `in_` valList s filterTickets (TicketFilter True True) = Nothing

View file

@ -61,7 +61,7 @@ data TicketSummary = TicketSummary
, tsCreatedAt :: UTCTime , tsCreatedAt :: UTCTime
, tsTitle :: Text , tsTitle :: Text
, tsLabels :: [WorkflowField] , tsLabels :: [WorkflowField]
, tsStatus :: TicketStatus , tsClosed :: Bool
, tsComments :: Int , tsComments :: Int
} }
@ -73,7 +73,7 @@ data ClothSummary = ClothSummary
, csCreatedAt :: UTCTime , csCreatedAt :: UTCTime
, csTitle :: Text , csTitle :: Text
, csLabels :: [WorkflowField] , csLabels :: [WorkflowField]
, csStatus :: TicketStatus , csClosed :: Bool
, csComments :: Int , csComments :: Int
} }

View file

@ -13,16 +13,12 @@ $# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>. $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<span .ticket-status-column> <span .ticket-status-column>
$case csStatus cs $if csClosed cs
$of TSNew <span .#{cClosed}>
<span .#{cNew}>
$else
$of TSTodo <span .#{cTodo}>
<span .#{cTodo}>
$of TSClosed
<span .#{cClosed}>
<span .ticket-number-column> <span .ticket-number-column>
<a href=@{ticketRoute cs}> <a href=@{ticketRoute cs}>

View file

@ -13,16 +13,12 @@ $# with this software. If not, see
$# <http://creativecommons.org/publicdomain/zero/1.0/>. $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<span .ticket-status-column> <span .ticket-status-column>
$case tsStatus ts $if tsClosed ts
$of TSNew <span .#{cClosed}>
<span .#{cNew}>
$else
$of TSTodo <span .#{cTodo}>
<span .#{cTodo}>
$of TSClosed
<span .#{cClosed}>
<span .ticket-number-column> <span .ticket-number-column>
<a href=@{ticketRoute ts}> <a href=@{ticketRoute ts}>