Preserve child items when deleting menu items
authorAlexander Ebert <ebert@woltlab.com>
Thu, 8 Jun 2017 10:00:28 +0000 (12:00 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 8 Jun 2017 10:00:28 +0000 (12:00 +0200)
See #2293

wcfsetup/install/files/acp/templates/menuItemList.tpl

index ab067812471083109e6792d6f8fd35e4de9cbf0d..c412cbdaa9245909e861a36bfb2369c4d16dfcdc 100644 (file)
        });
        
        $(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);
+               };
        });
 </script>