From 424692d61110042462d7d88310290a8f682bd23a Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Thu, 19 May 2022 00:22:10 +0200 Subject: [PATCH] feat(workflows): show info and warnings about scheduled/performed archivation --- .../uniworx/categories/workflows/de-de-formal.msg | 2 ++ messages/uniworx/categories/workflows/en-eu.msg | 2 ++ src/Handler/Workflow/Workflow/Workflow.hs | 5 +++++ .../de-de-formal.hamlet | 4 ++++ .../i18n/workflow-archivation-scheduled/en-eu.hamlet | 4 ++++ templates/workflows/workflow.hamlet | 11 +++++++++++ 6 files changed, 28 insertions(+) create mode 100644 templates/i18n/workflow-archivation-scheduled/de-de-formal.hamlet create mode 100644 templates/i18n/workflow-archivation-scheduled/en-eu.hamlet diff --git a/messages/uniworx/categories/workflows/de-de-formal.msg b/messages/uniworx/categories/workflows/de-de-formal.msg index 6cd756c84..b30081a91 100644 --- a/messages/uniworx/categories/workflows/de-de-formal.msg +++ b/messages/uniworx/categories/workflows/de-de-formal.msg @@ -106,6 +106,8 @@ WorkflowWorkflowWorkflowStateHeading: Zustand/Daten WorkflowWorkflowWorkflowPayloadHeading: Aktueller Datensatz WorkflowWorkflowWorkflowStateStateLabel: Aktueller Zustand WorkflowWorkflowWorkflowStateStateHidden: Versteckter Zustand +WorkflowWorkflowWorkflowStateArchivedLabel: Archiviert seit +WorkflowWorkflowWorkflowArchivationInfo: Workflows, welche seit 61 Tagen abgeschlossen sind, werden automatisch archiviert. Archivierte Workflows werden nicht als laufende Workflows gelistet. Das Auslösen einer Aktion setzt den Archivierungszeitpunkt eines Workflows zurück. WorkflowWorkflowWorkflowHistoryLabelOthers: Aktionen Anderer WorkflowWorkflowWorkflowHistoryLabelOwn: Eigene Aktionen diff --git a/messages/uniworx/categories/workflows/en-eu.msg b/messages/uniworx/categories/workflows/en-eu.msg index 2dcc37915..143a0db74 100644 --- a/messages/uniworx/categories/workflows/en-eu.msg +++ b/messages/uniworx/categories/workflows/en-eu.msg @@ -65,6 +65,8 @@ WorkflowWorkflowWorkflowStateHeading: State/Data WorkflowWorkflowWorkflowPayloadHeading: Current data WorkflowWorkflowWorkflowStateStateLabel: Current state WorkflowWorkflowWorkflowStateStateHidden: Hidden state +WorkflowWorkflowWorkflowStateArchivedLabel: Archived since +WorkflowWorkflowWorkflowArchivationInfo: Workflows that are finalized since 61 days will be automatically moved to the archive. Archived workflows are not listed as running. Actions reset the archivation date of a workflow. WorkflowWorkflowWorkflowHistoryLabelOthers: Other users' actions WorkflowWorkflowWorkflowHistoryLabelOwn: Your actions diff --git a/src/Handler/Workflow/Workflow/Workflow.hs b/src/Handler/Workflow/Workflow/Workflow.hs index 61bac5894..99fe42538 100644 --- a/src/Handler/Workflow/Workflow/Workflow.hs +++ b/src/Handler/Workflow/Workflow/Workflow.hs @@ -52,6 +52,7 @@ data WorkflowHistoryItem = WorkflowHistoryItem data WorkflowCurrentState = WorkflowCurrentState { wcsState :: Maybe (Text, Maybe Icon) + , wcsArchived :: Maybe UTCTime , wcsMessages :: Set Message , wcsPayload :: [(Text, ([WorkflowFieldPayloadW Void (Maybe (Entity User))], Maybe Text))] } @@ -76,6 +77,7 @@ getSWWFilesR ssh = getWorkflowFilesR $ WSSchool ssh workflowR :: RouteWorkflowScope -> CryptoFileNameWorkflowWorkflow -> Handler Html workflowR rScope cID = workflowsDisabledWarning title heading $ do + now <- liftIO getCurrentTime (mEdge, (workflowState, workflowHistory)) <- runDB $ do wwId <- decrypt cID WorkflowWorkflow{..} <- get404 wwId @@ -212,6 +214,8 @@ workflowR rScope cID = workflowsDisabledWarning title heading $ do messageContent <- selectLanguageI18n wnmContent return Message{..} + let wcsArchived = workflowWorkflowArchived + tell ( Just $ Last WorkflowCurrentState{..} , pure WorkflowHistoryItem{..} ) @@ -255,6 +259,7 @@ workflowR rScope cID = workflowsDisabledWarning title heading $ do Nothing -> i18n MsgWorkflowPayloadUserGone Just (Entity _ User{..}) -> nameWidget userDisplayName userSurname WorkflowFieldPayloadW (WFPFile v ) -> absurd v + archivationScheduled archived = $(i18nWidgetFile "workflow-archivation-scheduled") $(widgetFile "workflows/workflow") where (heading, title) = case rScope of diff --git a/templates/i18n/workflow-archivation-scheduled/de-de-formal.hamlet b/templates/i18n/workflow-archivation-scheduled/de-de-formal.hamlet new file mode 100644 index 000000000..68cc8e463 --- /dev/null +++ b/templates/i18n/workflow-archivation-scheduled/de-de-formal.hamlet @@ -0,0 +1,4 @@ +$newline never + +

+ Dieser Workflow wird am ^{formatTimeW SelFormatDateTime archived} archiviert. diff --git a/templates/i18n/workflow-archivation-scheduled/en-eu.hamlet b/templates/i18n/workflow-archivation-scheduled/en-eu.hamlet new file mode 100644 index 000000000..efa0e8f52 --- /dev/null +++ b/templates/i18n/workflow-archivation-scheduled/en-eu.hamlet @@ -0,0 +1,4 @@ +$newline never + +

+ This workflow will be archived on ^{formatTimeW SelFormatDateTime archived}. diff --git a/templates/workflows/workflow.hamlet b/templates/workflows/workflow.hamlet index aaac0b497..1df3fe1cc 100644 --- a/templates/workflows/workflow.hamlet +++ b/templates/workflows/workflow.hamlet @@ -1,6 +1,10 @@ $newline never $maybe WorkflowCurrentState{..} <- workflowState

+ $maybe archived <- wcsArchived + $if now < archived + ^{notification NotificationBroad =<< messageWidget Warning (archivationScheduled archived)} +

_{MsgWorkflowWorkflowWorkflowStateHeading} @@ -16,6 +20,13 @@ $maybe WorkflowCurrentState{..} <- workflowState $nothing _{MsgWorkflowWorkflowWorkflowStateStateHidden} + $maybe archived <- wcsArchived + $if now >= archived +
+ _{MsgWorkflowWorkflowWorkflowStateArchivedLabel} # + ^{messageTooltip =<< messageI Info MsgWorkflowWorkflowWorkflowArchivationInfo} +
+ ^{formatTimeW SelFormatDateTime archived} $forall msg <- wcsMessages ^{notification NotificationBroad msg}