diff --git a/src/Vervis/Form/Ticket.hs b/src/Vervis/Form/Ticket.hs index a46ff8b..2c182b9 100644 --- a/src/Vervis/Form/Ticket.hs +++ b/src/Vervis/Form/Ticket.hs @@ -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 diff --git a/src/Vervis/TicketFilter.hs b/src/Vervis/TicketFilter.hs index d5bf7ff..aa5f21c 100644 --- a/src/Vervis/TicketFilter.hs +++ b/src/Vervis/TicketFilter.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016, 2018 by fr33domlover . + - Written in 2016, 2018, 2019 by fr33domlover . - - ♡ 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