Make confirmMessag for deleting users button non optional
authorjoshuaruesweg <ruesweg@woltlab.com>
Mon, 9 Aug 2021 10:22:50 +0000 (12:22 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Mon, 9 Aug 2021 10:22:50 +0000 (12:22 +0200)
ts/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.ts
ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/DeleteAction.js
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Delete.js

index c2d4dfeeaf9ab21c4c9d85b3e2df98509ee437ad..37efb572fc851fac28f86fb67c5cb31f42fc1f77 100644 (file)
@@ -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],
         () => {
index 5edebe6722560383fbcf9808f32200a4d80e9049..551912f01e9158f6b83bb2db79aba956fccdb2cb 100644 (file)
@@ -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 {
index 75560ea80e140437648b138020361bd786ef940b..dd726758d63adb152d583ef89061de075636d9e0 100644 (file)
@@ -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);
index 027fd388914aed5ad27f8c9082ace7e76cad6c45..076cadf88769ba40ecfe108c876f45f24149e980 100644 (file)
@@ -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({