feat(system-msg): add volatile cluster settings to system message forms
This commit is contained in:
parent
92b2d09169
commit
f8f9dc0621
@ -8,6 +8,7 @@ SystemMessageLastChanged: Zuletzt geändert
|
||||
SystemMessageLastUnhide: Zuletzt un-versteckt
|
||||
SystemMessageFrom: Sichtbar ab
|
||||
SystemMessageTo: Sichtbar bis
|
||||
SystemMessageOnVolatileClusterSettings: Sichtbar bei VolatileCluster-Einstellungen
|
||||
SystemMessageAuthenticatedOnly: Nur angemeldet
|
||||
SystemMessageSeverity: Schwere
|
||||
SystemMessagePriority: Priorität
|
||||
@ -38,3 +39,7 @@ SystemMessageEditTranslationSuccess: Übersetzung angepasst.
|
||||
SystemMessageDeleteTranslationSuccess: Übersetzung entfernt.
|
||||
|
||||
RFC1766: RFC1766-Sprachcode
|
||||
|
||||
SystemMessageOnVolatileClusterSettingKey: VolatileCluster-Einstellung
|
||||
SystemMessageOnVolatileClusterSettingValue: Wert
|
||||
SystemMessageOnVolatileClusterSettingKeyExists: Für diese Einstellung existiert bereits ein Wert!
|
||||
|
||||
@ -8,6 +8,7 @@ SystemMessageLastChanged: Last changed
|
||||
SystemMessageLastUnhide: Last unhidden
|
||||
SystemMessageFrom: Visible from
|
||||
SystemMessageTo: Visible to
|
||||
SystemMessageOnVolatileClusterSettings: Visible on VolatileCluster settings
|
||||
SystemMessageAuthenticatedOnly: Only logged in users
|
||||
SystemMessageSeverity: Severity
|
||||
SystemMessagePriority: Priority
|
||||
@ -38,3 +39,7 @@ SystemMessageEditTranslationSuccess: Successfully edited translation.
|
||||
SystemMessageDeleteTranslationSuccess: Successfully deleted translation.
|
||||
|
||||
RFC1766: RFC1766 language code
|
||||
|
||||
SystemMessageOnVolatileClusterSettingKey: VolatileCluster setting
|
||||
SystemMessageOnVolatileClusterSettingValue: Value
|
||||
SystemMessageOnVolatileClusterSettingKeyExists: There already exists a value for this setting!
|
||||
|
||||
@ -8,3 +8,6 @@ FieldSecondary: Nebenfach
|
||||
MultiEmailFieldTip: Es sind mehrere, Komma-separierte, E-Mail-Adressen möglich
|
||||
WeekDay: Wochentag
|
||||
LdapIdentificationOrEmail: Campus-Kennung / E-Mail-Adresse
|
||||
|
||||
ClusterVolatileWorkflowsEnabled: Workflows aktiv
|
||||
ClusterVolatileQuickActionsEnabled: Schnellzugriffsmenü aktiv
|
||||
|
||||
@ -7,4 +7,7 @@ FieldPrimary: Major
|
||||
FieldSecondary: Minor
|
||||
MultiEmailFieldTip: Multiple emails addresses may be specified (comma-separated)
|
||||
WeekDay: Day of the week
|
||||
LdapIdentificationOrEmail: Campus account/email address
|
||||
LdapIdentificationOrEmail: Campus account/email address
|
||||
|
||||
ClusterVolatileWorkflowsEnabled: Workflows enabled
|
||||
ClusterVolatileQuickActionsEnabled: Quick actions enabled
|
||||
@ -514,6 +514,14 @@ instance RenderMessage UniWorX RouteWorkflowScope where
|
||||
mr :: forall msg. RenderMessage UniWorX msg => msg -> Text
|
||||
mr = renderMessage foundation ls
|
||||
|
||||
instance RenderMessage UniWorX VolatileClusterSettingsKey where
|
||||
renderMessage foundation ls = \case
|
||||
ClusterVolatileWorkflowsEnabled -> mr MsgClusterVolatileWorkflowsEnabled
|
||||
ClusterVolatileQuickActionsEnabled -> mr MsgClusterVolatileQuickActionsEnabled
|
||||
where
|
||||
mr :: forall msg. RenderMessage UniWorX msg => msg -> Text
|
||||
mr = renderMessage foundation ls
|
||||
|
||||
|
||||
unRenderMessage' :: (Ord a, Finite a, RenderMessage master a) => (Text -> Text -> Bool) -> master -> Text -> [a]
|
||||
unRenderMessage' cmp foundation inp = nubOrd $ do
|
||||
|
||||
@ -7,16 +7,15 @@ module Handler.SystemMessage
|
||||
|
||||
import Import
|
||||
|
||||
import qualified Data.Map.Lazy as Map
|
||||
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
|
||||
import qualified Data.List.NonEmpty as NonEmpty
|
||||
|
||||
import Handler.Utils
|
||||
import Handler.Utils.News
|
||||
|
||||
import qualified Data.HashMap.Strict as HashMap
|
||||
import Data.Map ((!))
|
||||
import qualified Data.Map.Lazy as Map
|
||||
import qualified Data.List.NonEmpty as NonEmpty
|
||||
import qualified Data.Set as Set
|
||||
|
||||
import qualified Database.Esqueleto.Legacy as E
|
||||
|
||||
|
||||
@ -24,10 +23,31 @@ invalidateVisibleSystemMessages :: (MonadHandler m, HandlerSite m ~ UniWorX) =>
|
||||
invalidateVisibleSystemMessages = memcachedByInvalidate AuthCacheVisibleSystemMessages $ Proxy @(Map SystemMessageId (Maybe UTCTime, Maybe UTCTime))
|
||||
|
||||
|
||||
-- TODO: work in progress
|
||||
systemMessageVolatileClusterSettingsForm :: Maybe SystemMessageVolatileClusterSettings -> AForm Handler SystemMessageVolatileClusterSettings
|
||||
systemMessageVolatileClusterSettingsForm _mPrev = wFormToAForm $ do
|
||||
return mempty
|
||||
systemMessageVolatileClusterSettingsForm (fmap Set.toList -> mPrev) = wFormToAForm $ do
|
||||
currentRoute <- fromMaybe (error "systemMessageVolatileClusterSettingsForm called from 404-handler") <$> getCurrentRoute
|
||||
let
|
||||
volatileClusterSettingForm :: (Text -> Text) -> Maybe (VolatileClusterSettingsKey, Value) -> Form (VolatileClusterSettingsKey, Value)
|
||||
volatileClusterSettingForm nudge mTemplate csrf = do
|
||||
(keyRes, keyView) <- mpopt (selectField optionsFinite) ("" & addName (nudge "key" )) (view _1 <$> mTemplate)
|
||||
(valRes, valView) <- mreq (jsonField JsonFieldNormal) ("" & addName (nudge "value")) (view _2 <$> mTemplate)
|
||||
return ((,) <$> keyRes <*> valRes, $(widgetFile "widgets/massinput/systemMessage/volatileClusterSettings/form"))
|
||||
|
||||
miAdd nudge submitView csrf = do
|
||||
(formRes, formView) <- volatileClusterSettingForm nudge Nothing csrf
|
||||
MsgRenderer mr <- getMsgRenderer
|
||||
let res = formRes <&> \newDat@(newKey, _) oldDat -> if
|
||||
| any (\(oldKey, _) -> newKey == oldKey) oldDat -> FormFailure [mr MsgSystemMessageOnVolatileClusterSettingKeyExists]
|
||||
| otherwise -> FormSuccess $ pure newDat
|
||||
return (res, $(widgetFile "widgets/massinput/systemMessage/volatileClusterSettings/add"))
|
||||
miEdit nudge = volatileClusterSettingForm nudge . Just
|
||||
|
||||
miButtonAction :: forall p. PathPiece p => p -> Maybe (SomeRoute UniWorX)
|
||||
miButtonAction frag = Just . SomeRoute $ currentRoute :#: frag
|
||||
|
||||
miLayout :: MassInputLayout ListLength (VolatileClusterSettingsKey, Value) (VolatileClusterSettingsKey, Value)
|
||||
miLayout lLength _ cellWdgts delButtons addWdgts = $(widgetFile "widgets/massinput/systemMessage/volatileClusterSettings/layout")
|
||||
fmap (fmap Set.fromList) $ massInputAccumEditW miAdd miEdit miButtonAction miLayout ("system-message-volatile-cluster-settings" :: Text) (fslI MsgSystemMessageOnVolatileClusterSettings) False mPrev
|
||||
|
||||
|
||||
getMessageR, postMessageR :: CryptoUUIDSystemMessage -> Handler Html
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
$newline never
|
||||
^{formView}
|
||||
<td .table__td>
|
||||
^{fvWidget submitView}
|
||||
@ -0,0 +1,6 @@
|
||||
$newline never
|
||||
<td .table__td>
|
||||
#{csrf}
|
||||
^{fvWidget keyView}
|
||||
<td .table__td>
|
||||
^{fvWidget valView}
|
||||
@ -0,0 +1,16 @@
|
||||
$newline never
|
||||
<table .table .table--striped .table--hover>
|
||||
<thead>
|
||||
<tr .table__row .table__row--head>
|
||||
<th .table__th>_{MsgSystemMessageOnVolatileClusterSettingKey}
|
||||
<th .table__th>_{MsgSystemMessageOnVolatileClusterSettingValue}
|
||||
<td>
|
||||
<tbody>
|
||||
$forall coord <- review liveCoords lLength
|
||||
<tr .massinput__cell .table__row>
|
||||
^{cellWdgts ! coord}
|
||||
<td>
|
||||
^{fvWidget (delButtons ! coord)}
|
||||
<tfoot>
|
||||
<tr .massinput__cell.massinput__cell--add>
|
||||
^{addWdgts ! (0, 0)}
|
||||
Reference in New Issue
Block a user