Added ability to hide subnav with showSubNav() in HalHttpPage
This commit is contained in:
parent
3b71021422
commit
c765b4d983
2 changed files with 35 additions and 8 deletions
|
|
@ -29,20 +29,29 @@
|
|||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<!-- Title and Icon -->
|
||||
<a class="navbar-brand" href="/">
|
||||
<span class="glyphicon glyphicon-record" style="color:red"></span>
|
||||
<b>HAL</b>
|
||||
</a>
|
||||
<!-- Hamburger button for smaller screens -->
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">
|
||||
<span class="glyphicon glyphicon-record" style="color:red"></span>
|
||||
<b>HAL</b>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Main navigation -->
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
{{#rootNav}}
|
||||
{{^.getSubNavs().length}}
|
||||
<li {{#.isActive()}}class="active"{{/.isActive()}}>
|
||||
<a href="{{.getURL()}}" >{{.getName()}}</a>
|
||||
</li>
|
||||
{{/.getSubNavs().length}}
|
||||
{{#.getSubNavs().length}}
|
||||
<li class="dropdown {{#.isActive()}}active{{/.isActive()}}">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{.getName()}}</a>
|
||||
<ul class="dropdown-menu">
|
||||
|
|
@ -53,9 +62,11 @@
|
|||
{{/.getSubNavs()}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/.getSubNavs().length}}
|
||||
{{/rootNav}}
|
||||
</ul>
|
||||
|
||||
<!-- User navigation -->
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
|
|
@ -83,6 +94,8 @@
|
|||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
{{#showSubNav}}
|
||||
<!-- Sub navigation -->
|
||||
<div class="col-sm-3 col-md-2 sidebar">
|
||||
<ul id="sub-navbar" class="nav nav-sidebar">
|
||||
{{#subNav}}
|
||||
|
|
@ -92,8 +105,10 @@
|
|||
{{/subNav}}
|
||||
</ul>
|
||||
</div>
|
||||
{{/showSubNav}}
|
||||
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
{{#showSubNav}}<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">{{/showSubNav}}
|
||||
{{^showSubNav}}<div class="col-sm-11 col-sm-offset-1 col-md-11 col-md-offset-1 main">{{/showSubNav}}
|
||||
{{alerts}}
|
||||
{{content}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -26,9 +26,11 @@ public abstract class HalHttpPage implements HttpPage{
|
|||
private static Navigation userNav = Navigation.createRootNav();
|
||||
|
||||
private String pageId;
|
||||
private boolean showSubNav;
|
||||
|
||||
public HalHttpPage(String id){
|
||||
this.pageId = id;
|
||||
this.showSubNav = true;
|
||||
}
|
||||
|
||||
public String getId(){
|
||||
|
|
@ -55,9 +57,12 @@ public abstract class HalHttpPage implements HttpPage{
|
|||
|
||||
Templator tmpl = new Templator(FileUtil.find(TEMPLATE));
|
||||
tmpl.set("user", User.getLocalUser(db));
|
||||
tmpl.set("showSubNav", showSubNav);
|
||||
if (showSubNav) {
|
||||
List<Navigation> breadcrumb = Navigation.getBreadcrumb(Navigation.getPagedNavigation(header));
|
||||
if (!breadcrumb.isEmpty())
|
||||
tmpl.set("subNav", breadcrumb.get(1).createPagedNavInstance(header).getSubNavs());
|
||||
}
|
||||
tmpl.set("rootNav", rootNav.createPagedNavInstance(header).getSubNavs());
|
||||
tmpl.set("userNav", userNav.createPagedNavInstance(header).getSubNavs());
|
||||
tmpl.set("alerts", HalAlertManager.getInstance().generateAlerts());
|
||||
|
|
@ -69,6 +74,12 @@ public abstract class HalHttpPage implements HttpPage{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if the subnavigation should be shown on the page
|
||||
*/
|
||||
protected void showSubNav(boolean show) {
|
||||
this.showSubNav = show;
|
||||
}
|
||||
|
||||
public static Navigation getRootNav(){
|
||||
return rootNav;
|
||||
|
|
@ -85,6 +96,7 @@ public abstract class HalHttpPage implements HttpPage{
|
|||
throws Exception;
|
||||
|
||||
|
||||
|
||||
public interface HalJsonPage{
|
||||
DataNode jsonResponse(
|
||||
Map<String, Object> session,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue