From 53670cbee075bcd69d28c2191c550327c01284c5 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Mon, 9 Aug 2021 12:22:50 +0200 Subject: [PATCH] Make confirmMessag for deleting users button non optional --- .../Core/Acp/Ui/User/Action/DeleteAction.ts | 4 ++++ .../Core/Acp/Ui/User/Action/Handler/Delete.ts | 9 ++------- .../Core/Acp/Ui/User/Action/DeleteAction.js | 3 +++ .../Core/Acp/Ui/User/Action/Handler/Delete.js | 10 ++-------- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/ts/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.ts b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.ts index c2d4dfeeaf..37efb572fc 100644 --- a/ts/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.ts +++ b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.ts @@ -14,6 +14,10 @@ export class DeleteAction extends AbstractUserAction { this.button.addEventListener("click", (event) => { event.preventDefault(); + if (!(typeof this.button.dataset.confirmMessage === "string")) { + throw new Error("The button does not provides a confirmMessage."); + } + const deleteHandler = new Delete( [this.userId], () => { diff --git a/ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.ts b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.ts index 5edebe6722..551912f01e 100644 --- a/ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.ts +++ b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.ts @@ -6,7 +6,6 @@ * @since 5.5 */ -import * as Language from "../../../../../Language"; import * as UiConfirmation from "../../../../../Ui/Confirmation"; import * as Ajax from "../../../../../Ajax"; import { CallbackSuccess } from "../../../../../Ajax/Data"; @@ -16,14 +15,10 @@ export class Delete { private successCallback: CallbackSuccess; private deleteMessage: string; - public constructor(userIDs: number[], successCallback: CallbackSuccess, deleteMessage?: string) { + public constructor(userIDs: number[], successCallback: CallbackSuccess, deleteMessage: string) { this.userIDs = userIDs; this.successCallback = successCallback; - if (deleteMessage) { - this.deleteMessage = deleteMessage; - } else { - this.deleteMessage = Language.get("wcf.button.delete.confirmMessage"); // @todo find better variable for a generic message - } + this.deleteMessage = deleteMessage; } public delete(): void { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.js index 75560ea80e..dd726758d6 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.js @@ -15,6 +15,9 @@ define(["require", "exports", "tslib", "./AbstractUserAction", "./Handler/Delete init() { this.button.addEventListener("click", (event) => { event.preventDefault(); + if (!(typeof this.button.dataset.confirmMessage === "string")) { + throw new Error("The button does not provides a confirmMessage."); + } const deleteHandler = new Delete_1.default([this.userId], () => { this.userDataElement.remove(); }, this.button.dataset.confirmMessage); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.js index 027fd38891..076cadf887 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.js @@ -5,23 +5,17 @@ * @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler * @since 5.5 */ -define(["require", "exports", "tslib", "../../../../../Language", "../../../../../Ui/Confirmation", "../../../../../Ajax"], function (require, exports, tslib_1, Language, UiConfirmation, Ajax) { +define(["require", "exports", "tslib", "../../../../../Ui/Confirmation", "../../../../../Ajax"], function (require, exports, tslib_1, UiConfirmation, Ajax) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Delete = void 0; - Language = tslib_1.__importStar(Language); UiConfirmation = tslib_1.__importStar(UiConfirmation); Ajax = tslib_1.__importStar(Ajax); class Delete { constructor(userIDs, successCallback, deleteMessage) { this.userIDs = userIDs; this.successCallback = successCallback; - if (deleteMessage) { - this.deleteMessage = deleteMessage; - } - else { - this.deleteMessage = Language.get("wcf.button.delete.confirmMessage"); // @todo find better variable for a generic message - } + this.deleteMessage = deleteMessage; } delete() { UiConfirmation.show({ -- 2.20.1