Skip to content

Instantly share code, notes, and snippets.

@lipusz
Created September 13, 2013 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lipusz/6553906 to your computer and use it in GitHub Desktop.
Save lipusz/6553906 to your computer and use it in GitHub Desktop.
http://issues.liferay.com/browse/LPS-39666 Hidden pages break page sorting in navigation bar
diff --git a/portal-web/docroot/html/js/liferay/navigation.js b/portal-web/docroot/html/js/liferay/navigation.js
index 59f71ae..ab423a6 100644
@@ -8,10 +8,10 @@ AUI.add(
var STATUS_CODE = Liferay.STATUS_CODE;
- var STR_LAYOUT_ID = 'layoutId';
-
var STR_EMPTY = '';
+ var STR_LAYOUT_ID = 'layoutId';
+
var TPL_EDITOR = '<div class="add-page-editor"><div class="input-append"></div></div>';
var TPL_FIELD_INPUT = '<input class="add-page-editor-input" type="text" value="{0}" />';
@@ -838,27 +838,30 @@ AUI.add(
function(node) {
var instance = this;
- var navItems = instance.get('navBlock').all('li');
+ var nextLayoutId = -1;
- var priority = -1;
+ var nextNode = node.next();
- navItems.some(
- function(item, index, collection) {
- if (!item.ancestor().hasClass('child-menu')) {
- priority++;
- }
+ if (nextNode) {
+ nextLayoutId = nextNode.getData(STR_LAYOUT_ID);
+ }
- return item == node;
- }
- );
+ var previousLayoutId = -1;
+
+ var previousNode = node.previous();
+
+ if (previousNode) {
+ previousLayoutId = previousNode.getData(STR_LAYOUT_ID);
+ }
var data = {
cmd: 'priority',
doAsUserId: themeDisplay.getDoAsUserIdEncoded(),
groupId: themeDisplay.getSiteGroupId(),
layoutId: node.getData(STR_LAYOUT_ID),
+ nextLayoutId: nextLayoutId,
p_auth: Liferay.authToken,
- priority: priority,
+ previousLayoutId: previousLayoutId,
privateLayout: themeDisplay.isPrivateLayout()
};
diff --git a/portal-impl/src/com/liferay/portlet/layoutsadmin/action/UpdateLayoutAction.java b/portal-impl/src/com/liferay/portlet/layoutsadmin/action/UpdateLayoutAction.java
index 159fe2c..fec898f 100644
@@ -29,6 +29,7 @@ import com.liferay.portal.model.Layout;
import com.liferay.portal.model.LayoutConstants;
import com.liferay.portal.model.LayoutPrototype;
import com.liferay.portal.security.permission.ActionKeys;
+import com.liferay.portal.service.LayoutLocalServiceUtil;
import com.liferay.portal.service.LayoutPrototypeServiceUtil;
import com.liferay.portal.service.LayoutServiceUtil;
import com.liferay.portal.service.ServiceContext;
@@ -288,7 +289,39 @@ public class UpdateLayoutAction extends JSONAction {
long groupId = ParamUtil.getLong(request, "groupId");
boolean privateLayout = ParamUtil.getBoolean(request, "privateLayout");
long layoutId = ParamUtil.getLong(request, "layoutId");
- int priority = ParamUtil.getInteger(request, "priority");
+ long nextLayoutId = ParamUtil.getLong(request, "nextLayoutId", -1);
+ long previousLayoutId = ParamUtil.getLong(
+ request, "previousLayoutId", -1);
+
+ Layout nextLayout = null;
+
+ if (nextLayoutId > -1) {
+ nextLayout = LayoutLocalServiceUtil.getLayout(
+ groupId, privateLayout, nextLayoutId);
+ }
+
+ Layout previousLayout = null;
+
+ if (previousLayoutId > -1) {
+ previousLayout = LayoutLocalServiceUtil.getLayout(
+ groupId, privateLayout, previousLayoutId);
+ }
+
+ Layout layout = LayoutLocalServiceUtil.getLayout(
+ groupId, privateLayout, layoutId);
+
+ int priority = layout.getPriority();
+
+ if ((nextLayout != null) &&
+ (layout.getPriority() > nextLayout.getPriority())) {
+
+ priority = nextLayout.getPriority();
+ }
+ else if ((previousLayout != null) &&
+ (layout.getPriority() < previousLayout.getPriority())) {
+
+ priority = previousLayout.getPriority();
+ }
if (plid <= 0) {
LayoutServiceUtil.updatePriority(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment