Commit b36ae048 by Tuomas Riihimäki

Generate correct sort for menus

1 parent a6b6adb4
......@@ -71,6 +71,8 @@ public class MenuNavigationFacade extends IntegerPkGenericFacade<MenuNavigation>
cb.equal(root.get(MenuNavigation_.event), eventbean.getCurrentEvent()),
cb.isTrue(root.get(MenuNavigation_.visible)));
cq.orderBy(cb.asc(root.get(MenuNavigation_.sort)));
return getEm().createQuery(cq).getResultList();
}
......
......@@ -17,4 +17,6 @@ public interface MenuBeanLocal {
List<MenuNavigation> getTopmenus();
void flushOldMenu();
}
......@@ -82,8 +82,9 @@ public class MenuNavigation extends GenericEntity implements Comparable<MenuNavi
super();
}
public MenuNavigation(LanEvent ev, String keyString) {
public MenuNavigation(LanEvent ev, String keyString, Integer sort) {
super();
this.sort = sort;
this.event = ev;
this.key = keyString;
this.visible = true;
......@@ -183,8 +184,11 @@ public class MenuNavigation extends GenericEntity implements Comparable<MenuNavi
// used only for initialization function...
public MenuNavigation addPage(Menuitem item, IAppPermission permission) {
int childSort = 100;
if (children == null) {
children = new ArrayList<MenuNavigation>();
} else {
childSort = children.get(children.size() - 1).getSort() + 10;
}
MenuNavigation add = new MenuNavigation();
if (item != null)
......@@ -196,6 +200,7 @@ public class MenuNavigation extends GenericEntity implements Comparable<MenuNavi
add.setPermission(permission);
add.setParent(this);
add.setVisible(true);
add.setSort(childSort);
children.add(add);
return add;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!