Skip to content

Commit 80819f0

Browse files
committed
Migrate user group copy to FormBuilderDialogInteraction
1 parent cb9c30e commit 80819f0

File tree

9 files changed

+39
-69
lines changed

9 files changed

+39
-69
lines changed

ts/WoltLabSuite/Core/Acp/Component/User/Group/Copy.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

ts/WoltLabSuite/Core/Component/Interaction/FormBuilderDialog.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function handleFormBuilderDialogAction(
2020
interactionEffect: InteractionEffect = InteractionEffect.ReloadItem,
2121
detail: Payload,
2222
): Promise<void> {
23-
const { ok } = await dialogFactory().usingFormBuilder().fromEndpoint(endpoint);
23+
const { ok, result } = await dialogFactory().usingFormBuilder().fromEndpoint<Payload>(endpoint);
2424

2525
if (!ok) {
2626
return;
@@ -32,6 +32,7 @@ async function handleFormBuilderDialogAction(
3232
bubbles: true,
3333
detail: {
3434
...detail,
35+
...result,
3536
_reloadPage: String(interactionEffect === InteractionEffect.ReloadPage),
3637
},
3738
}),
@@ -41,6 +42,7 @@ async function handleFormBuilderDialogAction(
4142
new CustomEvent<Payload>("interaction:invalidate-all", {
4243
detail: {
4344
...detail,
45+
...result,
4446
},
4547
}),
4648
);
@@ -50,6 +52,7 @@ async function handleFormBuilderDialogAction(
5052
bubbles: true,
5153
detail: {
5254
...detail,
55+
...result,
5356
},
5457
}),
5558
);

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
{include file='header' pageTitle='wcf.acp.group.'|concat:$action}
22

33
<script data-relocate="true">
4-
{if $action == 'edit' && $group->canCopy()}
5-
require(['WoltLabSuite/Core/Acp/Component/User/Group/Copy'], ({ init }) => {
6-
init();
7-
});
8-
{/if}
9-
104
$(function() {
115
{if $action === 'add' && $isBlankForm}
126
elBySelAll('.jsBbcodeSelectOptionHtml input[type="checkbox"]', undefined, function (checkbox) {
@@ -43,12 +37,20 @@
4337
</li>
4438
{/if}
4539

46-
{if $group->canCopy()}
47-
<li><button type="button" class="jsButtonUserGroupCopy button" data-endpoint="{link controller="UserGroupCopy" id=$groupID}{/link}">{icon name='copy'} <span>{lang}wcf.acp.group.button.copy{/lang}</span></button></li>
48-
{/if}
49-
5040
<li>
5141
{unsafe:$interactionContextMenu->render()}
42+
<script data-relocate="true">
43+
{
44+
const container = document.getElementById('{unsafe:$interactionContextMenu->getContainerID()|encodeJS}');
45+
container.addEventListener('interaction:invalidate-all', (event) => {
46+
if (event.detail.interaction === 'copy') {
47+
setTimeout(() => {
48+
window.location.href = event.detail.redirectURL;
49+
}, 2000);
50+
}
51+
});
52+
}
53+
</script>
5254
</li>
5355
{/if}
5456

wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Component/User/Group/Copy.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

wcfsetup/install/files/js/WoltLabSuite/Core/Component/Interaction/FormBuilderDialog.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wcfsetup/install/files/lib/acp/action/UserGroupCopyAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function getForm(): Psr15DialogForm
8989
{
9090
$form = new Psr15DialogForm(
9191
UserGroupCopyAction::class,
92-
WCF::getLanguage()->get('wcf.acp.dashboard.configure')
92+
WCF::getLanguage()->get('wcf.acp.group.copy')
9393
);
9494
$form->appendChildren([
9595
FormContainer::create('section')

wcfsetup/install/files/lib/system/interaction/admin/UserGroupInteractions.class.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace wcf\system\interaction\admin;
44

5+
use wcf\acp\action\UserGroupCopyAction;
56
use wcf\data\user\group\UserGroup;
67
use wcf\event\interaction\admin\UserGroupInteractionCollecting;
78
use wcf\system\event\EventHandler;
89
use wcf\system\interaction\AbstractInteractionProvider;
910
use wcf\system\interaction\DeleteInteraction;
11+
use wcf\system\interaction\FormBuilderDialogInteraction;
12+
use wcf\system\interaction\InteractionEffect;
13+
use wcf\system\request\LinkHandler;
1014

1115
/**
1216
* Interaction provider for user groups.
@@ -21,7 +25,16 @@ final class UserGroupInteractions extends AbstractInteractionProvider
2125
public function __construct()
2226
{
2327
$this->addInteractions([
24-
new DeleteInteraction("core/users/groups/%s", static fn(UserGroup $group) => $group->isDeletable())
28+
new DeleteInteraction("core/users/groups/%s", static fn(UserGroup $group) => $group->isDeletable()),
29+
new FormBuilderDialogInteraction(
30+
'copy',
31+
LinkHandler::getInstance()->getControllerLink(UserGroupCopyAction::class, ['id' => '%s']),
32+
'wcf.acp.group.button.copy',
33+
static function (UserGroup $group): bool {
34+
return $group->canCopy();
35+
},
36+
InteractionEffect::ReloadList
37+
)
2538
]);
2639

2740
EventHandler::getInstance()->fire(

wcfsetup/install/lang/de.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,8 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE
876876
<item name="wcf.acp.group.option.user.profile.aboutMeMaxLength"><![CDATA[Maximallänge „Über mich“]]></item>
877877
<item name="wcf.acp.group.option.user.profile.canReportContent"><![CDATA[Kann Inhalte melden]]></item>
878878
<item name="wcf.acp.group.option.admin.captcha.canManageCaptchaQuestion"><![CDATA[Kann Captcha-Fragen verwalten]]></item>
879-
<item name="wcf.acp.group.button.copy"><![CDATA[Benutzergruppe kopieren]]></item>
879+
<item name="wcf.acp.group.copy"><![CDATA[Benutzergruppe kopieren]]></item>
880+
<item name="wcf.acp.group.button.copy"><![CDATA[Kopieren]]></item>
880881
<item name="wcf.acp.group.copy.copyACLOptions"><![CDATA[Objekt-Berechtigungen kopieren]]></item>
881882
<item name="wcf.acp.group.copy.copyACLOptions.description"><![CDATA[Berechtigungen, die für bestimmte Objekte wie Labelgruppen gesetzt wurden, werden auch für die neue Benutzergruppe übernommen.]]></item>
882883
<item name="wcf.acp.group.copy.copyMembers"><![CDATA[Mitglieder kopieren]]></item>

wcfsetup/install/lang/en.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru
852852
<item name="wcf.acp.group.option.user.profile.aboutMeMaxLength"><![CDATA[Maximum About Me Length]]></item>
853853
<item name="wcf.acp.group.option.user.profile.canReportContent"><![CDATA[Can report content]]></item>
854854
<item name="wcf.acp.group.option.admin.captcha.canManageCaptchaQuestion"><![CDATA[Can manage captcha questions]]></item>
855-
<item name="wcf.acp.group.button.copy"><![CDATA[Copy User Group]]></item>
855+
<item name="wcf.acp.group.copy"><![CDATA[Copy User Group]]></item>
856+
<item name="wcf.acp.group.button.copy"><![CDATA[Copy]]></item>
856857
<item name="wcf.acp.group.copy.copyACLOptions"><![CDATA[Copy Object Permissions]]></item>
857858
<item name="wcf.acp.group.copy.copyACLOptions.description"><![CDATA[The permissions set for certain objects like label groups will also be set for the new user group.]]></item>
858859
<item name="wcf.acp.group.copy.copyMembers"><![CDATA[Copy Members]]></item>

0 commit comments

Comments
 (0)