{- This file is part of Vervis. - - Written in 2016 by fr33domlover . - - ♡ 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 - . -} module Vervis.Form.Repo ( NewRepo (..) , newRepoForm ) where --import Prelude import Vervis.Import import Vervis.Field.Repo import Vervis.Model import Vervis.Model.Ident import Vervis.Model.Repo 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) <*> 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 newRepoForm :: PersonId -> SharerId -> Maybe ProjectId -> Form NewRepo newRepoForm pid sid mpid = renderDivs $ newRepoAForm pid sid mpid