diff --git a/frontend/src/utils/alerts/alerts.js b/frontend/src/utils/alerts/alerts.js index e54f898fd..3c4eba683 100644 --- a/frontend/src/utils/alerts/alerts.js +++ b/frontend/src/utils/alerts/alerts.js @@ -137,7 +137,7 @@ export class Alerts { if (alerts) { alerts.forEach((alert) => { - const alertElement = this._createAlertElement(alert.status, alert.content); + const alertElement = this._createAlertElement(alert.status, alert.content, alert.icon === null ? undefined : alert.icon); this._element.appendChild(alertElement); this._alertElements.push(alertElement); this._initAlert(alertElement); @@ -147,7 +147,7 @@ export class Alerts { } } - _createAlertElement(type, content) { + _createAlertElement(type, content, icon = 'info-circle') { const alertElement = document.createElement('div'); alertElement.classList.add(ALERT_CLASS, 'alert-' + type); @@ -155,7 +155,7 @@ export class Alerts { alertCloser.classList.add(ALERT_CLOSER_CLASS); const alertIcon = document.createElement('div'); - alertIcon.classList.add(ALERT_ICON_CLASS); + alertIcon.classList.add(ALERT_ICON_CLASS, 'fas', 'fa-fw', 'fa-' + icon); const alertContent = document.createElement('div'); alertContent.classList.add(ALERT_CONTENT_CLASS); diff --git a/src/Handler/Admin.hs b/src/Handler/Admin.hs index 7d02ee2e2..27fc5c809 100644 --- a/src/Handler/Admin.hs +++ b/src/Handler/Admin.hs @@ -113,7 +113,7 @@ postAdminTestR = do formResultModal emailResult AdminTestR $ \(email, ls) -> do jId <- mapWriterT runDB $ do jId <- queueJob $ JobSendTestEmail email ls - tell . pure $ Message Success [shamlet|Email-test gestartet (Job ##{tshow (fromSqlKey jId)})|] Nothing + tell . pure $ Message Success [shamlet|Email-test gestartet (Job ##{tshow (fromSqlKey jId)})|] (Just IconEmail) return jId writeJobCtl $ JobCtlPerform jId addMessage Warning [shamlet|Inkorrekt ausgegebener Alert|] -- For testing alert handling when short circuiting; for proper (not fallback-solution) handling always use `tell` within `formResultModal` diff --git a/src/Utils/Icon.hs b/src/Utils/Icon.hs index a5d0c8a92..582f9f35c 100644 --- a/src/Utils/Icon.hs +++ b/src/Utils/Icon.hs @@ -53,6 +53,7 @@ data Icon | IconSFTHint -- for SheetFileType only | IconSFTSolution -- for SheetFileType only | IconSFTMarking -- for SheetFileType only + | IconEmail deriving (Eq, Ord, Enum, Bounded, Show, Read) iconText :: Icon -> Text @@ -80,10 +81,7 @@ iconText = \case IconSFTHint -> "life-ring" -- for SheetFileType only IconSFTSolution -> "exclamation-circle" -- for SheetFileType only IconSFTMarking -> "check-circle" -- for SheetFileType only - --- | like iconText, but eliminates '-' since these are problemativ in alert-icons.js -iconJS :: Icon -> Text -iconJS = filter ('-' /=) . iconText + IconEmail -> "envelope" instance Universe Icon instance Finite Icon @@ -96,9 +94,10 @@ deriveJSON defaultOptions -- Create an icon from font-awesome without additional space icon :: Icon -> Markup -icon ic = let ict = iconText ic in - [shamlet|$newline never - |] +icon ic = [shamlet| + $newline never + + |] -- declare constats for all icons for compatibility and convenience -- "IconCourse" generates "iconCourse = icon IconCourse"