1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-01-12 05:45:08 +09:00
vervis/src/Vervis/Form/Ticket.hs

47 lines
1.5 KiB
Haskell
Raw Normal View History

2016-05-01 06:26:54 +09:00
{- This file is part of Vervis.
-
- Written in 2016 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
- The author(s) have dedicated all copyright and related and neighboring
- rights to this software to the public domain worldwide. This software is
- distributed without any warranty.
-
- You should have received a copy of the CC0 Public Domain Dedication along
- with this software. If not, see
- <http://creativecommons.org/publicdomain/zero/1.0/>.
-}
module Vervis.Form.Ticket
( newTicketForm
)
where
import Prelude
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Class (lift)
import Data.Time.Clock (getCurrentTime)
import Yesod.Form
import Vervis.Foundation (Form, Handler)
import Vervis.Model
--TODO use custom fields to ensure uniqueness or other constraints?
--TODO stuff like number and created - do I generate them here using monadic
-- form or do I rely on handler to provide? which approach is better?
2016-05-01 18:58:55 +09:00
newTicketAForm :: ProjectId -> Int -> PersonId -> AForm Handler Ticket
newTicketAForm pid number author = Ticket
2016-05-01 06:26:54 +09:00
<$> pure pid
<*> pure number
<*> lift (liftIO getCurrentTime)
2016-05-01 18:58:55 +09:00
<*> pure author
2016-05-01 06:26:54 +09:00
<*> areq textField "Title*" Nothing
<*> (maybe "" unTextarea <$> aopt textareaField "Description (Markdown)" Nothing)
<*> pure False
2016-05-01 18:58:55 +09:00
newTicketForm :: ProjectId -> Int -> PersonId -> Form Ticket
newTicketForm pid number author = renderDivs $ newTicketAForm pid number author