If a repo belongs to a project, pick repo team from project team
This commit is contained in:
parent
7e0abe20b8
commit
72def092b2
2 changed files with 35 additions and 15 deletions
|
@ -72,12 +72,13 @@ data NewRepoCollab = NewRepoCollab
|
||||||
, ncRole :: RepoRoleId
|
, ncRole :: RepoRoleId
|
||||||
}
|
}
|
||||||
|
|
||||||
newRepoCollabAForm :: PersonId -> RepoId -> AForm Handler NewRepoCollab
|
newRepoCollabAForm
|
||||||
newRepoCollabAForm pid rid = NewRepoCollab
|
:: PersonId -> Maybe ProjectId -> RepoId -> AForm Handler NewRepoCollab
|
||||||
<$> areq selectPerson "Person*" Nothing
|
newRepoCollabAForm pid mjid rid = NewRepoCollab
|
||||||
|
<$> areq (selectPerson mjid) "Person*" Nothing
|
||||||
<*> areq selectRole "Role*" Nothing
|
<*> areq selectRole "Role*" Nothing
|
||||||
where
|
where
|
||||||
selectPerson = selectField $ do
|
selectPerson Nothing = selectField $ do
|
||||||
l <- runDB $ select $
|
l <- runDB $ select $
|
||||||
from $ \ (collab `RightOuterJoin` person `InnerJoin` sharer) -> do
|
from $ \ (collab `RightOuterJoin` person `InnerJoin` sharer) -> do
|
||||||
on $ person ^. PersonIdent E.==. sharer ^. SharerId
|
on $ person ^. PersonIdent E.==. sharer ^. SharerId
|
||||||
|
@ -87,10 +88,28 @@ newRepoCollabAForm pid rid = NewRepoCollab
|
||||||
where_ $ isNothing $ collab ?. RepoCollabId
|
where_ $ isNothing $ collab ?. RepoCollabId
|
||||||
return (sharer ^. SharerIdent, person ^. PersonId)
|
return (sharer ^. SharerIdent, person ^. PersonId)
|
||||||
optionsPairs $ map (shr2text . unValue *** unValue) l
|
optionsPairs $ map (shr2text . unValue *** unValue) l
|
||||||
|
selectPerson (Just jid) = selectField $ do
|
||||||
|
l <- runDB $ select $ from $
|
||||||
|
\ ( pcollab `InnerJoin`
|
||||||
|
person `LeftOuterJoin`
|
||||||
|
rcollab `InnerJoin`
|
||||||
|
sharer
|
||||||
|
) -> do
|
||||||
|
on $ person ^. PersonIdent E.==. sharer ^. SharerId
|
||||||
|
on $
|
||||||
|
rcollab ?. RepoCollabRepo E.==. just (val rid) &&.
|
||||||
|
rcollab ?. RepoCollabPerson E.==. just (person ^. PersonId)
|
||||||
|
on $
|
||||||
|
pcollab ^. ProjectCollabProject E.==. val jid &&.
|
||||||
|
pcollab ^. ProjectCollabPerson E.==. person ^. PersonId
|
||||||
|
where_ $ isNothing $ rcollab ?. RepoCollabId
|
||||||
|
return (sharer ^. SharerIdent, person ^. PersonId)
|
||||||
|
optionsPairs $ map (shr2text . unValue *** unValue) l
|
||||||
selectRole =
|
selectRole =
|
||||||
selectField $
|
selectField $
|
||||||
optionsPersistKey [RepoRolePerson ==. pid] [] $
|
optionsPersistKey [RepoRolePerson ==. pid] [] $
|
||||||
rl2text . repoRoleIdent
|
rl2text . repoRoleIdent
|
||||||
|
|
||||||
newRepoCollabForm :: PersonId -> RepoId -> Form NewRepoCollab
|
newRepoCollabForm
|
||||||
newRepoCollabForm pid rid = renderDivs $ newRepoCollabAForm pid rid
|
:: PersonId -> Maybe ProjectId -> RepoId -> Form NewRepoCollab
|
||||||
|
newRepoCollabForm pid mjid rid = renderDivs $ newRepoCollabAForm pid mjid rid
|
||||||
|
|
|
@ -237,12 +237,12 @@ getRepoDevsR shr rp = do
|
||||||
|
|
||||||
postRepoDevsR :: ShrIdent -> RpIdent -> Handler Html
|
postRepoDevsR :: ShrIdent -> RpIdent -> Handler Html
|
||||||
postRepoDevsR shr rp = do
|
postRepoDevsR shr rp = do
|
||||||
(pid, rid) <- runDB $ do
|
(pid, mjid, rid) <- runDB $ do
|
||||||
Entity s _ <- getBy404 $ UniqueSharer shr
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
||||||
Entity p _ <- getBy404 $ UniquePersonIdent s
|
Entity p _ <- getBy404 $ UniquePersonIdent s
|
||||||
Entity r _ <- getBy404 $ UniqueRepo rp s
|
Entity r repository <- getBy404 $ UniqueRepo rp s
|
||||||
return (p, r)
|
return (p, repoProject repository, r)
|
||||||
((result, widget), enctype) <- runFormPost $ newRepoCollabForm pid rid
|
((result, widget), enctype) <- runFormPost $ newRepoCollabForm pid mjid rid
|
||||||
case result of
|
case result of
|
||||||
FormSuccess nc -> do
|
FormSuccess nc -> do
|
||||||
runDB $ do
|
runDB $ do
|
||||||
|
@ -263,12 +263,13 @@ postRepoDevsR shr rp = do
|
||||||
|
|
||||||
getRepoDevNewR :: ShrIdent -> RpIdent -> Handler Html
|
getRepoDevNewR :: ShrIdent -> RpIdent -> Handler Html
|
||||||
getRepoDevNewR shr rp = do
|
getRepoDevNewR shr rp = do
|
||||||
(pid, rid) <- runDB $ do
|
(pid, mjid, rid) <- runDB $ do
|
||||||
Entity s _ <- getBy404 $ UniqueSharer shr
|
Entity s _ <- getBy404 $ UniqueSharer shr
|
||||||
Entity p _ <- getBy404 $ UniquePersonIdent s
|
Entity p _ <- getBy404 $ UniquePersonIdent s
|
||||||
Entity r _ <- getBy404 $ UniqueRepo rp s
|
Entity r repository <- getBy404 $ UniqueRepo rp s
|
||||||
return (p, r)
|
return (p, repoProject repository, r)
|
||||||
((_result, widget), enctype) <- runFormPost $ newRepoCollabForm pid rid
|
((_result, widget), enctype) <-
|
||||||
|
runFormPost $ newRepoCollabForm pid mjid rid
|
||||||
defaultLayout $(widgetFile "repo/collab/new")
|
defaultLayout $(widgetFile "repo/collab/new")
|
||||||
|
|
||||||
getRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html
|
getRepoDevR :: ShrIdent -> RpIdent -> ShrIdent -> Handler Html
|
||||||
|
|
Loading…
Reference in a new issue