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