Support nested structures in `Ui/Object/Action/Delete`
authorMatthias Schmidt <gravatronics@live.com>
Sun, 21 Mar 2021 08:43:42 +0000 (09:43 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 21 Mar 2021 09:21:40 +0000 (10:21 +0100)
ts/WoltLabSuite/Core/Ui/Object/Action/Delete.ts
wcfsetup/install/files/acp/templates/menuItemList.tpl
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Delete.js
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index b69a13277e7a223e5a1077aef9be4bfca51afd8c..3ec1e78bca7b1c5d06df0b778bce2bd8a5722f49 100644 (file)
@@ -11,6 +11,13 @@ import UiObjectActionHandler from "./Handler";
 import { DatabaseObjectActionResponse } from "../../../Ajax/Data";
 
 function deleteObject(data: DatabaseObjectActionResponse, objectElement: HTMLElement): void {
+  const childContainer = objectElement.querySelector(".jsObjectActionObjectChildren");
+  if (childContainer) {
+    Array.from(childContainer.children).forEach((child: HTMLElement) => {
+      objectElement.parentNode!.insertBefore(child, objectElement);
+    });
+  }
+
   objectElement.remove();
 }
 
index 5f5e1c6a444fa130bf790fdafd9906ca8aeaaf9c..4617f1c276f2e1a967b47adcab81981b0b1634de 100644 (file)
                        }
                });
        });
-       
-       $(function() {
-               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);
-                               });
-                       });
-                       
-                       mpTriggerEffect.call(deleteAction, objectIDs);
-               };
-       });
 </script>
 
 <header class="contentHeader">
@@ -64,7 +48,7 @@
                                                                {/if}
                                                                <a href="{link controller='MenuItemEdit' id=$menuItemNode->itemID}{/link}" class="jsTooltip" title="{lang}wcf.global.button.edit{/lang}"><span class="icon icon16 fa-pencil"></span></a>
                                                                {if $menuItemNode->canDelete()}
-                                                                       <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$menuItemNode->itemID}" data-confirm-message-html="{lang __encode=true}wcf.acp.menu.item.delete.confirmMessage{/lang}"></span>
+                                                                       {objectAction action="delete" objectTitle=$menuItemNode->getTitle()}
                                                                {else}
                                                                        <span class="icon icon16 fa-times disabled" title="{lang}wcf.global.button.delete{/lang}"></span>
                                                                {/if}
@@ -73,7 +57,7 @@
                                                        </span>
                                                </span>
                                        
-                                               <ol class="sortableList" data-object-id="{@$menuItemNode->itemID}">{if !$menuItemNode->hasChildren()}</ol></li>{/if}
+                                               <ol class="sortableList jsObjectActionObjectChildren" data-object-id="{@$menuItemNode->itemID}">{if !$menuItemNode->hasChildren()}</ol></li>{/if}
                                                
                                                {if !$menuItemNode->hasChildren() && $menuItemNode->isLastSibling()}
                                                        {@"</ol></li>"|str_repeat:$menuItemNode->getOpenParentNodes()}
index 4261900ba12fbbad8c42022c959b4173401d4a12..032f5f0aebbaab784b5ea046da253038f2ca8ed9 100644 (file)
@@ -12,6 +12,12 @@ define(["require", "exports", "tslib", "./Handler"], function (require, exports,
     exports.setup = void 0;
     Handler_1 = tslib_1.__importDefault(Handler_1);
     function deleteObject(data, objectElement) {
+        const childContainer = objectElement.querySelector(".jsObjectActionObjectChildren");
+        if (childContainer) {
+            Array.from(childContainer.children).forEach((child) => {
+                objectElement.parentNode.insertBefore(child, objectElement);
+            });
+        }
         objectElement.remove();
     }
     function setup() {
index 5af1264a74eedc1f58e8d773d89b61487dcac605..d206e5b104cf2dc68ff2610772e076c17d5af6e7 100644 (file)
@@ -1178,7 +1178,6 @@ ACHTUNG: Die oben genannten Meldungen sind stark gekürzt. Sie können Details z
                <item name="wcf.acp.menu.list"><![CDATA[Menüs]]></item>
                <item name="wcf.acp.menu.item.add"><![CDATA[Menüpunkt hinzufügen]]></item>
                <item name="wcf.acp.menu.item.action.description"><![CDATA[Menü: {$menu->getTitle()}]]></item>
-               <item name="wcf.acp.menu.item.delete.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} den Menüpunkt <span class="confirmationObject">{$menuItemNode->getTitle()}</span> wirklich löschen?]]></item>
                <item name="wcf.acp.menu.item.edit"><![CDATA[Menüpunkt bearbeiten]]></item>
                <item name="wcf.acp.menu.item.externalURL"><![CDATA[Externe URL]]></item>
                <item name="wcf.acp.menu.item.isDisabled"><![CDATA[Menüpunkt deaktivieren]]></item>
index d919dac7afdec754a21d19645d850fffdc7af2c0..f617ca28f47b688aef13fd5bb9c799164fd45492 100644 (file)
@@ -1156,7 +1156,6 @@ ATTENTION: The messages listed above are greatly shortened. You can view details
                <item name="wcf.acp.menu.list"><![CDATA[Menus]]></item>
                <item name="wcf.acp.menu.item.add"><![CDATA[Add Menu Item]]></item>
                <item name="wcf.acp.menu.item.action.description"><![CDATA[Menu: {$menu->getTitle()}]]></item>
-               <item name="wcf.acp.menu.item.delete.confirmMessage"><![CDATA[Do you really want to delete the menu item <span class="confirmationObject">{$menuItemNode->getTitle()}</span>?]]></item>
                <item name="wcf.acp.menu.item.edit"><![CDATA[Edit Menu Item]]></item>
                <item name="wcf.acp.menu.item.externalURL"><![CDATA[External URL]]></item>
                <item name="wcf.acp.menu.item.isDisabled"><![CDATA[Disable menu item]]></item>