Workflow scope field, minimal support
This commit is contained in:
parent
6b4ecb99c7
commit
fc556e0eb3
7 changed files with 39 additions and 11 deletions
|
@ -166,7 +166,7 @@ Workflow
|
||||||
ident WflIdent
|
ident WflIdent
|
||||||
name Text Maybe
|
name Text Maybe
|
||||||
desc Text Maybe
|
desc Text Maybe
|
||||||
-- scope WorkflowScope -- sharer / public / featured
|
scope WorkflowScope
|
||||||
|
|
||||||
UniqueWorkflow sharer ident
|
UniqueWorkflow sharer ident
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,13 @@ import Vervis.Import hiding (on, isNothing)
|
||||||
|
|
||||||
import Database.Esqueleto hiding ((==.))
|
import Database.Esqueleto hiding ((==.))
|
||||||
|
|
||||||
import qualified Database.Esqueleto as E ((==.))
|
import qualified Database.Esqueleto as E
|
||||||
|
|
||||||
import Vervis.Field.Project
|
import Vervis.Field.Project
|
||||||
import Vervis.Model
|
import Vervis.Model
|
||||||
import Vervis.Model.Ident
|
import Vervis.Model.Ident
|
||||||
import Vervis.Model.Repo
|
import Vervis.Model.Repo
|
||||||
|
import Vervis.Model.Workflow
|
||||||
|
|
||||||
data NewProject = NewProject
|
data NewProject = NewProject
|
||||||
{ npIdent :: PrjIdent
|
{ npIdent :: PrjIdent
|
||||||
|
@ -53,10 +54,23 @@ newProjectAForm sid = NewProject
|
||||||
selectField $
|
selectField $
|
||||||
optionsPersistKey [ProjectRoleSharer ==. sid] [] $
|
optionsPersistKey [ProjectRoleSharer ==. sid] [] $
|
||||||
rl2text . projectRoleIdent
|
rl2text . projectRoleIdent
|
||||||
selectWorkflow =
|
selectWorkflow = selectField $ do
|
||||||
selectField $
|
l <- runDB $ select $ from $ \ (w `InnerJoin` s) -> do
|
||||||
optionsPersistKey [WorkflowSharer ==. sid] [] $
|
on $ w ^. WorkflowSharer E.==. s ^. SharerId
|
||||||
\ w -> fromMaybe (wfl2text $ workflowIdent w) $ workflowName w
|
where_ $
|
||||||
|
w ^. WorkflowSharer E.==. val sid E.||.
|
||||||
|
w ^. WorkflowScope E.!=. val WSSharer
|
||||||
|
return
|
||||||
|
( s ^. SharerIdent
|
||||||
|
, w ^. WorkflowId
|
||||||
|
, w ^. WorkflowIdent
|
||||||
|
, w ^. WorkflowName
|
||||||
|
)
|
||||||
|
let mkpair (Value sident, Value wid, Value wident, Value wname) =
|
||||||
|
( shr2text sident <> " / " <> fromMaybe (wfl2text wident) wname
|
||||||
|
, wid
|
||||||
|
)
|
||||||
|
optionsPairs $ map mkpair l
|
||||||
|
|
||||||
newProjectForm :: SharerId -> Form NewProject
|
newProjectForm :: SharerId -> Form NewProject
|
||||||
newProjectForm sid = renderDivs $ newProjectAForm sid
|
newProjectForm sid = renderDivs $ newProjectAForm sid
|
||||||
|
|
|
@ -37,9 +37,10 @@ import Vervis.Model.Ident
|
||||||
import Vervis.Model.Workflow
|
import Vervis.Model.Workflow
|
||||||
|
|
||||||
data NewWorkflow = NewWorkflow
|
data NewWorkflow = NewWorkflow
|
||||||
{ nwIdent :: WflIdent
|
{ nwIdent :: WflIdent
|
||||||
, nwName :: Maybe Text
|
, nwName :: Maybe Text
|
||||||
, nwDesc :: Maybe Text
|
, nwDesc :: Maybe Text
|
||||||
|
, nwPublic :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
newWorkflowAForm :: SharerId -> AForm Handler NewWorkflow
|
newWorkflowAForm :: SharerId -> AForm Handler NewWorkflow
|
||||||
|
@ -47,6 +48,7 @@ newWorkflowAForm sid = NewWorkflow
|
||||||
<$> areq (newWorkflowIdentField sid) "Identifier*" Nothing
|
<$> areq (newWorkflowIdentField sid) "Identifier*" Nothing
|
||||||
<*> aopt textField "Name" Nothing
|
<*> aopt textField "Name" Nothing
|
||||||
<*> aopt textField "Description" Nothing
|
<*> aopt textField "Description" Nothing
|
||||||
|
<*> areq checkBoxField "Public*" Nothing
|
||||||
|
|
||||||
newWorkflowForm :: SharerId -> Form NewWorkflow
|
newWorkflowForm :: SharerId -> Form NewWorkflow
|
||||||
newWorkflowForm sid = renderDivs $ newWorkflowAForm sid
|
newWorkflowForm sid = renderDivs $ newWorkflowAForm sid
|
||||||
|
|
|
@ -88,6 +88,8 @@ postWorkflowsR shr = do
|
||||||
, workflowIdent = nwIdent nw
|
, workflowIdent = nwIdent nw
|
||||||
, workflowName = nwName nw
|
, workflowName = nwName nw
|
||||||
, workflowDesc = nwDesc nw
|
, workflowDesc = nwDesc nw
|
||||||
|
, workflowScope =
|
||||||
|
if nwPublic nw then WSPublic else WSSharer
|
||||||
}
|
}
|
||||||
runDB $ insert_ workflow
|
runDB $ insert_ workflow
|
||||||
setMessage "Workflow added."
|
setMessage "Workflow added."
|
||||||
|
|
|
@ -65,7 +65,9 @@ runMigrations sb migrations = do
|
||||||
|
|
||||||
changes :: MonadIO m => [SchemaT SqlBackend m ()]
|
changes :: MonadIO m => [SchemaT SqlBackend m ()]
|
||||||
changes =
|
changes =
|
||||||
[
|
[ addField "Workflow"
|
||||||
|
(Field "scope" (FTPrim SqlString) NotNull)
|
||||||
|
(Just "'WSSharer'")
|
||||||
]
|
]
|
||||||
|
|
||||||
migrateDB :: MonadIO m => ReaderT SqlBackend m ()
|
migrateDB :: MonadIO m => ReaderT SqlBackend m ()
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Vervis.Model.Workflow
|
module Vervis.Model.Workflow
|
||||||
( WorkflowFieldType (..)
|
( WorkflowScope (..)
|
||||||
|
, WorkflowFieldType (..)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -22,6 +23,11 @@ import Prelude
|
||||||
|
|
||||||
import Database.Persist.TH
|
import Database.Persist.TH
|
||||||
|
|
||||||
|
data WorkflowScope = WSSharer | WSPublic | WSFeatured
|
||||||
|
deriving (Eq, Show, Read, Bounded, Enum)
|
||||||
|
|
||||||
|
derivePersistField "WorkflowScope"
|
||||||
|
|
||||||
data WorkflowFieldType = WFTText | WFTEnum
|
data WorkflowFieldType = WFTText | WFTEnum
|
||||||
deriving (Eq, Show, Read, Bounded, Enum)
|
deriving (Eq, Show, Read, Bounded, Enum)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
<input type="submit" value="Delete this workflow">
|
<input type="submit" value="Delete this workflow">
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>
|
||||||
|
Scope: #{show $ workflowScope w}
|
||||||
<li>
|
<li>
|
||||||
Human-friendly name: #{fromMaybe "(none)" $ workflowName w}
|
Human-friendly name: #{fromMaybe "(none)" $ workflowName w}
|
||||||
<li>
|
<li>
|
||||||
|
|
Loading…
Reference in a new issue