1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-27 17:14:52 +09:00

DB: Rename entity WorkflowFieldEnum to WorkflowEnum

This commit is contained in:
fr33domlover 2020-01-05 12:04:17 +00:00
parent b78a0fa116
commit 8fc5e4b3c1
11 changed files with 72 additions and 64 deletions

View file

@ -295,9 +295,9 @@ WorkflowField
workflow WorkflowId
ident FldIdent
name Text
desc Text Maybe
desc Text Maybe
type WorkflowFieldType
enm WorkflowFieldEnumId Maybe
enm WorkflowEnumId Maybe
required Bool
constant Bool
filterNew Bool
@ -306,20 +306,20 @@ WorkflowField
UniqueWorkflowField workflow ident
WorkflowFieldEnum
WorkflowEnum
workflow WorkflowId
ident EnmIdent
name Text
desc Text Maybe
UniqueWorkflowFieldEnum workflow ident
UniqueWorkflowEnum workflow ident
WorkflowFieldEnumCtor
enum WorkflowFieldEnumId
WorkflowEnumCtor
enum WorkflowEnumId
name Text
desc Text Maybe
desc Text Maybe
UniqueWorkflowFieldEnumCtor enum name
UniqueWorkflowEnumCtor enum name
TicketParamText
ticket TicketId
@ -331,7 +331,7 @@ TicketParamText
TicketParamEnum
ticket TicketId
field WorkflowFieldId
value WorkflowFieldEnumCtorId
value WorkflowEnumCtorId
UniqueTicketParamEnum ticket field value

View file

@ -90,8 +90,8 @@ checkEnmUniqueCI
checkEnmUniqueCI wid = checkM $ \ enm -> do
sames <- runDB $ select $ from $ \ enum -> do
where_ $
enum ^. WorkflowFieldEnumWorkflow ==. val wid &&.
lower_ (enum ^. WorkflowFieldEnumIdent) ==. lower_ (val enm)
enum ^. WorkflowEnumWorkflow ==. val wid &&.
lower_ (enum ^. WorkflowEnumIdent) ==. lower_ (val enm)
limit 1
return ()
return $ if null sames
@ -113,9 +113,9 @@ checkCtorName =
in checkBool nameOk msg
checkCtorUnique
:: WorkflowFieldEnumId -> Field Handler Text -> Field Handler Text
:: WorkflowEnumId -> Field Handler Text -> Field Handler Text
checkCtorUnique eid = checkM $ \ name -> do
mc <- runDB $ getBy $ UniqueWorkflowFieldEnumCtor eid name
mc <- runDB $ getBy $ UniqueWorkflowEnumCtor eid name
return $ case mc of
Nothing -> Right name
Just _ -> Left ("There is already an enum ctor by that name" :: Text)
@ -123,5 +123,5 @@ checkCtorUnique eid = checkM $ \ name -> do
ctorNameField :: Field Handler Text
ctorNameField = checkCtorName textField
newCtorNameField :: WorkflowFieldEnumId -> Field Handler Text
newCtorNameField :: WorkflowEnumId -> Field Handler Text
newCtorNameField eid = checkCtorUnique eid ctorNameField

View file

@ -52,7 +52,7 @@ data NewTicket = NewTicket
{ ntTitle :: Text
, ntDesc :: Text
, ntTParams :: [(WorkflowFieldId, Text)]
, ntEParams :: [(WorkflowFieldId, WorkflowFieldEnumCtorId)]
, ntEParams :: [(WorkflowFieldId, WorkflowEnumCtorId)]
}
fieldSettings :: Text -> Bool -> FieldSettings App
@ -72,7 +72,7 @@ tfield (Entity fid f) =
efield
:: Entity WorkflowField
-> Maybe (AForm Handler (Maybe (WorkflowFieldId, WorkflowFieldEnumCtorId)))
-> Maybe (AForm Handler (Maybe (WorkflowFieldId, WorkflowEnumCtorId)))
efield (Entity fid f) =
case workflowFieldEnm f of
Nothing -> Nothing
@ -84,9 +84,9 @@ efield (Entity fid f) =
sel =
selectField $
optionsPersistKey
[WorkflowFieldEnumCtorEnum ==. eid]
[WorkflowEnumCtorEnum ==. eid]
[]
workflowFieldEnumCtorName
workflowEnumCtorName
in fmap (fid, ) <$>
if workflowFieldRequired f
then Just <$> areq sel sets Nothing
@ -157,16 +157,16 @@ eEditField
-> AForm
Handler
( Maybe TicketParamEnumId
, Maybe (WorkflowFieldId, WorkflowFieldEnumCtorId)
, Maybe (WorkflowFieldId, WorkflowEnumCtorId)
)
eEditField (TicketEnumParam (WorkflowFieldSummary fid _ name req _ _) e mv) =
let sets = fieldSettings name req
sel =
selectField $
optionsPersistKey
[WorkflowFieldEnumCtorEnum ==. wesId e]
[WorkflowEnumCtorEnum ==. wesId e]
[]
workflowFieldEnumCtorName
workflowEnumCtorName
in (tepvId <$> mv, ) . fmap (fid, ) <$>
if req
then Just <$> areq sel sets (tepvVal <$> mv)
@ -191,7 +191,7 @@ editTicketContentForm
)
]
, [ ( Maybe TicketParamEnumId
, Maybe (WorkflowFieldId, WorkflowFieldEnumCtorId)
, Maybe (WorkflowFieldId, WorkflowEnumCtorId)
)
]
)

View file

@ -59,7 +59,7 @@ data NewField = NewField
, nfName :: Text
, nfDesc :: Maybe Text
, nfType :: WorkflowFieldType
, nfEnum :: Maybe WorkflowFieldEnumId
, nfEnum :: Maybe WorkflowEnumId
, nfReq :: Bool
, nfConst :: Bool
, nfNew :: Bool
@ -82,9 +82,9 @@ newFieldAForm wid = NewField
where
selectEnum =
optionsPersistKey
[WorkflowFieldEnumWorkflow ==. wid]
[Asc WorkflowFieldEnumName]
workflowFieldEnumName
[WorkflowEnumWorkflow ==. wid]
[Asc WorkflowEnumName]
workflowEnumName
newFieldForm :: WorkflowId -> Form NewField
newFieldForm wid = renderDivs $ newFieldAForm wid
@ -109,10 +109,10 @@ data NewCtor = NewCtor
, ncDesc :: Maybe Text
}
newCtorAForm :: WorkflowFieldEnumId -> AForm Handler NewCtor
newCtorAForm :: WorkflowEnumId -> AForm Handler NewCtor
newCtorAForm eid = NewCtor
<$> areq (newCtorNameField eid) "name*" Nothing
<*> aopt textField "Description" Nothing
newCtorForm :: WorkflowFieldEnumId -> Form NewCtor
newCtorForm :: WorkflowEnumId -> Form NewCtor
newCtorForm eid = renderDivs $ newCtorAForm eid

View file

@ -221,7 +221,7 @@ getWorkflowEnumsR shr wfl = do
es <- runDB $ do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity wid _ <- getBy404 $ UniqueWorkflow sid wfl
selectList [WorkflowFieldEnumWorkflow ==. wid] []
selectList [WorkflowEnumWorkflow ==. wid] []
defaultLayout $(widgetFile "workflow/enum/list")
postWorkflowEnumsR :: ShrIdent -> WflIdent -> Handler Html
@ -233,11 +233,11 @@ postWorkflowEnumsR shr wfl = do
((result, widget), enctype) <- runFormPost $ newEnumForm wid
case result of
FormSuccess ne -> do
let enum = WorkflowFieldEnum
{ workflowFieldEnumWorkflow = wid
, workflowFieldEnumIdent = neIdent ne
, workflowFieldEnumName = neName ne
, workflowFieldEnumDesc = neDesc ne
let enum = WorkflowEnum
{ workflowEnumWorkflow = wid
, workflowEnumIdent = neIdent ne
, workflowEnumName = neName ne
, workflowEnumDesc = neDesc ne
}
runDB $ insert_ enum
setMessage "Workflow field enum added."
@ -263,7 +263,7 @@ getWorkflowEnumR shr wfl enm = do
e <- runDB $ do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity wid _ <- getBy404 $ UniqueWorkflow sid wfl
Entity _ e <- getBy404 $ UniqueWorkflowFieldEnum wid enm
Entity _ e <- getBy404 $ UniqueWorkflowEnum wid enm
return e
defaultLayout $(widgetFile "workflow/enum/one")
@ -287,8 +287,8 @@ getWorkflowEnumCtorsR shr wfl enm = do
cs <- runDB $ do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity wid _ <- getBy404 $ UniqueWorkflow sid wfl
Entity eid _ <- getBy404 $ UniqueWorkflowFieldEnum wid enm
selectList [WorkflowFieldEnumCtorEnum ==. eid] []
Entity eid _ <- getBy404 $ UniqueWorkflowEnum wid enm
selectList [WorkflowEnumCtorEnum ==. eid] []
defaultLayout $(widgetFile "workflow/enum/ctor/list")
postWorkflowEnumCtorsR :: ShrIdent -> WflIdent -> EnmIdent -> Handler Html
@ -296,15 +296,15 @@ postWorkflowEnumCtorsR shr wfl enm = do
eid <- runDB $ do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity wid _ <- getBy404 $ UniqueWorkflow sid wfl
Entity eid _ <- getBy404 $ UniqueWorkflowFieldEnum wid enm
Entity eid _ <- getBy404 $ UniqueWorkflowEnum wid enm
return eid
((result, widget), etype) <- runFormPost $ newCtorForm eid
case result of
FormSuccess nc -> do
let ctor = WorkflowFieldEnumCtor
{ workflowFieldEnumCtorEnum = eid
, workflowFieldEnumCtorName = ncName nc
, workflowFieldEnumCtorDesc = ncDesc nc
let ctor = WorkflowEnumCtor
{ workflowEnumCtorEnum = eid
, workflowEnumCtorName = ncName nc
, workflowEnumCtorDesc = ncDesc nc
}
runDB $ insert_ ctor
setMessage "Workflow field enum ctor added."
@ -321,7 +321,7 @@ getWorkflowEnumCtorNewR shr wfl enm = do
eid <- runDB $ do
Entity sid _ <- getBy404 $ UniqueSharer shr
Entity wid _ <- getBy404 $ UniqueWorkflow sid wfl
Entity eid _ <- getBy404 $ UniqueWorkflowFieldEnum wid enm
Entity eid _ <- getBy404 $ UniqueWorkflowEnum wid enm
return eid
((_result, widget), etype) <- runFormPost $ newCtorForm eid
defaultLayout $(widgetFile "workflow/enum/ctor/new")

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis.
-
- Written in 2016, 2018, 2019 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2016, 2018, 2019, 2020 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -1216,6 +1216,14 @@ changes hLocal ctx =
, removeField "RemoteCollection" "ident"
-- 179
, renameField "RemoteCollection" "identNew" "ident"
-- 180
, renameEntity "WorkflowFieldEnum" "WorkflowEnum"
-- 181
, renameEntity "WorkflowFieldEnumCtor" "WorkflowEnumCtor"
-- 182
, renameUnique "WorkflowEnum" "UniqueWorkflowFieldEnum" "UniqueWorkflowEnum"
-- 183
, renameUnique "WorkflowEnumCtor" "UniqueWorkflowFieldEnumCtor" "UniqueWorkflowEnumCtor"
]
migrateDB

View file

@ -209,13 +209,13 @@ getTicketTextParams tid wid = fmap (map toTParam) $
)
data WorkflowEnumSummary = WorkflowEnumSummary
{ wesId :: WorkflowFieldEnumId
{ wesId :: WorkflowEnumId
, wesIdent :: EnmIdent
}
data TicketEnumParamValue = TicketEnumParamValue
{ tepvId :: TicketParamEnumId
, tepvVal :: WorkflowFieldEnumCtorId
, tepvVal :: WorkflowEnumCtorId
, tepvName :: Text
}
@ -234,10 +234,10 @@ toEParam
, Value Bool
, Value Bool
, Value Bool
, Value WorkflowFieldEnumId
, Value WorkflowEnumId
, Value EnmIdent
, Value (Maybe TicketParamEnumId)
, Value (Maybe WorkflowFieldEnumCtorId)
, Value (Maybe WorkflowEnumCtorId)
, Value (Maybe Text)
)
-> TicketEnumParam
@ -289,16 +289,16 @@ getTicketEnumParams :: TicketId -> WorkflowId -> AppDB [TicketEnumParam]
getTicketEnumParams tid wid = fmap (map toEParam) $
select $ from $ \ (p `InnerJoin` c `RightOuterJoin` f `InnerJoin` e) -> do
on $
e ^. WorkflowFieldEnumWorkflow ==. val wid &&.
f ^. WorkflowFieldEnm ==. just (e ^. WorkflowFieldEnumId)
e ^. WorkflowEnumWorkflow ==. val wid &&.
f ^. WorkflowFieldEnm ==. just (e ^. WorkflowEnumId)
on $
f ^. WorkflowFieldWorkflow ==. val wid &&.
f ^. WorkflowFieldType ==. val WFTEnum &&.
p ?. TicketParamEnumField ==. just (f ^. WorkflowFieldId) &&.
c ?. WorkflowFieldEnumCtorEnum ==. f ^. WorkflowFieldEnm
c ?. WorkflowEnumCtorEnum ==. f ^. WorkflowFieldEnm
on $
p ?. TicketParamEnumTicket ==. just (val tid) &&.
p ?. TicketParamEnumValue ==. c ?. WorkflowFieldEnumCtorId
p ?. TicketParamEnumValue ==. c ?. WorkflowEnumCtorId
return
( f ^. WorkflowFieldId
, f ^. WorkflowFieldIdent
@ -308,9 +308,9 @@ getTicketEnumParams tid wid = fmap (map toEParam) $
, f ^. WorkflowFieldFilterNew
, f ^. WorkflowFieldFilterTodo
, f ^. WorkflowFieldFilterClosed
, e ^. WorkflowFieldEnumId
, e ^. WorkflowFieldEnumIdent
, e ^. WorkflowEnumId
, e ^. WorkflowEnumIdent
, p ?. TicketParamEnumId
, c ?. WorkflowFieldEnumCtorId
, c ?. WorkflowFieldEnumCtorName
, c ?. WorkflowEnumCtorId
, c ?. WorkflowEnumCtorName
)

View file

@ -18,12 +18,12 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<ul>
$forall Entity _cid c <- cs
$with name <- workflowFieldEnumCtorName c
$with name <- workflowEnumCtorName c
<li>
<div>
#{name}
<div>
#{fromMaybe "(none)" $ workflowFieldEnumCtorDesc c}
#{fromMaybe "(none)" $ workflowEnumCtorDesc c}
<div>
^{buttonW PUT "Edit this ctor" (WorkflowEnumCtorR shr wfl enm name)}
^{buttonW DELETE "Delete this ctor" (WorkflowEnumCtorR shr wfl enm name)}

View file

@ -19,5 +19,5 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<ul>
$forall Entity _eid e <- es
<li>
<a href=@{WorkflowEnumR shr wfl $ workflowFieldEnumIdent e}>
#{workflowFieldEnumName e}
<a href=@{WorkflowEnumR shr wfl $ workflowEnumIdent e}>
#{workflowEnumName e}

View file

@ -17,9 +17,9 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<ul>
<li>
Display name: #{workflowFieldEnumName e}
Display name: #{workflowEnumName e}
<li>
Description: #{fromMaybe "(none)" $ workflowFieldEnumDesc e}
Description: #{fromMaybe "(none)" $ workflowEnumDesc e}
<li>
<a href=@{WorkflowEnumCtorsR shr wfl enm}>
Ctors

View file

@ -26,8 +26,8 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
$of Left typ
#{show typ}
$of Right enum
<a href=@{WorkflowEnumR shr wfl $ workflowFieldEnumIdent enum}>
#{workflowFieldEnumName enum}
<a href=@{WorkflowEnumR shr wfl $ workflowEnumIdent enum}>
#{workflowEnumName enum}
<li>
Required: #{workflowFieldRequired f}
<li>