Convert `Ui/User/Profile/Menu/Item/Ignore` to TypeScript
authorAlexander Ebert <ebert@woltlab.com>
Sat, 31 Oct 2020 12:12:38 +0000 (13:12 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 31 Oct 2020 12:12:38 +0000 (13:12 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.js [deleted file]
wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/User/Profile/Menu/Item/Ignore.ts [new file with mode: 0644]

index adbfb5099f09750e743f508f38baa9e87ce723f0..3f3a275361c4c3846d25a12e2e304c3813301da9 100644 (file)
@@ -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 (file)
index 00d6161..0000000
+++ /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 (file)
index 0000000..b376d01
--- /dev/null
@@ -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;