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) {
|
||||
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);
|
||||
|
||||
@ -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`
|
||||
|
||||
@ -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
|
||||
<i .fas .fa-#{ict}>|]
|
||||
icon ic = [shamlet|
|
||||
$newline never
|
||||
<i .fas .fa-#{iconText ic}>
|
||||
|]
|
||||
|
||||
-- declare constats for all icons for compatibility and convenience
|
||||
-- "IconCourse" generates "iconCourse = icon IconCourse"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user