From 4eb8d26da06690b2ea2bb70c834d7ef21acb0316 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 8 Jun 2017 12:00:28 +0200 Subject: [PATCH] Preserve child items when deleting menu items See #2293 --- .../install/files/acp/templates/menuItemList.tpl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/acp/templates/menuItemList.tpl b/wcfsetup/install/files/acp/templates/menuItemList.tpl index ab06781247..c412cbdaa9 100644 --- a/wcfsetup/install/files/acp/templates/menuItemList.tpl +++ b/wcfsetup/install/files/acp/templates/menuItemList.tpl @@ -15,8 +15,22 @@ }); $(function() { - new WCF.Action.Delete('wcf\\data\\menu\\item\\MenuItemAction', '.sortableNode', '> .sortableNodeLabel .jsDeleteButton'); new WCF.Action.Toggle('wcf\\data\\menu\\item\\MenuItemAction', '.sortableNode', '> .sortableNodeLabel .jsToggleButton'); + + var deleteAction = new WCF.Action.Delete('wcf\\data\\menu\\item\\MenuItemAction', '.sortableNode', '> .sortableNodeLabel .jsDeleteButton'); + var mpTriggerEffect = deleteAction.triggerEffect; + deleteAction.triggerEffect = function (objectIDs) { + // move children up by one + objectIDs.forEach(function (objectId) { + var item = elBySel('#menuItemList li[data-object-id="' + objectId + '"]'); + elBySelAll('.sortableList[data-object-id="' + objectId + '"] > li', item, function(childItem) { + item.parentNode.insertBefore(childItem, item); + }); + console.log("item", item); + }); + + mpTriggerEffect.call(deleteAction, objectIDs); + }; }); -- 2.20.1