From: Matthias Schmidt Date: Fri, 7 May 2021 07:25:08 +0000 (+0200) Subject: Use ignore dialog for list of ignored users (#4199) X-Git-Tag: 5.4.0_Alpha_2~42 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=08a89f3e023abcaf02a097b18c3c7fbc13d43b16;p=GitHub%2FWoltLab%2FWCF.git Use ignore dialog for list of ignored users (#4199) Close #4140 --- diff --git a/com.woltlab.wcf/templates/ignoredUsers.tpl b/com.woltlab.wcf/templates/ignoredUsers.tpl index 4a37a19cb6..fe10da0483 100644 --- a/com.woltlab.wcf/templates/ignoredUsers.tpl +++ b/com.woltlab.wcf/templates/ignoredUsers.tpl @@ -12,9 +12,9 @@ {if $objects|count}
-
    +
      {foreach from=$objects item=user} -
    1. +
    2. {user object=$user type='avatar48' ariaHidden='true' tabindex='-1'} @@ -23,7 +23,12 @@ @@ -53,6 +58,16 @@ {/hascontent} + + {else}

      {lang}wcf.user.ignoredUsers.noUsers{/lang}

      {/if} diff --git a/ts/WoltLabSuite/Core/Ui/User/Ignore/List.ts b/ts/WoltLabSuite/Core/Ui/User/Ignore/List.ts new file mode 100644 index 0000000000..23a35c3d01 --- /dev/null +++ b/ts/WoltLabSuite/Core/Ui/User/Ignore/List.ts @@ -0,0 +1,57 @@ +/** + * Shows the ignore dialogs when editing users on the page listing ignored users. + * + * @author Matthias Schmidt + * @copyright 2001-2021 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Ui/User/Ignore/List + */ + +import FormBuilderDialog from "../../../Form/Builder/Dialog"; +import * as Language from "../../../Language"; +import * as UiNotification from "../../Notification"; + +interface AjaxResponse { + isIgnoredUser: 0 | 1; +} + +export class UiUserIgnoreList { + protected dialogs = new Map(); + + constructor() { + document + .querySelectorAll(".jsEditIgnoreButton") + .forEach((el) => el.addEventListener("click", (ev) => this.openDialog(ev))); + } + + protected openDialog(event: Event): void { + const button = event.currentTarget as HTMLAnchorElement; + const userId = ~~(button.closest(".jsIgnoredUser") as HTMLLIElement).dataset.objectId!; + + if (!this.dialogs.has(userId)) { + this.dialogs.set( + userId, + new FormBuilderDialog("ignoreDialog", "wcf\\data\\user\\ignore\\UserIgnoreAction", "getDialog", { + dialog: { + title: Language.get("wcf.user.button.ignore"), + }, + actionParameters: { + userID: userId, + }, + submitActionName: "submitDialog", + successCallback(data: AjaxResponse) { + UiNotification.show(undefined, () => { + if (!data.isIgnoredUser) { + window.location.reload(); + } + }); + }, + }), + ); + } + + this.dialogs.get(userId)!.open(); + } +} + +export default UiUserIgnoreList; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Ignore/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Ignore/List.js new file mode 100644 index 0000000000..8b0e277632 --- /dev/null +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Ignore/List.js @@ -0,0 +1,49 @@ +/** + * Shows the ignore dialogs when editing users on the page listing ignored users. + * + * @author Matthias Schmidt + * @copyright 2001-2021 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Ui/User/Ignore/List + */ +define(["require", "exports", "tslib", "../../../Form/Builder/Dialog", "../../../Language", "../../Notification"], function (require, exports, tslib_1, Dialog_1, Language, UiNotification) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.UiUserIgnoreList = void 0; + Dialog_1 = tslib_1.__importDefault(Dialog_1); + Language = tslib_1.__importStar(Language); + UiNotification = tslib_1.__importStar(UiNotification); + class UiUserIgnoreList { + constructor() { + this.dialogs = new Map(); + document + .querySelectorAll(".jsEditIgnoreButton") + .forEach((el) => el.addEventListener("click", (ev) => this.openDialog(ev))); + } + openDialog(event) { + const button = event.currentTarget; + const userId = ~~button.closest(".jsIgnoredUser").dataset.objectId; + if (!this.dialogs.has(userId)) { + this.dialogs.set(userId, new Dialog_1.default("ignoreDialog", "wcf\\data\\user\\ignore\\UserIgnoreAction", "getDialog", { + dialog: { + title: Language.get("wcf.user.button.ignore"), + }, + actionParameters: { + userID: userId, + }, + submitActionName: "submitDialog", + successCallback(data) { + UiNotification.show(undefined, () => { + if (!data.isIgnoredUser) { + window.location.reload(); + } + }); + }, + })); + } + this.dialogs.get(userId).open(); + } + } + exports.UiUserIgnoreList = UiUserIgnoreList; + exports.default = UiUserIgnoreList; +});