Convert `Form/Builder/Field/Button` to TypeScript
authorMatthias Schmidt <gravatronics@live.com>
Wed, 9 Dec 2020 16:33:12 +0000 (17:33 +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/Button.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.js [deleted file]
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.ts [new file with mode: 0644]

index 137aa5551809009b88c1b32d1b8d22e860092525..ff97b3835f4cd44cfe3afbb586da80fab65553af 100644 (file)
@@ -1,32 +1,24 @@
 /**
  * Data handler for a button 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/Value
- * @since       5.4
+ * @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/Value
+ * @since 5.4
  */
-define(['Core', './Field'], function (Core, FormBuilderField) {
+define(["require", "exports", "tslib", "./Field"], function (require, exports, tslib_1, Field_1) {
     "use strict";
-    /**
-     * @constructor
-     */
-    function FormBuilderFieldButton(fieldId) {
-        this.init(fieldId);
-    }
-    ;
-    Core.inherit(FormBuilderFieldButton, FormBuilderField, {
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-         */
-        _getData: function () {
-            var data = {};
+    Object.defineProperty(exports, "__esModule", { value: true });
+    Field_1 = tslib_1.__importDefault(Field_1);
+    class Button extends Field_1.default {
+        _getData() {
+            const data = {};
             if (this._field.dataset.isClicked === "1") {
                 data[this._fieldId] = this._field.value;
             }
             return data;
         }
-    });
-    return FormBuilderFieldButton;
+    }
+    exports.default = Button;
 });
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.js
deleted file mode 100644 (file)
index eef0575..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Data handler for a button 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/Value
- * @since       5.4
- */
-define(['Core', './Field'], function(Core, FormBuilderField) {
-       "use strict";
-       
-       /**
-        * @constructor
-        */
-       function FormBuilderFieldButton(fieldId) {
-               this.init(fieldId);
-       };
-       Core.inherit(FormBuilderFieldButton, FormBuilderField, {
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-                */
-               _getData: function() {
-                       var data = {};
-                       
-                       if (this._field.dataset.isClicked === "1") {
-                               data[this._fieldId] = this._field.value;
-                       }
-                       
-                       return data;
-               }
-       });
-       
-       return FormBuilderFieldButton;
-});
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Button.ts
new file mode 100644 (file)
index 0000000..08deade
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Data handler for a button 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/Value
+ * @since 5.4
+ */
+
+import Field from "./Field";
+import { FormBuilderData } from "../Data";
+
+export default class Button extends Field {
+  protected _getData(): FormBuilderData {
+    const data = {};
+
+    if (this._field!.dataset.isClicked === "1") {
+      data[this._fieldId] = (this._field! as HTMLInputElement).value;
+    }
+
+    return data;
+  }
+}