diff --git a/src/Vervis/Form/Repo.hs b/src/Vervis/Form/Repo.hs index 04397ea..bccfa21 100644 --- a/src/Vervis/Form/Repo.hs +++ b/src/Vervis/Form/Repo.hs @@ -24,12 +24,12 @@ import Vervis.Import import Vervis.Field.Repo import Vervis.Model.Repo -newRepoAForm :: SharerId -> AForm Handler Repo -newRepoAForm sid = Repo +newRepoAForm :: SharerId -> Maybe ProjectId -> AForm Handler Repo +newRepoAForm sid mpid = Repo <$> areq (mkIdentField sid) "Identifier*" Nothing <*> pure sid <*> areq (selectFieldList vcsList) "Version control system*" Nothing - <*> pure Nothing + <*> aopt selectProject "Project" (Just mpid) <*> aopt textField "Description" Nothing <*> pure "master" where @@ -38,6 +38,10 @@ newRepoAForm sid = Repo [ ("Darcs", VCSDarcs) , ("Git" , VCSGit) ] + selectProject = + selectField $ + optionsPersistKey + [ProjectSharer ==. sid] [Asc ProjectIdent] projectIdent -newRepoForm :: SharerId -> Form Repo -newRepoForm = renderDivs . newRepoAForm +newRepoForm :: SharerId -> Maybe ProjectId -> Form Repo +newRepoForm sid mpid = renderDivs $ newRepoAForm sid mpid diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index fea37b6..fbc3aa5 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -108,7 +108,7 @@ postReposR :: Text -> Handler Html postReposR user = do Entity _pid person <- requireAuth let sid = personIdent person - ((result, widget), enctype) <- runFormPost $ newRepoForm sid + ((result, widget), enctype) <- runFormPost $ newRepoForm sid Nothing case result of FormSuccess repo -> do parent <- askSharerDir user @@ -132,7 +132,7 @@ getRepoNewR :: Text -> Handler Html getRepoNewR user = do Entity _pid person <- requireAuth let sid = personIdent person - ((_result, widget), enctype) <- runFormPost $ newRepoForm sid + ((_result, widget), enctype) <- runFormPost $ newRepoForm sid Nothing defaultLayout $ do setTitle $ toHtml $ mconcat ["Vervis > People > ", user, " > New Repo"] $(widgetFile "repo/repo-new")