Convert `Form/Builder/Field/Acl` to TypeScript
authorMatthias Schmidt <gravatronics@live.com>
Wed, 9 Dec 2020 16:32:58 +0000 (17:32 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 15 Dec 2020 17:23:04 +0000 (18:23 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Acl.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Acl.js [deleted file]
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Acl.ts [new file with mode: 0644]

index 44e5559a6d1338aebb66d01e730044fe7c808a71..ef94c0247bb2b14b3e8c09bb8d3d33621e5058cb 100644 (file)
@@ -1,45 +1,30 @@
 /**
  * Data handler for a acl form builder field in an Ajax form.
  *
- * @author     Matthias Schmidt
- * @copyright  2001-2020 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module     WoltLabSuite/Core/Form/Builder/Field/Acl
- * @since      5.2.3
+ * @author  Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module  WoltLabSuite/Core/Form/Builder/Field/Acl
+ * @since 5.2.3
  */
-define(['Core', './Field'], function (Core, FormBuilderField) {
+define(["require", "exports", "tslib", "./Field", "../../../Core"], function (require, exports, tslib_1, Field_1, Core) {
     "use strict";
-    /**
-     * @constructor
-     */
-    function FormBuilderFieldAcl(fieldId) {
-        this.init(fieldId);
-        this._aclList = null;
-    }
-    ;
-    Core.inherit(FormBuilderFieldAcl, FormBuilderField, {
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-         */
-        _getData: function () {
-            var data = {};
-            data[this._fieldId] = this._aclList.getData();
-            return data;
-        },
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#_readField
-         */
-        _readField: function () {
+    Field_1 = tslib_1.__importDefault(Field_1);
+    Core = tslib_1.__importStar(Core);
+    class Acl extends Field_1.default {
+        _getData() {
+            return {
+                [this._fieldId]: this._aclList.getData(),
+            };
+        }
+        _readField() {
             // does nothing
-        },
-        /**
-         * Sets the ACL list object used to extract the ACL values.
-         *
-         * @param      {WCF.ACL.List}          aclList
-         */
-        setAclList: function (aclList) {
+        }
+        setAclList(aclList) {
             this._aclList = aclList;
+            return this;
         }
-    });
-    return FormBuilderFieldAcl;
+    }
+    Core.enableLegacyInheritance(Acl);
+    return Acl;
 });
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Acl.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Acl.js
deleted file mode 100644 (file)
index c984d4c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Data handler for a acl form builder field in an Ajax form.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2020 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module     WoltLabSuite/Core/Form/Builder/Field/Acl
- * @since      5.2.3
- */
-define(['Core', './Field'], function(Core, FormBuilderField) {
-       "use strict";
-       
-       /**
-        * @constructor
-        */
-       function FormBuilderFieldAcl(fieldId) {
-               this.init(fieldId);
-               
-               this._aclList = null;
-       };
-       Core.inherit(FormBuilderFieldAcl, FormBuilderField, {
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-                */
-               _getData: function() {
-                       var data = {};
-                       
-                       data[this._fieldId] = this._aclList.getData();
-                       
-                       return data;
-               },
-               
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#_readField
-                */
-               _readField: function() {
-                       // does nothing
-               },
-               
-               /**
-                * Sets the ACL list object used to extract the ACL values.
-                * 
-                * @param       {WCF.ACL.List}          aclList
-                */
-               setAclList: function(aclList) {
-                       this._aclList = aclList;
-               }
-       });
-       
-       return FormBuilderFieldAcl;
-});
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Acl.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Acl.ts
new file mode 100644 (file)
index 0000000..88e1391
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * Data handler for a acl form builder field in an Ajax form.
+ *
+ * @author  Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module  WoltLabSuite/Core/Form/Builder/Field/Acl
+ * @since 5.2.3
+ */
+
+import Field from "./Field";
+import { FormBuilderData } from "../Data";
+import * as Core from "../../../Core";
+
+interface AclList {
+  getData: () => object;
+}
+
+class Acl extends Field {
+  protected _aclList: AclList;
+
+  protected _getData(): FormBuilderData {
+    return {
+      [this._fieldId]: this._aclList.getData(),
+    };
+  }
+
+  protected _readField(): void {
+    // does nothing
+  }
+
+  public setAclList(aclList: AclList): Acl {
+    this._aclList = aclList;
+
+    return this;
+  }
+}
+
+Core.enableLegacyInheritance(Acl);
+
+export = Acl;