From 273714002e6c80422bca27eac67fe7f6a037929b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 31 Oct 2020 13:12:38 +0100 Subject: [PATCH] Convert `Ui/User/Profile/Menu/Item/Ignore` to TypeScript --- .../Core/Ui/User/Profile/Menu/Item/Ignore.js | 51 ++++++++----------- .../Core/Ui/User/Profile/Menu/Item/Ignore.js | 46 ----------------- .../Core/Ui/User/Profile/Menu/Item/Ignore.ts | 41 +++++++++++++++ 3 files changed, 62 insertions(+), 76 deletions(-) delete mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js create mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.ts diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js index adbfb5099f..3f3a275361 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js @@ -1,39 +1,30 @@ -define(['Core', 'Language', 'Ui/Notification', './Abstract'], function (Core, Language, UiNotification, UiUserProfileMenuItemAbstract) { +define(["require", "exports", "tslib", "../../../../../Language", "../../../../Notification", "./Abstract"], function (require, exports, tslib_1, Language, UiNotification, Abstract_1) { "use strict"; - if (!COMPILER_TARGET_DEFAULT) { - var Fake = function () { }; - Fake.prototype = { - _getLabel: function () { }, - _getAjaxActionName: function () { }, - _ajaxSuccess: function () { }, - _ajaxSetup: function () { }, - init: function () { }, - _initButton: function () { }, - _toggle: function () { }, - _updateButton: function () { } - }; - return Fake; - } - function UiUserProfileMenuItemIgnore(userId, isActive) { this.init(userId, isActive); } - Core.inherit(UiUserProfileMenuItemIgnore, UiUserProfileMenuItemAbstract, { - _getLabel: function () { - return Language.get('wcf.user.button.' + (this._isActive ? 'un' : '') + 'ignore'); - }, - _getAjaxActionName: function () { - return this._isActive ? 'unignore' : 'ignore'; - }, - _ajaxSuccess: function (data) { - this._isActive = (data.returnValues.isIgnoredUser ? true : false); + Language = tslib_1.__importStar(Language); + UiNotification = tslib_1.__importStar(UiNotification); + Abstract_1 = tslib_1.__importDefault(Abstract_1); + class UiUserProfileMenuItemIgnore extends Abstract_1.default { + constructor(userId, isActive) { + super(userId, isActive); + } + _getLabel() { + return Language.get("wcf.user.button." + (this._isActive ? "un" : "") + "ignore"); + } + _getAjaxActionName() { + return this._isActive ? "unignore" : "ignore"; + } + _ajaxSuccess(data) { + this._isActive = !!data.returnValues.isIgnoredUser; this._updateButton(); UiNotification.show(); - }, - _ajaxSetup: function () { + } + _ajaxSetup() { return { data: { - className: 'wcf\\data\\user\\ignore\\UserIgnoreAction' - } + className: "wcf\\data\\user\\ignore\\UserIgnoreAction", + }, }; } - }); + } return UiUserProfileMenuItemIgnore; }); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js deleted file mode 100644 index 00d61610c5..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js +++ /dev/null @@ -1,46 +0,0 @@ -define(['Core', 'Language', 'Ui/Notification', './Abstract'], function(Core, Language, UiNotification, UiUserProfileMenuItemAbstract) { - "use strict"; - - if (!COMPILER_TARGET_DEFAULT) { - var Fake = function() {}; - Fake.prototype = { - _getLabel: function() {}, - _getAjaxActionName: function() {}, - _ajaxSuccess: function() {}, - _ajaxSetup: function() {}, - init: function() {}, - _initButton: function() {}, - _toggle: function() {}, - _updateButton: function() {} - }; - return Fake; - } - - function UiUserProfileMenuItemIgnore(userId, isActive) { this.init(userId, isActive); } - Core.inherit(UiUserProfileMenuItemIgnore, UiUserProfileMenuItemAbstract, { - _getLabel: function() { - return Language.get('wcf.user.button.' + (this._isActive ? 'un' : '') + 'ignore'); - }, - - _getAjaxActionName: function() { - return this._isActive ? 'unignore' : 'ignore'; - }, - - _ajaxSuccess: function(data) { - this._isActive = (data.returnValues.isIgnoredUser ? true : false); - this._updateButton(); - - UiNotification.show(); - }, - - _ajaxSetup: function() { - return { - data: { - className: 'wcf\\data\\user\\ignore\\UserIgnoreAction' - } - }; - } - }); - - return UiUserProfileMenuItemIgnore; -}); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.ts new file mode 100644 index 0000000000..b376d01f16 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.ts @@ -0,0 +1,41 @@ +import * as Language from "../../../../../Language"; +import { RequestOptions, ResponseData } from "../../../../../Ajax/Data"; +import * as UiNotification from "../../../../Notification"; +import UiUserProfileMenuItemAbstract from "./Abstract"; + +interface AjaxResponse extends ResponseData { + returnValues: { + isIgnoredUser: 1 | 0; + }; +} + +class UiUserProfileMenuItemIgnore extends UiUserProfileMenuItemAbstract { + constructor(userId: number, isActive: boolean) { + super(userId, isActive); + } + + _getLabel(): string { + return Language.get("wcf.user.button." + (this._isActive ? "un" : "") + "ignore"); + } + + _getAjaxActionName(): string { + return this._isActive ? "unignore" : "ignore"; + } + + _ajaxSuccess(data: AjaxResponse): void { + this._isActive = !!data.returnValues.isIgnoredUser; + this._updateButton(); + + UiNotification.show(); + } + + _ajaxSetup(): RequestOptions { + return { + data: { + className: "wcf\\data\\user\\ignore\\UserIgnoreAction", + }, + }; + } +} + +export = UiUserProfileMenuItemIgnore; -- 2.20.1