UI: In ticket view, display filter as 3 checkboxes, default is open tickets
This commit is contained in:
parent
0031801a74
commit
73cfaf7ceb
2 changed files with 19 additions and 9 deletions
|
@ -225,8 +225,18 @@ claimRequestForm :: Form Text
|
|||
claimRequestForm = renderDivs claimRequestAForm
|
||||
|
||||
ticketFilterAForm :: AForm Handler TicketFilter
|
||||
ticketFilterAForm = TicketFilter
|
||||
<$> aopt (selectField optionsEnum) "Status*" (Just Nothing)
|
||||
ticketFilterAForm = mk
|
||||
<$> areq checkBoxField "New" (Just True)
|
||||
<*> areq checkBoxField "To-do" (Just True)
|
||||
<*> 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 = renderDivs ticketFilterAForm
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{- This file is part of Vervis.
|
||||
-
|
||||
- Written in 2016, 2018 by fr33domlover <fr33domlover@riseup.net>.
|
||||
- Written in 2016, 2018, 2019 by fr33domlover <fr33domlover@riseup.net>.
|
||||
-
|
||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||
-
|
||||
|
@ -26,19 +26,19 @@ import Vervis.Model
|
|||
import Vervis.Model.Ticket
|
||||
|
||||
data TicketFilter = TicketFilter
|
||||
{ tfStatus :: Maybe TicketStatus
|
||||
{ tfStatus :: [TicketStatus]
|
||||
}
|
||||
|
||||
instance Default TicketFilter where
|
||||
def = TicketFilter
|
||||
{ tfStatus = Nothing
|
||||
{ tfStatus = []
|
||||
}
|
||||
|
||||
filterTickets
|
||||
:: Esqueleto q e b
|
||||
=> TicketFilter
|
||||
-> Maybe (e (Entity Ticket) -> e (Value Bool))
|
||||
filterTickets tf =
|
||||
case tfStatus tf of
|
||||
Nothing -> Nothing
|
||||
Just s -> Just $ \ t -> t ^. TicketStatus ==. val s
|
||||
filterTickets (TicketFilter s) =
|
||||
if null s
|
||||
then Nothing
|
||||
else Just $ \ t -> t ^. TicketStatus `in_` valList s
|
||||
|
|
Loading…
Reference in a new issue