From: Cyperghost Date: Tue, 3 Dec 2024 09:16:36 +0000 (+0100) Subject: Migrate `WCF.ACP.User.Group.Copy` to TypeScript X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=06787917de73ec32a626d0be6cad769a1fd36716;p=GitHub%2FWoltLab%2FWCF.git Migrate `WCF.ACP.User.Group.Copy` to TypeScript --- diff --git a/ts/WoltLabSuite/Core/Acp/Ui/User/Group/Copy.ts b/ts/WoltLabSuite/Core/Acp/Ui/User/Group/Copy.ts new file mode 100644 index 0000000000..45866e4ad7 --- /dev/null +++ b/ts/WoltLabSuite/Core/Acp/Ui/User/Group/Copy.ts @@ -0,0 +1,28 @@ +/** + * Handles the dialog to copy a user group. + * + * @author Olaf Braun + * @copyright 2001-2024 WoltLab GmbH + * @license GNU Lesser General Public License + */ + +import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog"; + +interface CopyResponse { + groupID: number; + redirectURL: string; +} + +export function init() { + const button = document.querySelector(".jsButtonUserGroupCopy"); + button?.addEventListener("click", () => { + void dialogFactory() + .usingFormBuilder() + .fromEndpoint(button.dataset.endpoint!) + .then((result) => { + if (result.ok) { + window.location.href = result.result.redirectURL; + } + }); + }); +} diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 4a45c87748..567ad9ef13 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -1283,64 +1283,6 @@ WCF.ACP.User.BanHandler = { } }; -/** - * Namespace for user group management. - */ -WCF.ACP.User.Group = { }; - -/** - * Handles copying user groups. - */ -WCF.ACP.User.Group.Copy = Class.extend({ - /** - * id of the copied group - * @var integer - */ - _groupID: 0, - - /** - * Initializes a new instance of WCF.ACP.User.Group.Copy. - * - * @param integer groupID - */ - init: function(groupID) { - this._groupID = groupID; - - $('.jsButtonUserGroupCopy').click($.proxy(this._click, this)); - }, - - /** - * Handles clicking on a 'copy user group' button. - */ - _click: function() { - var $template = $('
'); - $template.append($('
' + WCF.Language.get('wcf.acp.group.copy.copyMembers.description') + '
')); - $template.append($('
' + WCF.Language.get('wcf.acp.group.copy.copyUserGroupOptions.description') + '
')); - $template.append($('
' + WCF.Language.get('wcf.acp.group.copy.copyACLOptions.description') + '
')); - - WCF.System.Confirmation.show(WCF.Language.get('wcf.acp.group.copy.confirmMessage'), $.proxy(function(action) { - if (action === 'confirm') { - new WCF.Action.Proxy({ - autoSend: true, - data: { - actionName: 'copy', - className: 'wcf\\data\\user\\group\\UserGroupAction', - objectIDs: [ this._groupID ], - parameters: { - copyACLOptions: $('#copyACLOptions').is(':checked'), - copyMembers: $('#copyMembers').is(':checked'), - copyUserGroupOptions: $('#copyUserGroupOptions').is(':checked') - } - }, - success: function(data) { - window.location = data.returnValues.redirectURL; - } - }); - } - }, this), '', $template, true); - } -}); - /** * Generic implementation to enable users. */ diff --git a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl index c7b0ece143..c4f27aa586 100644 --- a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl @@ -1,23 +1,15 @@ {include file='header' pageTitle='wcf.acp.group.'|concat:$action}