Commit b36ae048 by Tuomas Riihimäki

Generate correct sort for menus

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