When creating a repo, allow to pick a project for it
This commit is contained in:
parent
ee9b40d466
commit
f8ae122da7
2 changed files with 11 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue