diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 6085284..732d27f 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -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 diff --git a/src/Vervis/Ticket.hs b/src/Vervis/Ticket.hs index 91b715d..170213b 100644 --- a/src/Vervis/Ticket.hs +++ b/src/Vervis/Ticket.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016 by fr33domlover . + - Written in 2016, 2018 by fr33domlover . - - ♡ 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 diff --git a/src/Vervis/TicketFilter.hs b/src/Vervis/TicketFilter.hs index f72824f..ad9d38f 100644 --- a/src/Vervis/TicketFilter.hs +++ b/src/Vervis/TicketFilter.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016 by fr33domlover . + - Written in 2016, 2018 by fr33domlover . - - ♡ 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 diff --git a/templates/ticket/list.hamlet b/templates/ticket/list.hamlet index f2f191b..eb291bd 100644 --- a/templates/ticket/list.hamlet +++ b/templates/ticket/list.hamlet @@ -22,19 +22,6 @@ $# . ^{filtWidget} - - - -
Number - Author - Title - Status - $forall (Value number, Entity _ author, Value title, Value status) <- rows -
- #{number} - - ^{personLinkW author} - - #{title} - - #{show status} +
    + $forall ts <- rows +
  • ^{ticketSummaryW shr prj ts Nothing}