Experimental changes to Vervis.
Clone
HTTPS:
darcs clone https://vervis.peers.community/repos/KrXYo
SSH:
darcs clone USERNAME@vervis.peers.community:KrXYo
Tags
TODO
Workflow.hs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | {- 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.Workflow
( NewWorkflow (..)
, newWorkflowForm
, NewField (..)
, newFieldForm
, NewEnum (..)
, newEnumForm
, NewCtor (..)
, newCtorForm
)
where
import Vervis.Import hiding (on, isNothing)
import Database.Esqueleto hiding ((==.))
import qualified Database.Esqueleto as E ((==.))
import Vervis.Field.Workflow
import Vervis.Model
import Vervis.Model.Ident
import Vervis.Model.Workflow
data NewWorkflow = NewWorkflow
{ nwIdent :: WflIdent
, nwName :: Maybe Text
, nwDesc :: Maybe Text
, nwPublic :: Bool
}
newWorkflowAForm :: SharerId -> AForm Handler NewWorkflow
newWorkflowAForm sid = NewWorkflow
<$> areq (newWorkflowIdentField sid) "Identifier*" Nothing
<*> aopt textField "Name" Nothing
<*> aopt textField "Description" Nothing
<*> areq checkBoxField "Public*" Nothing
newWorkflowForm :: SharerId -> Form NewWorkflow
newWorkflowForm sid = renderDivs $ newWorkflowAForm sid
data NewField = NewField
{ nfIdent :: FldIdent
, nfName :: Text
, nfDesc :: Maybe Text
, nfType :: WorkflowFieldType
, nfReq :: Bool
, nfConst :: Bool
, nfNew :: Bool
, nfTodo :: Bool
, nfClosed :: Bool
}
newFieldAForm :: WorkflowId -> AForm Handler NewField
newFieldAForm wid = NewField
<$> areq (newFieldIdentField wid) "Identifier*" Nothing
<*> areq textField "Name*" Nothing
<*> aopt textField "Description" Nothing
<*> areq (selectField optionsEnum) "Type*" Nothing
<*> areq checkBoxField "Required*" Nothing
<*> areq checkBoxField "Constant*" Nothing
<*> areq checkBoxField "Applies to New*" (Just True)
<*> areq checkBoxField "Applies to Todo*" (Just True)
<*> areq checkBoxField "Applies to Closed*" (Just True)
newFieldForm :: WorkflowId -> Form NewField
newFieldForm wid = renderDivs $ newFieldAForm wid
data NewEnum = NewEnum
{ neIdent :: EnmIdent
, neName :: Text
, neDesc :: Maybe Text
}
newEnumAForm :: WorkflowId -> AForm Handler NewEnum
newEnumAForm wid = NewEnum
<$> areq (newEnumIdentField wid) "Identifier*" Nothing
<*> areq textField "Name*" Nothing
<*> aopt textField "Description" Nothing
newEnumForm :: WorkflowId -> Form NewEnum
newEnumForm wid = renderDivs $ newEnumAForm wid
data NewCtor = NewCtor
{ ncName :: Text
, ncDesc :: Maybe Text
}
newCtorAForm :: WorkflowFieldEnumId -> AForm Handler NewCtor
newCtorAForm eid = NewCtor
<$> areq (newCtorNameField eid) "name*" Nothing
<*> aopt textField "Description" Nothing
newCtorForm :: WorkflowFieldEnumId -> Form NewCtor
newCtorForm eid = renderDivs $ newCtorAForm eid
|