feat(alerts js): support custom icons in Alerts HTTP-Header
This commit is contained in:
parent
bdaa9c6ecf
commit
8833cb5090
@ -137,7 +137,7 @@ export class Alerts {
|
|||||||
|
|
||||||
if (alerts) {
|
if (alerts) {
|
||||||
alerts.forEach((alert) => {
|
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._element.appendChild(alertElement);
|
||||||
this._alertElements.push(alertElement);
|
this._alertElements.push(alertElement);
|
||||||
this._initAlert(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');
|
const alertElement = document.createElement('div');
|
||||||
alertElement.classList.add(ALERT_CLASS, 'alert-' + type);
|
alertElement.classList.add(ALERT_CLASS, 'alert-' + type);
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ export class Alerts {
|
|||||||
alertCloser.classList.add(ALERT_CLOSER_CLASS);
|
alertCloser.classList.add(ALERT_CLOSER_CLASS);
|
||||||
|
|
||||||
const alertIcon = document.createElement('div');
|
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');
|
const alertContent = document.createElement('div');
|
||||||
alertContent.classList.add(ALERT_CONTENT_CLASS);
|
alertContent.classList.add(ALERT_CONTENT_CLASS);
|
||||||
|
|||||||
@ -113,7 +113,7 @@ postAdminTestR = do
|
|||||||
formResultModal emailResult AdminTestR $ \(email, ls) -> do
|
formResultModal emailResult AdminTestR $ \(email, ls) -> do
|
||||||
jId <- mapWriterT runDB $ do
|
jId <- mapWriterT runDB $ do
|
||||||
jId <- queueJob $ JobSendTestEmail email ls
|
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
|
return jId
|
||||||
writeJobCtl $ JobCtlPerform 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`
|
addMessage Warning [shamlet|Inkorrekt ausgegebener Alert|] -- For testing alert handling when short circuiting; for proper (not fallback-solution) handling always use `tell` within `formResultModal`
|
||||||
|
|||||||
@ -53,6 +53,7 @@ data Icon
|
|||||||
| IconSFTHint -- for SheetFileType only
|
| IconSFTHint -- for SheetFileType only
|
||||||
| IconSFTSolution -- for SheetFileType only
|
| IconSFTSolution -- for SheetFileType only
|
||||||
| IconSFTMarking -- for SheetFileType only
|
| IconSFTMarking -- for SheetFileType only
|
||||||
|
| IconEmail
|
||||||
deriving (Eq, Ord, Enum, Bounded, Show, Read)
|
deriving (Eq, Ord, Enum, Bounded, Show, Read)
|
||||||
|
|
||||||
iconText :: Icon -> Text
|
iconText :: Icon -> Text
|
||||||
@ -80,10 +81,7 @@ iconText = \case
|
|||||||
IconSFTHint -> "life-ring" -- for SheetFileType only
|
IconSFTHint -> "life-ring" -- for SheetFileType only
|
||||||
IconSFTSolution -> "exclamation-circle" -- for SheetFileType only
|
IconSFTSolution -> "exclamation-circle" -- for SheetFileType only
|
||||||
IconSFTMarking -> "check-circle" -- for SheetFileType only
|
IconSFTMarking -> "check-circle" -- for SheetFileType only
|
||||||
|
IconEmail -> "envelope"
|
||||||
-- | like iconText, but eliminates '-' since these are problemativ in alert-icons.js
|
|
||||||
iconJS :: Icon -> Text
|
|
||||||
iconJS = filter ('-' /=) . iconText
|
|
||||||
|
|
||||||
instance Universe Icon
|
instance Universe Icon
|
||||||
instance Finite Icon
|
instance Finite Icon
|
||||||
@ -96,9 +94,10 @@ deriveJSON defaultOptions
|
|||||||
|
|
||||||
-- Create an icon from font-awesome without additional space
|
-- Create an icon from font-awesome without additional space
|
||||||
icon :: Icon -> Markup
|
icon :: Icon -> Markup
|
||||||
icon ic = let ict = iconText ic in
|
icon ic = [shamlet|
|
||||||
[shamlet|$newline never
|
$newline never
|
||||||
<i .fas .fa-#{ict}>|]
|
<i .fas .fa-#{iconText ic}>
|
||||||
|
|]
|
||||||
|
|
||||||
-- declare constats for all icons for compatibility and convenience
|
-- declare constats for all icons for compatibility and convenience
|
||||||
-- "IconCourse" generates "iconCourse = icon IconCourse"
|
-- "IconCourse" generates "iconCourse = icon IconCourse"
|
||||||
|
|||||||
Reference in New Issue
Block a user