--- /dev/null
+/**
+ * An abstract action, to handle user actions.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Acp/Ui/User/Action
+ * @since 5.5
+ */
+
+export abstract class AbstractUserAction {
+ protected readonly button: HTMLElement;
+ protected readonly userDataElement: HTMLElement;
+ protected readonly userId: number;
+
+ public constructor(button: HTMLElement, userId: number, userDataElement: HTMLElement) {
+ this.button = button;
+ this.userId = userId;
+ this.userDataElement = userDataElement;
+ }
+}
+
+export default AbstractUserAction;
+++ /dev/null
-/**
- * @author Joshua Ruesweg
- * @copyright 2001-2021 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Acp/Ui/User/Action
- * @since 5.5
- */
-
-export abstract class AbstractUserAction {
- protected readonly button: HTMLElement;
- protected readonly userDataElement: HTMLElement;
- protected readonly userId: number;
-
- public constructor(button: HTMLElement, userId: number, userDataElement: HTMLElement) {
- this.button = button;
- this.userId = userId;
- this.userDataElement = userDataElement;
-
- this.init();
- }
-
- protected abstract init(): void;
-}
-
-export default AbstractUserAction;
/**
+ * Handles a user ban button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
import * as Core from "../../../../Core";
-import AbstractUserAction from "./AbstractUserAction";
+import AbstractUserAction from "./Abstract";
import BanHandler from "./Handler/Ban";
import * as UiNotification from "../../../../Ui/Notification";
import * as EventHandler from "../../../../Event/Handler";
export class BanAction extends AbstractUserAction {
private banHandler: BanHandler;
- protected init(): void {
+ public constructor(button: HTMLElement, userId: number, userDataElement: HTMLElement) {
+ super(button, userId, userDataElement);
+
this.banHandler = new BanHandler([this.userId]);
this.button.addEventListener("click", (event) => {
/**
+ * Handles a user delete button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 5.5
*/
-import AbstractUserAction from "./AbstractUserAction";
+import AbstractUserAction from "./Abstract";
import Delete from "./Handler/Delete";
export class DeleteAction extends AbstractUserAction {
- protected init(): void {
+ public constructor(button: HTMLElement, userId: number, userDataElement: HTMLElement) {
+ super(button, userId, userDataElement);
+
+ if (typeof this.button.dataset.confirmMessage !== "string") {
+ throw new Error("The button does not provide a confirmMessage.");
+ }
+
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],
() => {
this.userDataElement.remove();
},
- this.button.dataset.confirmMessage,
+ this.button.dataset.confirmMessage!,
);
deleteHandler.delete();
});
/**
+ * Handles a user disable/enable button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
import * as Core from "../../../../Core";
import { AjaxCallbackObject, AjaxCallbackSetup, DatabaseObjectActionResponse } from "../../../../Ajax/Data";
import * as UiNotification from "../../../../Ui/Notification";
-import AbstractUserAction from "./AbstractUserAction";
+import AbstractUserAction from "./Abstract";
import * as EventHandler from "../../../../Event/Handler";
export class DisableAction extends AbstractUserAction implements AjaxCallbackObject {
- protected init(): void {
+ public constructor(button: HTMLElement, userId: number, userDataElement: HTMLElement) {
+ super(button, userId, userDataElement);
+
this.button.addEventListener("click", (event) => {
event.preventDefault();
const isEnabled = Core.stringToBool(this.userDataElement.dataset.enabled!);
/**
+ * Handles a user ban.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
*/
import * as Ajax from "../../../../../Ajax";
-import BanDialog from "./Dialog/Ban";
+import BanDialog from "./Ban/Dialog";
+
+type Callback = () => void;
export class BanHandler {
private userIDs: number[];
- private banCallback: () => void;
public constructor(userIDs: number[]) {
this.userIDs = userIDs;
}
- public ban(callback: () => void): void {
+ public ban(callback: Callback): void {
BanDialog.open(this.userIDs, callback);
}
- public unban(callback: () => void): void {
+ public unban(callback: Callback): void {
Ajax.api({
_ajaxSetup: () => {
return {
},
};
},
- _ajaxSuccess: callback,
+ _ajaxSuccess: () => callback(),
});
}
}
--- /dev/null
+/**
+ * Creates and handles the dialog to ban a user.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Ban
+ * @since 5.5
+ */
+
+import UiDialog from "../../../../../../Ui/Dialog";
+import { DialogCallbackSetup } from "../../../../../../Ui/Dialog/Data";
+import * as Language from "../../../../../../Language";
+import * as Ajax from "../../../../../../Ajax";
+import DatePicker from "../../../../../../Date/Picker";
+
+type Callback = () => void;
+
+export class BanDialog {
+ private static instance: BanDialog;
+
+ private banCallback: Callback;
+ private userIDs: number[];
+ private submitElement: HTMLElement;
+ private neverExpiresCheckbox: HTMLInputElement;
+ private reasonInput: HTMLInputElement;
+ private userBanExpiresSettingsElement: HTMLElement;
+ private dialogContent: HTMLElement;
+
+ public static open(userIDs: number[], callback: Callback): void {
+ if (!BanDialog.instance) {
+ BanDialog.instance = new BanDialog();
+ }
+
+ BanDialog.instance.setCallback(callback);
+ BanDialog.instance.setUserIDs(userIDs);
+ BanDialog.instance.openDialog();
+ }
+
+ private openDialog(): void {
+ UiDialog.open(this);
+ }
+
+ private setCallback(callback: Callback): void {
+ this.banCallback = callback;
+ }
+
+ private setUserIDs(userIDs: number[]): void {
+ this.userIDs = userIDs;
+ }
+
+ private banSubmit(reason: string, expires: string): void {
+ Ajax.apiOnce({
+ data: {
+ actionName: "ban",
+ className: "wcf\\data\\user\\UserAction",
+ objectIDs: this.userIDs,
+ parameters: {
+ banReason: reason,
+ banExpires: expires,
+ },
+ },
+ success: this.banCallback,
+ });
+ }
+
+ private cleanupDialog(): void {
+ this.reasonInput.value = "";
+ this.neverExpiresCheckbox.checked = true;
+ DatePicker.clear("userBanExpires");
+ this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
+ }
+
+ _dialogSetup(): ReturnType<DialogCallbackSetup> {
+ return {
+ id: "userBanHandler",
+ options: {
+ onSetup: (content: HTMLElement): void => {
+ this.dialogContent = content;
+ this.submitElement = content.querySelector(".formSubmitButton")! as HTMLElement;
+ this.reasonInput = content.querySelector("#userBanReason")! as HTMLInputElement;
+ this.neverExpiresCheckbox = content.querySelector("#userBanNeverExpires")! as HTMLInputElement;
+ this.userBanExpiresSettingsElement = content.querySelector("#userBanExpiresSettings")! as HTMLElement;
+
+ this.submitElement.addEventListener("click", (event) => {
+ event.preventDefault();
+
+ const expires = this.neverExpiresCheckbox.checked ? "" : DatePicker.getValue("userBanExpires");
+ this.banSubmit(this.reasonInput.value, expires);
+
+ UiDialog.close(this);
+
+ this.cleanupDialog();
+ });
+
+ this.neverExpiresCheckbox.addEventListener("change", (event) => {
+ const checkbox = event.currentTarget as HTMLInputElement;
+ if (checkbox.checked) {
+ this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
+ } else {
+ this.userBanExpiresSettingsElement.style.removeProperty("display");
+ }
+ });
+ },
+ title: Language.get("wcf.acp.user.ban.sure"),
+ },
+ source: `
+ <div class="section">
+ <dl>
+ <dt><label for="userBanReason">${Language.get("wcf.acp.user.banReason")}</label></dt>
+ <dd>
+ <textarea id="userBanReason" cols="40" rows="3" class=""></textarea>
+ <small>${Language.get("wcf.acp.user.banReason.description")}</small>
+ </dd>
+ </dl>
+ <dl>
+ <dt></dt>
+ <dd>
+ <label for="userBanNeverExpires">
+ <input type="checkbox" name="userBanNeverExpires" id="userBanNeverExpires" checked="">
+ ${Language.get("wcf.acp.user.ban.neverExpires")}
+ </label>
+ </dd>
+ </dl>
+ <dl id="userBanExpiresSettings" style="display: none;">
+ <dt>
+ <label for="userBanExpires">${Language.get("wcf.acp.user.ban.expires")}</label>
+ </dt>
+ <dd>
+ <div class="inputAddon">
+ <input type="date"
+ name="userBanExpires"
+ id="userBanExpires"
+ class="medium"
+ min="${new Date(window.TIME_NOW * 1000).toISOString()}"
+ data-ignore-timezone="true"
+ />
+ </div>
+ <small>${Language.get("wcf.acp.user.ban.expires.description")}</small>
+ </dd>
+ </dl>
+ </div>
+ <div class="formSubmit dialogFormSubmit">
+ <button class="buttonPrimary formSubmitButton" accesskey="s">${Language.get("wcf.global.button.submit")}</button>
+ </div>`,
+ };
+ }
+}
+
+export default BanDialog;
/**
+ * Deletes a given user.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+++ /dev/null
-/**
- * @author Joshua Ruesweg
- * @copyright 2001-2021 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Dialog
- * @since 5.5
- */
-
-import UiDialog from "../../../../../../Ui/Dialog";
-import { DialogCallbackSetup } from "../../../../../../Ui/Dialog/Data";
-import * as Language from "../../../../../../Language";
-import * as Ajax from "../../../../../../Ajax";
-import DatePicker from "../../../../../../Date/Picker";
-
-export class BanDialog {
- private static instance: BanDialog;
-
- private banCallback: () => void;
- private userIDs: number[];
- private submitElement: HTMLElement;
- private neverExpiresCheckbox: HTMLInputElement;
- private reasonInput: HTMLInputElement;
- private userBanExpiresSettingsElement: HTMLElement;
- private dialogContent: HTMLElement;
- public static open(userIDs: number[], callback: () => void): void {
- if (!BanDialog.instance) {
- BanDialog.instance = new BanDialog();
- }
-
- BanDialog.instance.setCallback(callback);
- BanDialog.instance.setUserIDs(userIDs);
- BanDialog.instance.openDialog();
- }
-
- private openDialog(): void {
- UiDialog.open(this);
- }
-
- private setCallback(callback: () => void): void {
- this.banCallback = callback;
- }
-
- private setUserIDs(userIDs: number[]) {
- this.userIDs = userIDs;
- }
-
- private banSubmit(reason: string, expires: string): void {
- Ajax.apiOnce({
- data: {
- actionName: "ban",
- className: "wcf\\data\\user\\UserAction",
- objectIDs: this.userIDs,
- parameters: {
- banReason: reason,
- banExpires: expires,
- },
- },
- success: this.banCallback,
- });
- }
-
- private cleanupDialog(): void {
- this.reasonInput.value = "";
- this.neverExpiresCheckbox.checked = true;
- DatePicker.clear("userBanExpires");
- this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
- }
-
- _dialogSetup(): ReturnType<DialogCallbackSetup> {
- return {
- id: "userBanHandler",
- options: {
- onSetup: (content: HTMLElement): void => {
- this.dialogContent = content;
- this.submitElement = content.querySelector(".formSubmitButton")! as HTMLElement;
- this.reasonInput = content.querySelector("#userBanReason")! as HTMLInputElement;
- this.neverExpiresCheckbox = content.querySelector("#userBanNeverExpires")! as HTMLInputElement;
- this.userBanExpiresSettingsElement = content.querySelector("#userBanExpiresSettings")! as HTMLElement;
-
- this.submitElement.addEventListener("click", (event) => {
- event.preventDefault();
-
- const expires = this.neverExpiresCheckbox.checked ? "" : DatePicker.getValue("userBanExpires");
- this.banSubmit(this.reasonInput.value, expires);
-
- UiDialog.close(this);
-
- this.cleanupDialog();
- });
-
- this.neverExpiresCheckbox.addEventListener("change", (event) => {
- const checkbox = event.currentTarget as HTMLInputElement;
- if (checkbox.checked) {
- this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
- } else {
- this.userBanExpiresSettingsElement.style.removeProperty("display");
- }
- });
- },
- title: Language.get("wcf.acp.user.ban.sure"),
- },
- source: `
-<div class="section">
- <dl>
- <dt><label for="userBanReason">${Language.get("wcf.acp.user.banReason")}</label></dt>
- <dd>
- <textarea id="userBanReason" cols="40" rows="3" class=""></textarea>
- <small>${Language.get("wcf.acp.user.banReason.description")}</small>
- </dd>
- </dl>
- <dl>
- <dt></dt>
- <dd>
- <label for="userBanNeverExpires">
- <input type="checkbox" name="userBanNeverExpires" id="userBanNeverExpires" checked="">
- ${Language.get("wcf.acp.user.ban.neverExpires")}
- </label>
- </dd>
- </dl>
- <dl id="userBanExpiresSettings" style="display: none;">
- <dt>
- <label for="userBanExpires">${Language.get("wcf.acp.user.ban.expires")}</label>
- </dt>
- <dd>
- <div class="inputAddon">
- <input type="date"
- name="userBanExpires"
- id="userBanExpires"
- class="medium"
- min="${new Date(window.TIME_NOW * 1000).toISOString()}"
- data-ignore-timezone="true"
- />
- </div>
- <small>${Language.get("wcf.acp.user.ban.expires.description")}</small>
- </dd>
- </dl>
-</div>
-<div class="formSubmit dialogFormSubmit">
- <button class="buttonPrimary formSubmitButton" accesskey="s">${Language.get("wcf.global.button.submit")}</button>
-</div>`,
- };
- }
-}
-
-export default BanDialog;
/**
+ * Handles a send new password action.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
/**
+ * Handles a send new password button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 5.5
*/
-import AbstractUserAction from "./AbstractUserAction";
+import AbstractUserAction from "./Abstract";
import SendNewPassword from "./Handler/SendNewPassword";
export class SendNewPasswordAction extends AbstractUserAction {
- protected init(): void {
+ public constructor(button: HTMLElement, userId: number, userDataElement: HTMLElement) {
+ super(button, userId, userDataElement);
+
this.button.addEventListener("click", (event) => {
event.preventDefault();
/**
+ * Handles a toggle confirm email button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 5.5
*/
-import AbstractUserAction from "./AbstractUserAction";
+import AbstractUserAction from "./Abstract";
import * as Ajax from "../../../../Ajax";
import * as Core from "../../../../Core";
import { AjaxCallbackSetup, DatabaseObjectActionResponse } from "../../../../Ajax/Data";
import * as UiNotification from "../../../../Ui/Notification";
export class ToggleConfirmEmailAction extends AbstractUserAction {
- protected init(): void {
+ public constructor(button: HTMLElement, userId: number, userDataElement: HTMLElement) {
+ super(button, userId, userDataElement);
+
this.button.addEventListener("click", (event) => {
event.preventDefault();
const isEmailConfirmed = Core.stringToBool(this.userDataElement.dataset.emailConfirmed!);
Ajax.api(this, {
- actionName: (isEmailConfirmed ? "un" : "") + "confirmEmail",
+ actionName: isEmailConfirmed ? "unconfirmEmail" : "confirmEmail",
});
});
}
class AcpUserContentRemoveHandler {
private readonly dialogId: string;
private readonly userId: number;
- private readonly callbackSuccess: CallbackSuccess | null | undefined;
+ private readonly callbackSuccess?: CallbackSuccess;
/**
* Initializes the content remove handler.
*/
- constructor(element: HTMLElement, userId: number, callbackSuccess?: CallbackSuccess | null) {
+ constructor(element: HTMLElement, userId: number, callbackSuccess?: CallbackSuccess) {
this.userId = userId;
this.dialogId = `userRemoveContentHandler-${this.userId}`;
this.callbackSuccess = callbackSuccess;
});
}
- const deleteContent = dropdownMenu.querySelector(".jsDeleteContent") as HTMLAnchorElement;
+ const deleteContent = dropdownMenu.querySelector(".jsDeleteContent");
if (deleteContent !== null) {
- new AcpUserContentRemoveHandler(deleteContent, userId);
+ new AcpUserContentRemoveHandler(deleteContent as HTMLAnchorElement, userId);
}
- const sendNewPassword = dropdownMenu.querySelector(".jsSendNewPassword") as HTMLAnchorElement;
+ const sendNewPassword = dropdownMenu.querySelector(".jsSendNewPassword");
if (sendNewPassword !== null) {
- new SendNewPasswordAction(sendNewPassword, userId, userRow);
+ new SendNewPasswordAction(sendNewPassword as HTMLAnchorElement, userId, userRow);
}
- const toggleConfirmEmail = dropdownMenu.querySelector(".jsConfirmEmailToggle") as HTMLAnchorElement;
+ const toggleConfirmEmail = dropdownMenu.querySelector(".jsConfirmEmailToggle");
if (toggleConfirmEmail !== null) {
- new ToggleConfirmEmailAction(toggleConfirmEmail, userId, userRow);
+ new ToggleConfirmEmailAction(toggleConfirmEmail as HTMLAnchorElement, userId, userRow);
}
- const enableUser = dropdownMenu.querySelector(".jsEnable") as HTMLAnchorElement;
+ const enableUser = dropdownMenu.querySelector(".jsEnable");
if (enableUser !== null) {
- new DisableAction(enableUser, userId, userRow);
+ new DisableAction(enableUser as HTMLAnchorElement, userId, userRow);
}
- const banUser = dropdownMenu.querySelector(".jsBan") as HTMLAnchorElement;
+ const banUser = dropdownMenu.querySelector(".jsBan");
if (banUser !== null) {
- new BanAction(banUser, userId, userRow);
+ new BanAction(banUser as HTMLAnchorElement, userId, userRow);
}
- const deleteUser = dropdownMenu.querySelector(".jsDelete") as HTMLAnchorElement;
+ const deleteUser = dropdownMenu.querySelector(".jsDelete");
if (deleteUser !== null) {
- new DeleteAction(deleteUser, userId, userRow);
+ new DeleteAction(deleteUser as HTMLAnchorElement, userId, userRow);
}
}
--- /dev/null
+/**
+ * An abstract action, to handle user actions.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Acp/Ui/User/Action
+ * @since 5.5
+ */
+define(["require", "exports"], function (require, exports) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.AbstractUserAction = void 0;
+ class AbstractUserAction {
+ constructor(button, userId, userDataElement) {
+ this.button = button;
+ this.userId = userId;
+ this.userDataElement = userDataElement;
+ }
+ }
+ exports.AbstractUserAction = AbstractUserAction;
+ exports.default = AbstractUserAction;
+});
/**
+ * Handles a user ban button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Acp/Ui/User/Action
* @since 5.5
*/
-define(["require", "exports", "tslib", "../../../../Core", "./AbstractUserAction", "./Handler/Ban", "../../../../Ui/Notification", "../../../../Event/Handler"], function (require, exports, tslib_1, Core, AbstractUserAction_1, Ban_1, UiNotification, EventHandler) {
+define(["require", "exports", "tslib", "../../../../Core", "./Abstract", "./Handler/Ban", "../../../../Ui/Notification", "../../../../Event/Handler"], function (require, exports, tslib_1, Core, Abstract_1, Ban_1, UiNotification, EventHandler) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BanAction = void 0;
Core = tslib_1.__importStar(Core);
- AbstractUserAction_1 = tslib_1.__importDefault(AbstractUserAction_1);
+ Abstract_1 = tslib_1.__importDefault(Abstract_1);
Ban_1 = tslib_1.__importDefault(Ban_1);
UiNotification = tslib_1.__importStar(UiNotification);
EventHandler = tslib_1.__importStar(EventHandler);
- class BanAction extends AbstractUserAction_1.default {
- init() {
+ class BanAction extends Abstract_1.default {
+ constructor(button, userId, userDataElement) {
+ super(button, userId, userDataElement);
this.banHandler = new Ban_1.default([this.userId]);
this.button.addEventListener("click", (event) => {
event.preventDefault();
/**
+ * Handles a user delete button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Acp/Ui/User/Action
* @since 5.5
*/
-define(["require", "exports", "tslib", "./AbstractUserAction", "./Handler/Delete"], function (require, exports, tslib_1, AbstractUserAction_1, Delete_1) {
+define(["require", "exports", "tslib", "./Abstract", "./Handler/Delete"], function (require, exports, tslib_1, Abstract_1, Delete_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteAction = void 0;
- AbstractUserAction_1 = tslib_1.__importDefault(AbstractUserAction_1);
+ Abstract_1 = tslib_1.__importDefault(Abstract_1);
Delete_1 = tslib_1.__importDefault(Delete_1);
- class DeleteAction extends AbstractUserAction_1.default {
- init() {
+ class DeleteAction extends Abstract_1.default {
+ constructor(button, userId, userDataElement) {
+ super(button, userId, userDataElement);
+ if (typeof this.button.dataset.confirmMessage !== "string") {
+ throw new Error("The button does not provide a confirmMessage.");
+ }
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);
/**
+ * Handles a user disable/enable button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Acp/Ui/User/Action
* @since 5.5
*/
-define(["require", "exports", "tslib", "../../../../Ajax", "../../../../Core", "../../../../Ui/Notification", "./AbstractUserAction", "../../../../Event/Handler"], function (require, exports, tslib_1, Ajax, Core, UiNotification, AbstractUserAction_1, EventHandler) {
+define(["require", "exports", "tslib", "../../../../Ajax", "../../../../Core", "../../../../Ui/Notification", "./Abstract", "../../../../Event/Handler"], function (require, exports, tslib_1, Ajax, Core, UiNotification, Abstract_1, EventHandler) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DisableAction = void 0;
Ajax = tslib_1.__importStar(Ajax);
Core = tslib_1.__importStar(Core);
UiNotification = tslib_1.__importStar(UiNotification);
- AbstractUserAction_1 = tslib_1.__importDefault(AbstractUserAction_1);
+ Abstract_1 = tslib_1.__importDefault(Abstract_1);
EventHandler = tslib_1.__importStar(EventHandler);
- class DisableAction extends AbstractUserAction_1.default {
- init() {
+ class DisableAction extends Abstract_1.default {
+ constructor(button, userId, userDataElement) {
+ super(button, userId, userDataElement);
this.button.addEventListener("click", (event) => {
event.preventDefault();
const isEnabled = Core.stringToBool(this.userDataElement.dataset.enabled);
/**
+ * Handles a user ban.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler
* @since 5.5
*/
-define(["require", "exports", "tslib", "../../../../../Ajax", "./Dialog/Ban"], function (require, exports, tslib_1, Ajax, Ban_1) {
+define(["require", "exports", "tslib", "../../../../../Ajax", "./Ban/Dialog"], function (require, exports, tslib_1, Ajax, Dialog_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BanHandler = void 0;
Ajax = tslib_1.__importStar(Ajax);
- Ban_1 = tslib_1.__importDefault(Ban_1);
+ Dialog_1 = tslib_1.__importDefault(Dialog_1);
class BanHandler {
constructor(userIDs) {
this.userIDs = userIDs;
}
ban(callback) {
- Ban_1.default.open(this.userIDs, callback);
+ Dialog_1.default.open(this.userIDs, callback);
}
unban(callback) {
Ajax.api({
},
};
},
- _ajaxSuccess: callback,
+ _ajaxSuccess: () => callback(),
});
}
}
--- /dev/null
+/**
+ * Creates and handles the dialog to ban a user.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Ban
+ * @since 5.5
+ */
+define(["require", "exports", "tslib", "../../../../../../Ui/Dialog", "../../../../../../Language", "../../../../../../Ajax", "../../../../../../Date/Picker"], function (require, exports, tslib_1, Dialog_1, Language, Ajax, Picker_1) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.BanDialog = void 0;
+ Dialog_1 = tslib_1.__importDefault(Dialog_1);
+ Language = tslib_1.__importStar(Language);
+ Ajax = tslib_1.__importStar(Ajax);
+ Picker_1 = tslib_1.__importDefault(Picker_1);
+ class BanDialog {
+ static open(userIDs, callback) {
+ if (!BanDialog.instance) {
+ BanDialog.instance = new BanDialog();
+ }
+ BanDialog.instance.setCallback(callback);
+ BanDialog.instance.setUserIDs(userIDs);
+ BanDialog.instance.openDialog();
+ }
+ openDialog() {
+ Dialog_1.default.open(this);
+ }
+ setCallback(callback) {
+ this.banCallback = callback;
+ }
+ setUserIDs(userIDs) {
+ this.userIDs = userIDs;
+ }
+ banSubmit(reason, expires) {
+ Ajax.apiOnce({
+ data: {
+ actionName: "ban",
+ className: "wcf\\data\\user\\UserAction",
+ objectIDs: this.userIDs,
+ parameters: {
+ banReason: reason,
+ banExpires: expires,
+ },
+ },
+ success: this.banCallback,
+ });
+ }
+ cleanupDialog() {
+ this.reasonInput.value = "";
+ this.neverExpiresCheckbox.checked = true;
+ Picker_1.default.clear("userBanExpires");
+ this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
+ }
+ _dialogSetup() {
+ return {
+ id: "userBanHandler",
+ options: {
+ onSetup: (content) => {
+ this.dialogContent = content;
+ this.submitElement = content.querySelector(".formSubmitButton");
+ this.reasonInput = content.querySelector("#userBanReason");
+ this.neverExpiresCheckbox = content.querySelector("#userBanNeverExpires");
+ this.userBanExpiresSettingsElement = content.querySelector("#userBanExpiresSettings");
+ this.submitElement.addEventListener("click", (event) => {
+ event.preventDefault();
+ const expires = this.neverExpiresCheckbox.checked ? "" : Picker_1.default.getValue("userBanExpires");
+ this.banSubmit(this.reasonInput.value, expires);
+ Dialog_1.default.close(this);
+ this.cleanupDialog();
+ });
+ this.neverExpiresCheckbox.addEventListener("change", (event) => {
+ const checkbox = event.currentTarget;
+ if (checkbox.checked) {
+ this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
+ }
+ else {
+ this.userBanExpiresSettingsElement.style.removeProperty("display");
+ }
+ });
+ },
+ title: Language.get("wcf.acp.user.ban.sure"),
+ },
+ source: `
+ <div class="section">
+ <dl>
+ <dt><label for="userBanReason">${Language.get("wcf.acp.user.banReason")}</label></dt>
+ <dd>
+ <textarea id="userBanReason" cols="40" rows="3" class=""></textarea>
+ <small>${Language.get("wcf.acp.user.banReason.description")}</small>
+ </dd>
+ </dl>
+ <dl>
+ <dt></dt>
+ <dd>
+ <label for="userBanNeverExpires">
+ <input type="checkbox" name="userBanNeverExpires" id="userBanNeverExpires" checked="">
+ ${Language.get("wcf.acp.user.ban.neverExpires")}
+ </label>
+ </dd>
+ </dl>
+ <dl id="userBanExpiresSettings" style="display: none;">
+ <dt>
+ <label for="userBanExpires">${Language.get("wcf.acp.user.ban.expires")}</label>
+ </dt>
+ <dd>
+ <div class="inputAddon">
+ <input type="date"
+ name="userBanExpires"
+ id="userBanExpires"
+ class="medium"
+ min="${new Date(window.TIME_NOW * 1000).toISOString()}"
+ data-ignore-timezone="true"
+ />
+ </div>
+ <small>${Language.get("wcf.acp.user.ban.expires.description")}</small>
+ </dd>
+ </dl>
+ </div>
+ <div class="formSubmit dialogFormSubmit">
+ <button class="buttonPrimary formSubmitButton" accesskey="s">${Language.get("wcf.global.button.submit")}</button>
+ </div>`,
+ };
+ }
+ }
+ exports.BanDialog = BanDialog;
+ exports.default = BanDialog;
+});
/**
+ * Deletes a given user.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+++ /dev/null
-/**
- * @author Joshua Ruesweg
- * @copyright 2001-2021 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler/Dialog
- * @since 5.5
- */
-define(["require", "exports", "tslib", "../../../../../../Ui/Dialog", "../../../../../../Language", "../../../../../../Ajax", "../../../../../../Date/Picker"], function (require, exports, tslib_1, Dialog_1, Language, Ajax, Picker_1) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.BanDialog = void 0;
- Dialog_1 = tslib_1.__importDefault(Dialog_1);
- Language = tslib_1.__importStar(Language);
- Ajax = tslib_1.__importStar(Ajax);
- Picker_1 = tslib_1.__importDefault(Picker_1);
- class BanDialog {
- static open(userIDs, callback) {
- if (!BanDialog.instance) {
- BanDialog.instance = new BanDialog();
- }
- BanDialog.instance.setCallback(callback);
- BanDialog.instance.setUserIDs(userIDs);
- BanDialog.instance.openDialog();
- }
- openDialog() {
- Dialog_1.default.open(this);
- }
- setCallback(callback) {
- this.banCallback = callback;
- }
- setUserIDs(userIDs) {
- this.userIDs = userIDs;
- }
- banSubmit(reason, expires) {
- Ajax.apiOnce({
- data: {
- actionName: "ban",
- className: "wcf\\data\\user\\UserAction",
- objectIDs: this.userIDs,
- parameters: {
- banReason: reason,
- banExpires: expires,
- },
- },
- success: this.banCallback,
- });
- }
- cleanupDialog() {
- this.reasonInput.value = "";
- this.neverExpiresCheckbox.checked = true;
- Picker_1.default.clear("userBanExpires");
- this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
- }
- _dialogSetup() {
- return {
- id: "userBanHandler",
- options: {
- onSetup: (content) => {
- this.dialogContent = content;
- this.submitElement = content.querySelector(".formSubmitButton");
- this.reasonInput = content.querySelector("#userBanReason");
- this.neverExpiresCheckbox = content.querySelector("#userBanNeverExpires");
- this.userBanExpiresSettingsElement = content.querySelector("#userBanExpiresSettings");
- this.submitElement.addEventListener("click", (event) => {
- event.preventDefault();
- const expires = this.neverExpiresCheckbox.checked ? "" : Picker_1.default.getValue("userBanExpires");
- this.banSubmit(this.reasonInput.value, expires);
- Dialog_1.default.close(this);
- this.cleanupDialog();
- });
- this.neverExpiresCheckbox.addEventListener("change", (event) => {
- const checkbox = event.currentTarget;
- if (checkbox.checked) {
- this.userBanExpiresSettingsElement.style.setProperty("display", "none", "");
- }
- else {
- this.userBanExpiresSettingsElement.style.removeProperty("display");
- }
- });
- },
- title: Language.get("wcf.acp.user.ban.sure"),
- },
- source: `
-<div class="section">
- <dl>
- <dt><label for="userBanReason">${Language.get("wcf.acp.user.banReason")}</label></dt>
- <dd>
- <textarea id="userBanReason" cols="40" rows="3" class=""></textarea>
- <small>${Language.get("wcf.acp.user.banReason.description")}</small>
- </dd>
- </dl>
- <dl>
- <dt></dt>
- <dd>
- <label for="userBanNeverExpires">
- <input type="checkbox" name="userBanNeverExpires" id="userBanNeverExpires" checked="">
- ${Language.get("wcf.acp.user.ban.neverExpires")}
- </label>
- </dd>
- </dl>
- <dl id="userBanExpiresSettings" style="display: none;">
- <dt>
- <label for="userBanExpires">${Language.get("wcf.acp.user.ban.expires")}</label>
- </dt>
- <dd>
- <div class="inputAddon">
- <input type="date"
- name="userBanExpires"
- id="userBanExpires"
- class="medium"
- min="${new Date(window.TIME_NOW * 1000).toISOString()}"
- data-ignore-timezone="true"
- />
- </div>
- <small>${Language.get("wcf.acp.user.ban.expires.description")}</small>
- </dd>
- </dl>
-</div>
-<div class="formSubmit dialogFormSubmit">
- <button class="buttonPrimary formSubmitButton" accesskey="s">${Language.get("wcf.global.button.submit")}</button>
-</div>`,
- };
- }
- }
- exports.BanDialog = BanDialog;
- exports.default = BanDialog;
-});
/**
+ * Handles a send new password action.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
/**
+ * Handles a send new password button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Acp/Ui/User/Action
* @since 5.5
*/
-define(["require", "exports", "tslib", "./AbstractUserAction", "./Handler/SendNewPassword"], function (require, exports, tslib_1, AbstractUserAction_1, SendNewPassword_1) {
+define(["require", "exports", "tslib", "./Abstract", "./Handler/SendNewPassword"], function (require, exports, tslib_1, Abstract_1, SendNewPassword_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SendNewPasswordAction = void 0;
- AbstractUserAction_1 = tslib_1.__importDefault(AbstractUserAction_1);
+ Abstract_1 = tslib_1.__importDefault(Abstract_1);
SendNewPassword_1 = tslib_1.__importDefault(SendNewPassword_1);
- class SendNewPasswordAction extends AbstractUserAction_1.default {
- init() {
+ class SendNewPasswordAction extends Abstract_1.default {
+ constructor(button, userId, userDataElement) {
+ super(button, userId, userDataElement);
this.button.addEventListener("click", (event) => {
event.preventDefault();
const sendNewPasswordHandler = new SendNewPassword_1.default([this.userId], () => {
/**
+ * Handles a toggle confirm email button.
+ *
* @author Joshua Ruesweg
* @copyright 2001-2021 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Acp/Ui/User/Action
* @since 5.5
*/
-define(["require", "exports", "tslib", "./AbstractUserAction", "../../../../Ajax", "../../../../Core", "../../../../Ui/Notification"], function (require, exports, tslib_1, AbstractUserAction_1, Ajax, Core, UiNotification) {
+define(["require", "exports", "tslib", "./Abstract", "../../../../Ajax", "../../../../Core", "../../../../Ui/Notification"], function (require, exports, tslib_1, Abstract_1, Ajax, Core, UiNotification) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleConfirmEmailAction = void 0;
- AbstractUserAction_1 = tslib_1.__importDefault(AbstractUserAction_1);
+ Abstract_1 = tslib_1.__importDefault(Abstract_1);
Ajax = tslib_1.__importStar(Ajax);
Core = tslib_1.__importStar(Core);
UiNotification = tslib_1.__importStar(UiNotification);
- class ToggleConfirmEmailAction extends AbstractUserAction_1.default {
- init() {
+ class ToggleConfirmEmailAction extends Abstract_1.default {
+ constructor(button, userId, userDataElement) {
+ super(button, userId, userDataElement);
this.button.addEventListener("click", (event) => {
event.preventDefault();
const isEmailConfirmed = Core.stringToBool(this.userDataElement.dataset.emailConfirmed);
Ajax.api(this, {
- actionName: (isEmailConfirmed ? "un" : "") + "confirmEmail",
+ actionName: isEmailConfirmed ? "unconfirmEmail" : "confirmEmail",
});
});
}