-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add top(header) menu #641
base: future
Are you sure you want to change the base?
Add top(header) menu #641
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<wicket:panel xmlns:wicket="http://www.w3.org/1999/xhtml"> | ||
<div class="collapse navbar-collapse"> | ||
<ul class="navbar-nav"> | ||
<li wicket:id="items" class="nav-item"> | ||
<a href="#" class="nav-link" wicket:id="link"> | ||
<span wicket:id="name"></span> | ||
</a> | ||
<div class="dropdown-menu"> | ||
<div wicket:id="subItems"> | ||
<a wicket:id="subItemLink" class="dropdown-item" href="#"><span wicket:id="name"></span></a> | ||
</div> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
</wicket:panel> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package org.orienteer.core.web; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.wicket.AttributeModifier; | ||
import org.apache.wicket.behavior.AttributeAppender; | ||
import org.apache.wicket.markup.html.basic.Label; | ||
import org.apache.wicket.markup.html.link.ExternalLink; | ||
import org.apache.wicket.markup.html.list.ListItem; | ||
import org.apache.wicket.markup.html.list.ListView; | ||
import org.apache.wicket.markup.html.panel.GenericPanel; | ||
import org.apache.wicket.model.IModel; | ||
import org.apache.wicket.model.PropertyModel; | ||
import org.apache.wicket.request.cycle.RequestCycle; | ||
import org.orienteer.core.model.ODocumentNameModel; | ||
|
||
import com.orientechnologies.orient.core.record.impl.ODocument; | ||
|
||
import ru.ydn.wicket.wicketorientdb.model.ODocumentPropertyModel; | ||
|
||
/** | ||
* | ||
* Flat menu panel with dropdown support | ||
* | ||
*/ | ||
public class FlatMenuPanel extends GenericPanel<ODocument>{ | ||
private static final long serialVersionUID = 1L; | ||
private String itemsFieldName; | ||
|
||
public FlatMenuPanel(String id, IModel<ODocument> itemModel, String itemsFieldName) { | ||
super(id, itemModel); | ||
this.itemsFieldName = itemsFieldName; | ||
setOutputMarkupId(true); | ||
add(new ListView<ODocument>("items", new PropertyModel<List<ODocument>>(this, "items")) { | ||
|
||
@Override | ||
protected void populateItem(ListItem<ODocument> item) { | ||
IModel<ODocument> itemModel = item.getModel(); | ||
ODocumentPropertyModel<String> urlModel = new ODocumentPropertyModel<String>(itemModel, "url"); | ||
ODocumentPropertyModel<List<ODocument>> subItems = new ODocumentPropertyModel<List<ODocument>>(itemModel, "subItems"); | ||
final boolean hasSubItems = subItems.getObject() != null && !subItems.getObject().isEmpty(); | ||
ExternalLink link = new ExternalLink("link", urlModel) | ||
.setContextRelative(true); | ||
link.add(new Label("name", new ODocumentNameModel(item.getModel())).setRenderBodyOnly(true)); | ||
item.add(link); | ||
if (isActiveItem(urlModel)) { | ||
link.add(new AttributeAppender("class", " active")); | ||
} | ||
if (hasSubItems){ | ||
link.add(new AttributeModifier("aria-expanded", "false")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why these lines needed? It can be coded right in HTML. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If i do - all links show as dropdowns |
||
link.add(new AttributeModifier("aria-haspopup", "true")); | ||
link.add(new AttributeModifier("data-toggle", "dropdown")); | ||
|
||
item.add(new AttributeAppender("class", " dropdown")); | ||
link.add(new AttributeAppender("class", " dropdown-toggle")); | ||
} | ||
item.add(new ListView<ODocument>("subItems", subItems) { | ||
@Override | ||
protected void populateItem(ListItem<ODocument> item) { | ||
item.setRenderBodyOnly(true); | ||
IModel<ODocument> itemModel = item.getModel(); | ||
ODocumentPropertyModel<String> urlModel = new ODocumentPropertyModel<String>(itemModel, "url"); | ||
ExternalLink link = new ExternalLink("subItemLink", urlModel) | ||
.setContextRelative(true); | ||
link.add(new Label("name", new ODocumentNameModel(item.getModel())).setRenderBodyOnly(true)); | ||
item.add(link); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
protected void onConfigure() { | ||
super.onConfigure(); | ||
List<ODocument> subItems = getItems(); | ||
setVisible(subItems!=null && !subItems.isEmpty()); | ||
} | ||
|
||
public List<ODocument> getItems() { | ||
return getItems(getModelObject()); | ||
} | ||
|
||
public List<ODocument> getItems(ODocument doc) { | ||
List<ODocument> items = null; | ||
if(doc!=null) { | ||
items = doc.field(getItemsFieldName()); | ||
} | ||
if(items!=null) items.remove(null); //Remove deleted records | ||
return items; | ||
} | ||
|
||
public String getItemsFieldName() { | ||
return itemsFieldName; | ||
} | ||
|
||
private boolean isActiveItem(ODocumentPropertyModel<String> urlModel) { | ||
String currentUrl = RequestCycle.get().getRequest().getUrl().getPath(); | ||
String url = urlModel.getObject(); | ||
return url!=null && currentUrl.equals(url.replaceFirst("^/", "")); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
|
||
<nav class="navbar navbar-expand-lg" wicket:id="topMenu"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is menu looks good from mobile? Menu should be just collapsed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is bootstrap menu. I think mobile devices supported. |
||
</nav> | ||
|
||
<ul class="nav navbar-nav d-md-down-none ml-auto"> | ||
<li class="nav-item px-1"> | ||
<form wicket:id="searchForm" class="sidebar-search"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ public boolean isEnabled(Component component) { | |
|
||
@Override | ||
protected void populateItem(final ListItem<ODocument> item) { | ||
item.setRenderBodyOnly(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commonly it's not recommended because of AJAX. Why it's needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In bootstrap4 dropdowns use links directly, without external tags. |
||
IModel<ODocument> itemModel = item.getModel(); | ||
Link<ODocument> link = new AjaxFallbackLink<ODocument>("link", itemModel) { | ||
@Override | ||
|
@@ -109,6 +110,7 @@ public void onClick(AjaxRequestTarget target) { | |
add(new BookmarkablePageLink<Object>("logout", LogoutPage.class).setVisible(signedIn)); | ||
|
||
add(new RecursiveMenuPanel("perspectiveItems", perspectiveModel)); | ||
add(new FlatMenuPanel("topMenu", perspectiveModel,"topMenu")); | ||
|
||
|
||
add(feedbacks = new OrienteerFeedbackPanel("feedbacks")); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why these 2 classes additionally needed? There is already class for menu items for left menu - lets just use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top menu not support recursive trees display. Only top level and dropdowns.All - without icons.