From: joshuaruesweg Date: Fri, 18 Jun 2021 11:43:55 +0000 (+0200) Subject: Add independent SendNewPassword handler X-Git-Tag: 5.5.0_Alpha_1~479^2~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bda8f79e7f83c65ca946231d146979dea948d44b;p=GitHub%2FWoltLab%2FWCF.git Add independent SendNewPassword handler --- diff --git a/ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/SendNewPassword.ts b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/SendNewPassword.ts new file mode 100644 index 0000000000..4dc42b2901 --- /dev/null +++ b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/SendNewPassword.ts @@ -0,0 +1,49 @@ +import * as Language from "../../../../../Language"; +import * as UiConfirmation from "../../../../../Ui/Confirmation"; +import AcpUiWorker from "../../../Worker"; + +interface AjaxResponse { + loopCount: number; + parameters: ArbitraryObject; + proceedURL: string; + progress: number; + template?: string; +} + +type CallbackSuccess = (data: AjaxResponse) => void; + +/** + * @author Joshua Ruesweg + * @copyright 2001-2021 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler + * @since 5.5 + */ +export class SendNewPassword { + private userIDs: number[]; + private successCallback: CallbackSuccess | null; + + public constructor(userIDs: number[], successCallback: CallbackSuccess | null) { + this.userIDs = userIDs; + this.successCallback = successCallback; + } + + send(): void { + UiConfirmation.show({ + confirm: () => { + new AcpUiWorker({ + dialogId: "sendingNewPasswords", + dialogTitle: Language.get("wcf.acp.user.sendNewPassword.workerTitle"), + className: "wcf\\system\\worker\\SendNewPasswordWorker", + parameters: { + userIDs: this.userIDs, + }, + callbackSuccess: this.successCallback, + }); + }, + message: Language.get("wcf.acp.user.action.sendNewPassword.confirmMessage"), + }); + } +} + +export default SendNewPassword; diff --git a/ts/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.ts b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.ts index 53d2555e25..9bfde2d239 100644 --- a/ts/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.ts +++ b/ts/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.ts @@ -1,6 +1,5 @@ -import * as EventHandler from "../../../../Event/Handler"; -import * as Language from "../../../../Language"; import AbstractUserAction from "./AbstractUserAction"; +import SendNewPassword from "./Handler/SendNewPassword"; /** * @author Joshua Ruesweg @@ -14,20 +13,10 @@ export class SendNewPasswordAction extends AbstractUserAction { this.button.addEventListener("click", (event) => { event.preventDefault(); - // emulate clipboard selection - EventHandler.fire("com.woltlab.wcf.clipboard", "com.woltlab.wcf.user", { - data: { - actionName: "com.woltlab.wcf.user.sendNewPassword", - parameters: { - confirmMessage: Language.get("wcf.acp.user.action.sendNewPassword.confirmMessage"), - objectIDs: [this.userId], - }, - }, - responseData: { - actionName: "com.woltlab.wcf.user.sendNewPassword", - objectIDs: [this.userId], - }, + const sendNewPasswordHandler = new SendNewPassword([this.userId], () => { + location.reload(); }); + sendNewPasswordHandler.send(); }); } } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/SendNewPassword.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/SendNewPassword.js new file mode 100644 index 0000000000..b0ad9ab9cf --- /dev/null +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/Handler/SendNewPassword.js @@ -0,0 +1,39 @@ +define(["require", "exports", "tslib", "../../../../../Language", "../../../../../Ui/Confirmation", "../../../Worker"], function (require, exports, tslib_1, Language, UiConfirmation, Worker_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.SendNewPassword = void 0; + Language = tslib_1.__importStar(Language); + UiConfirmation = tslib_1.__importStar(UiConfirmation); + Worker_1 = tslib_1.__importDefault(Worker_1); + /** + * @author Joshua Ruesweg + * @copyright 2001-2021 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Acp/Ui/User/Action/Handler + * @since 5.5 + */ + class SendNewPassword { + constructor(userIDs, successCallback) { + this.userIDs = userIDs; + this.successCallback = successCallback; + } + send() { + UiConfirmation.show({ + confirm: () => { + new Worker_1.default({ + dialogId: "sendingNewPasswords", + dialogTitle: Language.get("wcf.acp.user.sendNewPassword.workerTitle"), + className: "wcf\\system\\worker\\SendNewPasswordWorker", + parameters: { + userIDs: this.userIDs, + }, + callbackSuccess: this.successCallback, + }); + }, + message: Language.get("wcf.acp.user.action.sendNewPassword.confirmMessage"), + }); + } + } + exports.SendNewPassword = SendNewPassword; + exports.default = SendNewPassword; +}); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.js index 2714c94180..020425e13c 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/User/Action/SendNewPasswordAction.js @@ -1,10 +1,9 @@ -define(["require", "exports", "tslib", "../../../../Event/Handler", "../../../../Language", "./AbstractUserAction"], function (require, exports, tslib_1, EventHandler, Language, AbstractUserAction_1) { +define(["require", "exports", "tslib", "./AbstractUserAction", "./Handler/SendNewPassword"], function (require, exports, tslib_1, AbstractUserAction_1, SendNewPassword_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SendNewPasswordAction = void 0; - EventHandler = tslib_1.__importStar(EventHandler); - Language = tslib_1.__importStar(Language); AbstractUserAction_1 = tslib_1.__importDefault(AbstractUserAction_1); + SendNewPassword_1 = tslib_1.__importDefault(SendNewPassword_1); /** * @author Joshua Ruesweg * @copyright 2001-2021 WoltLab GmbH @@ -16,20 +15,10 @@ define(["require", "exports", "tslib", "../../../../Event/Handler", "../../../.. init() { this.button.addEventListener("click", (event) => { event.preventDefault(); - // emulate clipboard selection - EventHandler.fire("com.woltlab.wcf.clipboard", "com.woltlab.wcf.user", { - data: { - actionName: "com.woltlab.wcf.user.sendNewPassword", - parameters: { - confirmMessage: Language.get("wcf.acp.user.action.sendNewPassword.confirmMessage"), - objectIDs: [this.userId], - }, - }, - responseData: { - actionName: "com.woltlab.wcf.user.sendNewPassword", - objectIDs: [this.userId], - }, + const sendNewPasswordHandler = new SendNewPassword_1.default([this.userId], () => { + location.reload(); }); + sendNewPasswordHandler.send(); }); } }