From 378f5b4afc404a5cd8c41998ec1e9e39975581d2 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 21 Mar 2021 09:43:42 +0100 Subject: [PATCH] Support nested structures in `Ui/Object/Action/Delete` --- .../Core/Ui/Object/Action/Delete.ts | 7 +++++++ .../files/acp/templates/menuItemList.tpl | 20 ++----------------- .../Core/Ui/Object/Action/Delete.js | 6 ++++++ wcfsetup/install/lang/de.xml | 1 - wcfsetup/install/lang/en.xml | 1 - 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/ts/WoltLabSuite/Core/Ui/Object/Action/Delete.ts b/ts/WoltLabSuite/Core/Ui/Object/Action/Delete.ts index b69a13277e..3ec1e78bca 100644 --- a/ts/WoltLabSuite/Core/Ui/Object/Action/Delete.ts +++ b/ts/WoltLabSuite/Core/Ui/Object/Action/Delete.ts @@ -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(); } diff --git a/wcfsetup/install/files/acp/templates/menuItemList.tpl b/wcfsetup/install/files/acp/templates/menuItemList.tpl index 5f5e1c6a44..4617f1c276 100644 --- a/wcfsetup/install/files/acp/templates/menuItemList.tpl +++ b/wcfsetup/install/files/acp/templates/menuItemList.tpl @@ -13,22 +13,6 @@ } }); }); - - $(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); - }; - });
@@ -64,7 +48,7 @@ {/if} {if $menuItemNode->canDelete()} - + {objectAction action="delete" objectTitle=$menuItemNode->getTitle()} {else} {/if} @@ -73,7 +57,7 @@ -
    {if !$menuItemNode->hasChildren()}
{/if} +
    {if !$menuItemNode->hasChildren()}
{/if} {if !$menuItemNode->hasChildren() && $menuItemNode->isLastSibling()} {@""|str_repeat:$menuItemNode->getOpenParentNodes()} diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Delete.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Delete.js index 4261900ba1..032f5f0aeb 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Delete.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Object/Action/Delete.js @@ -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() { diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 5af1264a74..d206e5b104 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1178,7 +1178,6 @@ ACHTUNG: Die oben genannten Meldungen sind stark gekürzt. Sie können Details z getTitle()}]]> - {$menuItemNode->getTitle()} wirklich löschen?]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index d919dac7af..f617ca28f4 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1156,7 +1156,6 @@ ATTENTION: The messages listed above are greatly shortened. You can view details getTitle()}]]> - {$menuItemNode->getTitle()}?]]> -- 2.20.1