diff --git a/src/Foundation.hs b/src/Foundation.hs index c4f9aaa06..4938141d6 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -254,6 +254,11 @@ uniworxMessages = UniWorXMessages . map SomeMessage data MenuType = NavbarAside | NavbarRight | NavbarSecondary | PageActionPrime | PageActionSecondary | Footer deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic) +instance Universe MenuType +instance Finite MenuType + +makePrisms ''MenuType + data MenuItem = MenuItem { menuItemLabel :: UniWorXMessage , menuItemIcon :: Maybe Text -- currently from: https://fontawesome.com/icons?d=gallery @@ -263,6 +268,8 @@ data MenuItem = MenuItem , menuItemType :: MenuType } +makeLenses_ ''MenuItem + instance RedirectUrl UniWorX MenuItem where toTextUrl MenuItem{..} = toTextUrl menuItemRoute instance HasRoute UniWorX MenuItem where @@ -958,15 +965,13 @@ siteLayout headingOverride widget = do contentHeadline = (toWidget <$> headingOverride) <|> (pageHeading =<< mcurrentRoute) breadcrumbsWgt :: Widget breadcrumbsWgt = $(widgetFile "widgets/breadcrumbs") - pageactionprime :: Widget - pageactionprime = $(widgetFile "widgets/pageactionprime") -- TODO: rename, since it also shows secondary pageActions now + pageaction :: Widget + pageaction = $(widgetFile "widgets/pageaction") -- functions to determine if there are page-actions (primary or secondary) - isPageAction :: MenuType -> Bool - isPageAction PageActionPrime = True - isPageAction PageActionSecondary = True - isPageAction _ = False - hasPageActions :: Bool - hasPageActions = any (isPageAction . menuItemType . view _1) menuTypes + hasPageActions, hasSecondaryPageActions, hasPrimaryPageActions :: Bool + hasPageActions = hasPrimaryPageActions || hasSecondaryPageActions + hasSecondaryPageActions = any (is _PageActionSecondary) $ toListOf (traverse . _1 . _menuItemType) menuTypes + hasPrimaryPageActions = any (is _PageActionPrime) $ toListOf (traverse . _1 . _menuItemType) menuTypes pc <- widgetToPageContent $ do addScript $ StaticR js_zepto_js diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index b6b6ecdf7..bf936affd 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -15,27 +15,28 @@ $if not isModal