Introduce pageActions and use in favourites
This commit is contained in:
parent
8433df99c7
commit
ad6f1ab199
@ -9,6 +9,7 @@
|
|||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
{-# LANGUAGE NamedFieldPuns #-}
|
{-# LANGUAGE NamedFieldPuns #-}
|
||||||
{-# LANGUAGE PatternGuards #-}
|
{-# LANGUAGE PatternGuards #-}
|
||||||
|
{-# LANGUAGE TupleSections #-}
|
||||||
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
|
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
|
||||||
|
|
||||||
module Foundation where
|
module Foundation where
|
||||||
@ -353,6 +354,15 @@ instance YesodBreadcrumbs UniWorX where
|
|||||||
breadcrumb ProfileR = return ("Profile", Just HomeR)
|
breadcrumb ProfileR = return ("Profile", Just HomeR)
|
||||||
breadcrumb _ = return ("home", Nothing)
|
breadcrumb _ = return ("home", Nothing)
|
||||||
|
|
||||||
|
pageActions :: Route UniWorX -> [MenuTypes]
|
||||||
|
pageActions (CourseR tid csh CourseShowR) = [ PageActionPrime $ MenuItem
|
||||||
|
{ menuItemLabel = "Übungsblätter"
|
||||||
|
, menuItemIcon = Nothing
|
||||||
|
, menuItemRoute = CSheetR tid csh SheetListR
|
||||||
|
, menuItemAccessCallback' = return True
|
||||||
|
}
|
||||||
|
]
|
||||||
|
pageActions _ = []
|
||||||
|
|
||||||
defaultLinks :: [MenuTypes]
|
defaultLinks :: [MenuTypes]
|
||||||
defaultLinks = -- Define the menu items of the header.
|
defaultLinks = -- Define the menu items of the header.
|
||||||
@ -422,7 +432,7 @@ defaultMenuLayout menu widget = do
|
|||||||
menuTypes <- filterM (menuItemAccessCallback . menuItem) menu
|
menuTypes <- filterM (menuItemAccessCallback . menuItem) menu
|
||||||
|
|
||||||
-- Lookup Favourites if possible
|
-- Lookup Favourites if possible
|
||||||
favourites <- do
|
favourites' <- do
|
||||||
muid <- maybeAuthId
|
muid <- maybeAuthId
|
||||||
case muid of
|
case muid of
|
||||||
Nothing -> return []
|
Nothing -> return []
|
||||||
@ -432,6 +442,11 @@ defaultMenuLayout menu widget = do
|
|||||||
E.orderBy [ E.asc $ course E.^. CourseShorthand ]
|
E.orderBy [ E.asc $ course E.^. CourseShorthand ]
|
||||||
return course
|
return course
|
||||||
|
|
||||||
|
favourites <- forM favourites' $ \(Entity _ c@Course{..})
|
||||||
|
-> let
|
||||||
|
courseRoute = CourseR courseTermId courseShorthand CourseShowR
|
||||||
|
in (c, courseRoute, ) <$> filterM (menuItemAccessCallback . menuItem) (pageActions courseRoute)
|
||||||
|
|
||||||
-- We break up the default layout into two components:
|
-- We break up the default layout into two components:
|
||||||
-- default-layout is the contents of the body tag, and
|
-- default-layout is the contents of the body tag, and
|
||||||
-- default-layout-wrapper is the entire page. Since the final
|
-- default-layout-wrapper is the entire page. Since the final
|
||||||
|
|||||||
@ -92,15 +92,7 @@ getCourseShowR tid csh = do
|
|||||||
return $ (courseEnt,dependent)
|
return $ (courseEnt,dependent)
|
||||||
let course = entityVal courseEnt
|
let course = entityVal courseEnt
|
||||||
(regWidget, regEnctype) <- generateFormPost $ identifyForm "registerBtn" $ registerButton $ mbRegistered
|
(regWidget, regEnctype) <- generateFormPost $ identifyForm "registerBtn" $ registerButton $ mbRegistered
|
||||||
let pageActions =
|
defaultLinkLayout [] $ do
|
||||||
[ PageActionPrime $ MenuItem
|
|
||||||
{ menuItemLabel = "Übungsblätter"
|
|
||||||
, menuItemIcon = Nothing
|
|
||||||
, menuItemRoute = CSheetR tid csh SheetListR
|
|
||||||
, menuItemAccessCallback' = return True
|
|
||||||
}
|
|
||||||
]
|
|
||||||
defaultLinkLayout pageActions $ do
|
|
||||||
setTitle $ [shamlet| #{toPathPiece tid} - #{csh}|]
|
setTitle $ [shamlet| #{toPathPiece tid} - #{csh}|]
|
||||||
$(widgetFile "course")
|
$(widgetFile "course")
|
||||||
|
|
||||||
|
|||||||
@ -17,23 +17,17 @@ $newline never
|
|||||||
<h3 .asidenav__box-title>
|
<h3 .asidenav__box-title>
|
||||||
WiSe 17/18
|
WiSe 17/18
|
||||||
<ul .asidenav__list>
|
<ul .asidenav__list>
|
||||||
$forall (Entity _ Course{..}) <- favourites
|
$forall (Course{..}, courseRoute, pageActions) <- favourites
|
||||||
$with route <- CourseR courseTermId courseShorthand CourseShowR
|
<li .asidenav__list-item>
|
||||||
<li .asidenav__list-item :Just route == mcurrentRoute:.asidenav__list-item--active>
|
<a .asidenav__link-wrapper href=@{courseRoute}>
|
||||||
<a .asidenav__link-wrapper href=@{route}>
|
<div .asidenav__link-shorthand>#{courseShorthand}
|
||||||
<div .asidenav__link-shorthand>#{courseShorthand}
|
<div .asidenav__link-label>#{courseName}
|
||||||
<div .asidenav__link-label>#{courseName}
|
<ul .asidenav__nested-list>
|
||||||
|
$forall action <- pageActions
|
||||||
<li .asidenav__list-item>
|
$case action
|
||||||
<a .asidenav__link-wrapper href="/course/S2018/ixd/show">
|
$of PageActionPrime (MenuItem{..})
|
||||||
<div .asidenav__link-shorthand>EXAMPLE
|
<li .asidenav__list-item>
|
||||||
<div .asidenav__link-label>Beispiel-Kurs
|
<a .asidenav__link-wrapper href=@{menuItemRoute}>#{menuItemLabel}
|
||||||
<ul .asidenav__nested-list>
|
$of _
|
||||||
<li .asidenav__list-item>
|
|
||||||
<a .asidenav__link-wrapper href="/course/S2018/ixd/ex">Übungsblätter
|
|
||||||
<li .asidenav__list-item>
|
|
||||||
<a .asidenav__link-wrapper href="/course/S2018/ixd/show">Klausuren
|
|
||||||
<li .asidenav__list-item>
|
|
||||||
<a .asidenav__link-wrapper href="/course/S2018/ixd/show">Übungsgruppen
|
|
||||||
|
|
||||||
<div .asidenav__toggler>
|
<div .asidenav__toggler>
|
||||||
|
|||||||
Reference in New Issue
Block a user