Display tickets in list view the same as in tree view

This commit is contained in:
fr33domlover 2018-06-17 10:29:51 +00:00
parent e29280959b
commit 6088b1e117
4 changed files with 24 additions and 50 deletions

View file

@ -112,18 +112,10 @@ getTicketsR shr prj = do
rows <- runDB $ do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity jid _ <- getBy404 $ UniqueProject prj sid
select $ from $ \ (ticket `InnerJoin` person `InnerJoin` sharer) -> do
on $ person ^. PersonIdent ==. sharer ^. SharerId
on $ ticket ^. TicketCreator ==. person ^. PersonId
where_ $ filterTickets tf ticket $
ticket ^. TicketProject ==. val jid
orderBy [asc $ ticket ^. TicketNumber]
return
( ticket ^. TicketNumber
, sharer
, ticket ^. TicketTitle
, ticket ^. TicketStatus
)
getTicketSummaries
(filterTickets tf)
(Just $ \ t -> [asc $ t ^. TicketNumber])
jid
defaultLayout $(widgetFile "ticket/list")
postTicketsR :: ShrIdent -> PrjIdent -> Handler Html
@ -185,7 +177,7 @@ getTicketTreeR shr prj = do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity jid _ <- getBy404 $ UniqueProject prj sid
liftA2 (,)
(getTicketSummaries jid)
(getTicketSummaries Nothing Nothing jid)
(getTicketDepEdges jid)
defaultLayout $ ticketTreeDW shr prj summaries deps

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis.
-
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -31,6 +31,7 @@ where
import Prelude
import Control.Arrow ((***))
import Data.Foldable (for_)
import Data.Text (Text)
import Database.Esqueleto
@ -41,8 +42,12 @@ import Vervis.Model.Workflow
import Vervis.Widget.Ticket (TicketSummary (..))
-- | Get summaries of all the tickets in the given project.
getTicketSummaries :: ProjectId -> AppDB [TicketSummary]
getTicketSummaries jid = do
getTicketSummaries
:: Maybe (SqlExpr (Entity Ticket) -> SqlExpr (Value Bool))
-> Maybe (SqlExpr (Entity Ticket) -> [SqlExpr OrderBy])
-> ProjectId
-> AppDB [TicketSummary]
getTicketSummaries mfilt morder jid = do
let toSummary (Value n, Entity _ s, Value c, Value t, Value d, Value r) =
TicketSummary
{ tsNumber = n
@ -58,6 +63,8 @@ getTicketSummaries jid = do
on $ p ^. PersonIdent ==. s ^. SharerId
on $ t ^. TicketCreator ==. p ^. PersonId
where_ $ t ^. TicketProject ==. val jid
for_ mfilt $ \ filt -> where_ $ filt t
for_ morder $ \ order -> orderBy $ order t
return
( t ^. TicketNumber
, s

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis.
-
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -36,23 +36,11 @@ instance Default TicketFilter where
{ tfStatus = Nothing
}
ticketFilter
:: Esqueleto q e b
=> TicketFilter
-> e (Entity Ticket)
-> Maybe (e (Value Bool))
ticketFilter tf ticket =
case tfStatus tf of
Nothing -> Nothing
Just t -> Just $ ticket ^. TicketStatus ==. val t
filterTickets
:: Esqueleto q e b
=> TicketFilter
-> e (Entity Ticket)
-> e (Value Bool)
-> e (Value Bool)
filterTickets tf ticket cond =
case ticketFilter tf ticket of
Nothing -> cond
Just f -> cond &&. f
-> Maybe (e (Entity Ticket) -> e (Value Bool))
filterTickets tf =
case tfStatus tf of
Nothing -> Nothing
Just s -> Just $ \ t -> t ^. TicketStatus ==. val s

View file

@ -22,19 +22,6 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
^{filtWidget}
<input type="submit" value="Filter">
<table>
<tr>
<th>Number
<th>Author
<th>Title
<th>Status
$forall (Value number, Entity _ author, Value title, Value status) <- rows
<tr>
<td>
<a href=@{TicketR shr prj number}>#{number}
<td>
^{personLinkW author}
<td>
<a href=@{TicketR shr prj number}>#{title}
<td>
#{show status}
<ul>
$forall ts <- rows
<li>^{ticketSummaryW shr prj ts Nothing}