1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 01:44:53 +09:00

UI: In ticket view, display filter as 3 checkboxes, default is open tickets

This commit is contained in:
fr33domlover 2019-11-07 10:46:25 +00:00
parent 0031801a74
commit 73cfaf7ceb
2 changed files with 19 additions and 9 deletions

View file

@ -225,8 +225,18 @@ claimRequestForm :: Form Text
claimRequestForm = renderDivs claimRequestAForm claimRequestForm = renderDivs claimRequestAForm
ticketFilterAForm :: AForm Handler TicketFilter ticketFilterAForm :: AForm Handler TicketFilter
ticketFilterAForm = TicketFilter ticketFilterAForm = mk
<$> aopt (selectField optionsEnum) "Status*" (Just Nothing) <$> 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 :: Form TicketFilter
ticketFilterForm = renderDivs ticketFilterAForm ticketFilterForm = renderDivs ticketFilterAForm

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis. {- 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. - Copying is an act of love. Please copy, reuse and share.
- -
@ -26,19 +26,19 @@ import Vervis.Model
import Vervis.Model.Ticket import Vervis.Model.Ticket
data TicketFilter = TicketFilter data TicketFilter = TicketFilter
{ tfStatus :: Maybe TicketStatus { tfStatus :: [TicketStatus]
} }
instance Default TicketFilter where instance Default TicketFilter where
def = TicketFilter def = TicketFilter
{ tfStatus = Nothing { tfStatus = []
} }
filterTickets filterTickets
:: Esqueleto q e b :: Esqueleto q e b
=> TicketFilter => TicketFilter
-> Maybe (e (Entity Ticket) -> e (Value Bool)) -> Maybe (e (Entity Ticket) -> e (Value Bool))
filterTickets tf = filterTickets (TicketFilter s) =
case tfStatus tf of if null s
Nothing -> Nothing then Nothing
Just s -> Just $ \ t -> t ^. TicketStatus ==. val s else Just $ \ t -> t ^. TicketStatus `in_` valList s