Commit 5cf22e0f by Anton Sudak

Updated navigation

parent e8c0a3e6
@import scala.collection.JavaConversions.collectionAsScalaIterable
@import ch.insign.cms.models.Template
@import ch.insign.cms.models.PageBlock
@import ch.insign.cms.views.html._navigation
@(
root: ch.insign.cms.models.PageBlock,
active: ch.insign.cms.models.PageBlock = null,
level: Integer = 0
root: PageBlock,
active: PageBlock = null,
level: Integer = 1
)
@logger = @{ org.slf4j.LoggerFactory.getLogger("_navigation.scala.html") }
@Option(root).map(_.getSubPages).map(Template.filterPermitted(_)).map { items => @items.map { item =>
@if(level > 1) {
<a class="dropdown-item @if(item == active){active}" href="@item.getNavItem.getURL">
@item.getNavTitle
</a>
@_navigation(item, active, level + 1)
} else {
<li class="nav-item">
<div class="btn-group">
<a href="@item.getNavItem.getURL" class="nav-link @if(item == active){active}">
@item.getNavTitle
</a>
@if(root != null) {
@if(root.getSubPages.nonEmpty) {
@Template.filterPermitted(root.getSubPages).map { subPage =>
<!-- TODO: INCLUDE SUBMENU AS DROPDOWN -->
<li class="nav-item">
<a href="@subPage.getNavItem.getURL" class="nav-link @if(subPage.isActive) {active}">
@subPage.getNavTitle
</a>
@_navigation(root = subPage, active = active, level = level+1)
</li>
}
@if(item.getSubPages.nonEmpty && level == 1) {
<span class="btn dropdown-toggle dropdown-toggle-split" id="navDropdown@item.getId" data-toggle="dropdown"></span>
<div class="dropdown-menu" aria-labelledby="navDropdown@item.getId">
@_navigation(item, active, level + 1)
</div>
}
</div>
</li>
}
} else {
@logger.warn("_navigation: No root node present")
}
\ No newline at end of file
}}
\ No newline at end of file
@(
key: String,
active: ch.insign.cms.models.PageBlock=null,
level: Integer=0
)
@import ch.insign.cms.models.PageBlock
@import ch.insign.cms.models.NavigationItem
@import ch.insign.cms.controllers
@import play.api.i18n.Messages;
@import play.api.i18n.Messages
@import ch.insign.cms.views.html._navigation
@(
key: String,
active: ch.insign.cms.models.Page = null,
level: Integer = 0
)
@logger = @{ org.slf4j.LoggerFactory.getLogger("_navigationByKey.scala.html") }
@defining(PageBlock.find.byKey(key)){ root =>
@if(root == null) {
@logger.warn("_navigation: Could not load root page with key " + key)
}
@_navigation(root = root, active = active, level = level+1)
}
@Option(PageBlock.find.byKey(key)).map { root =>
@_navigation(root, Option(active).map { case p: PageBlock => p }.getOrElse(null), level + 1)
}.getOrElse(() => logger.warn("_navigation: Could not load root page with key " + key))
......@@ -2,8 +2,9 @@
@import ch.insign.cms.models.{CMS, PageBlock, StandalonePage, ContentBlock, Template}
@import ch.insign.cms.blocks.sliderblock.SliderCollectionBlock
@import ch.insign.cms.views.html.{_pageBase, _navigationByKey}
@import ch.insign.playauth.views.helper.{authenticated, notAuthenticated}
@import ch.insign.playauth.views.helper.{authenticated, notAuthenticated, hasPermission}
@import play.twirl.api.HtmlFormat
@import ch.insign.cms.permissions.ApplicationPermission
@(
page: ch.insign.cms.models.Page,
header: Html = HtmlFormat.empty,
......@@ -38,8 +39,10 @@
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
@_navigationByKey(PageBlock.KEY_FRONTEND, page)
</ul>
<ul class="navbar-nav ml-auto mt-2 mt-lg-0">
@_navigationByKey(PageBlock.KEY_FRONTEND)
@authenticated { party =>
<li class="nav-item">
<a href="#" class="nav-link">
......@@ -59,7 +62,7 @@
</a>
</li>
}
@authenticated { party =>
@hasPermission(ApplicationPermission.DEBUG) {
@if(Template.isDebugMode()) {
<li class="nav-item">
<a href="@request.path?debug=false" class="nav-link">
......@@ -77,7 +80,7 @@
@notAuthenticated {
<li class="nav-item">
<a href="#" data-target="#loginModal" data-toggle="modal" class="nav-link">
@Messages("login.modal.login.btn")
@Messages("login.modal.login.btn")
</a>
</li>
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment