1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2025-01-10 01:16:46 +09:00
vervis/src/Vervis/Form/Repo.hs

63 lines
1.8 KiB
Haskell
Raw Normal View History

2016-02-27 14:41:36 +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.Repo
( NewRepo (..)
, newRepoForm
2016-02-27 14:41:36 +09:00
)
where
--import Prelude
2016-02-27 14:41:36 +09:00
import Vervis.Import
import Vervis.Field.Repo
import Vervis.Model
import Vervis.Model.Ident
import Vervis.Model.Repo
2016-02-27 14:41:36 +09:00
data NewRepo = NewRepo
{ nrpIdent :: RpIdent
, nrpVcs :: VersionControlSystem
, nrpProj :: Maybe ProjectId
, nrpDesc :: Maybe Text
, nrpRole :: RoleId
}
newRepoAForm
:: PersonId -> SharerId -> Maybe ProjectId -> AForm Handler NewRepo
newRepoAForm pid sid mpid = NewRepo
<$> (text2rp <$> areq (mkIdentField sid) "Identifier*" Nothing)
<*> areq (selectFieldList vcsList) "Version control system*" Nothing
<*> aopt selectProject "Project" (Just mpid)
2016-02-27 14:41:36 +09:00
<*> aopt textField "Description" Nothing
<*> areq selectRole "Your role*" Nothing
where
vcsList :: [(Text, VersionControlSystem)]
vcsList =
[ ("Darcs", VCSDarcs)
, ("Git" , VCSGit)
]
selectProject =
selectField $
optionsPersistKey [ProjectSharer ==. sid] [Asc ProjectIdent] $
prj2text . projectIdent
selectRole =
selectField $
optionsPersistKey [RolePerson ==. pid] [] $
rl2text . roleIdent
2016-02-27 14:41:36 +09:00
newRepoForm :: PersonId -> SharerId -> Maybe ProjectId -> Form NewRepo
newRepoForm pid sid mpid = renderDivs $ newRepoAForm pid sid mpid