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

View file

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

View file

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

View file

@ -22,19 +22,6 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
^{filtWidget} ^{filtWidget}
<input type="submit" value="Filter"> <input type="submit" value="Filter">
<table> <ul>
<tr> $forall ts <- rows
<th>Number <li>^{ticketSummaryW shr prj ts Nothing}
<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}