diff --git a/config/models b/config/models index 29ef535..3e5ca2f 100644 --- a/config/models +++ b/config/models @@ -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 diff --git a/src/Vervis/Field/Workflow.hs b/src/Vervis/Field/Workflow.hs index 9834368..12829f3 100644 --- a/src/Vervis/Field/Workflow.hs +++ b/src/Vervis/Field/Workflow.hs @@ -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 diff --git a/src/Vervis/Form/Ticket.hs b/src/Vervis/Form/Ticket.hs index 2c182b9..2892d09 100644 --- a/src/Vervis/Form/Ticket.hs +++ b/src/Vervis/Form/Ticket.hs @@ -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) ) ] ) diff --git a/src/Vervis/Form/Workflow.hs b/src/Vervis/Form/Workflow.hs index cc0b36b..a72fca7 100644 --- a/src/Vervis/Form/Workflow.hs +++ b/src/Vervis/Form/Workflow.hs @@ -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 diff --git a/src/Vervis/Handler/Workflow.hs b/src/Vervis/Handler/Workflow.hs index 93c8463..c959287 100644 --- a/src/Vervis/Handler/Workflow.hs +++ b/src/Vervis/Handler/Workflow.hs @@ -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") diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index cce628e..e6a301f 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016, 2018, 2019 by fr33domlover . + - Written in 2016, 2018, 2019, 2020 by fr33domlover . - - ♡ 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 diff --git a/src/Vervis/Ticket.hs b/src/Vervis/Ticket.hs index e04011c..0a56fef 100644 --- a/src/Vervis/Ticket.hs +++ b/src/Vervis/Ticket.hs @@ -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 ) diff --git a/templates/workflow/enum/ctor/list.hamlet b/templates/workflow/enum/ctor/list.hamlet index a4e0365..968023a 100644 --- a/templates/workflow/enum/ctor/list.hamlet +++ b/templates/workflow/enum/ctor/list.hamlet @@ -18,12 +18,12 @@ $# .