Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ts/WoltLabSuite/Core/Component/Confirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ class ConfirmationPrefab {
});
}

async disable(title?: string): Promise<boolean> {
const dialog = dialogFactory().withoutContent().asConfirmation();

let question: string;
if (title === undefined) {
question = getPhrase("wcf.dialog.confirmation.disable.indeterminate");
} else {
question = getPhrase("wcf.dialog.confirmation.disable", { title });
}

dialog.show(question);

return new Promise<boolean>((resolve) => {
dialog.addEventListener("primary", () => resolve(true));
dialog.addEventListener("cancel", () => resolve(false));
});
}

async restore(title?: string): Promise<boolean> {
const dialog = dialogFactory().withoutContent().asConfirmation();

Expand Down
7 changes: 7 additions & 0 deletions ts/WoltLabSuite/Core/Component/Interaction/Confirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum ConfirmationType {
SoftDeleteWithReason = "SoftDeleteWithReason",
Restore = "Restore",
Delete = "Delete",
Disable = "Disable",
Custom = "Custom",
}

Expand Down Expand Up @@ -48,6 +49,12 @@ export async function handleConfirmation(
};
}

if (confirmationType == ConfirmationType.Disable) {
return {
result: await confirmationFactory().disable(objectName ? objectName : undefined),
};
}

if (confirmationType == ConfirmationType.Custom) {
return {
result: await confirmationFactory().custom(customMessage).withoutMessage(),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function __invoke(PreloadPhrasesCollecting $event): void
$event->preload('wcf.dialog.confirmation.cannotBeUndone');
$event->preload('wcf.dialog.confirmation.delete');
$event->preload('wcf.dialog.confirmation.delete.indeterminate');
$event->preload('wcf.dialog.confirmation.disable');
$event->preload('wcf.dialog.confirmation.disable.indeterminate');
$event->preload('wcf.dialog.confirmation.softDelete');
$event->preload('wcf.dialog.confirmation.softDelete.indeterminate');
$event->preload('wcf.dialog.confirmation.restore');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace wcf\system\interaction;

/**
* Represents a disable interaction.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
class DisableInteraction extends RpcInteraction
{
public function __construct(
string $endpoint,
?\Closure $isAvailableCallback = null
) {
parent::__construct(
'disable',
$endpoint,
'wcf.global.button.disable',
InteractionConfirmationType::Disable,
'',
$isAvailableCallback
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum InteractionConfirmationType
case SoftDeleteWithReason;
case Restore;
case Delete;
case Disable;
case Custom;

public function toString(): string
Expand All @@ -27,6 +28,7 @@ public function toString(): string
self::SoftDeleteWithReason => 'SoftDeleteWithReason',
self::Restore => 'Restore',
self::Delete => 'Delete',
self::Disable => 'Disable',
self::Custom => 'Custom',
};
}
Expand Down
2 changes: 2 additions & 0 deletions wcfsetup/install/lang/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3796,6 +3796,8 @@ Dateianhänge:
<item name="wcf.dialog.confirmation.cannotBeUndone"><![CDATA[Dieser Vorgang kann nicht rückgängig gemacht werden.]]></item>
<item name="wcf.dialog.confirmation.delete"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} „{$title}“ wirklich löschen?]]></item>
<item name="wcf.dialog.confirmation.delete.indeterminate"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} dies wirklich löschen?]]></item>
<item name="wcf.dialog.confirmation.disable"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} „{$title}“ wirklich deaktivieren?]]></item>
<item name="wcf.dialog.confirmation.disable.indeterminate"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} dies wirklich deaktivieren?]]></item>
<item name="wcf.dialog.confirmation.softDelete"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} „{$title}“ in den Papierkorb verschieben?]]></item>
<item name="wcf.dialog.confirmation.softDelete.indeterminate"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} dies in den Papierkorb verschieben?]]></item>
<item name="wcf.dialog.confirmation.restore"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Möchtest du{else}Möchten Sie{/if} „{$title}“ wiederherstellen?]]></item>
Expand Down
2 changes: 2 additions & 0 deletions wcfsetup/install/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3742,6 +3742,8 @@ Attachments:
<item name="wcf.dialog.confirmation.cannotBeUndone"><![CDATA[This process cannot be undone.]]></item>
<item name="wcf.dialog.confirmation.delete"><![CDATA[Are you sure you want to delete “{$title}”?]]></item>
<item name="wcf.dialog.confirmation.delete.indeterminate"><![CDATA[Are you sure you want to delete this?]]></item>
<item name="wcf.dialog.confirmation.disable"><![CDATA[Do you want to disable “{$title}”?]]></item>
<item name="wcf.dialog.confirmation.disable.indeterminate"><![CDATA[Do you want to disable this?]]></item>
<item name="wcf.dialog.confirmation.softDelete"><![CDATA[Do you want to move “{$title}” to the trash bin?]]></item>
<item name="wcf.dialog.confirmation.softDelete.indeterminate"><![CDATA[Do you want to move this to the trash bin?]]></item>
<item name="wcf.dialog.confirmation.restore"><![CDATA[Do you want to restore “{$title}”?]]></item>
Expand Down
Loading