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

index e5e03d172ac014c4d23ea9b50ebcf58cb146ffbe..0c668e0c81a2e5a52dfd79a11d646560889e4257 100644 (file)
@@ -2,30 +2,23 @@
  * Data handler for a form builder field in an Ajax form that stores its value in an input's value
  * attribute.
  *
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module     WoltLabSuite/Core/Form/Builder/Field/Value
- * @since      5.2
+ * @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.2
  */
-define(['Core', './Field'], function (Core, FormBuilderField) {
+define(["require", "exports", "tslib", "./Field", "../../../Core"], function (require, exports, tslib_1, Field_1, Core) {
     "use strict";
-    /**
-     * @constructor
-     */
-    function FormBuilderFieldValue(fieldId) {
-        this.init(fieldId);
-    }
-    ;
-    Core.inherit(FormBuilderFieldValue, FormBuilderField, {
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-         */
-        _getData: function () {
-            var data = {};
-            data[this._fieldId] = this._field.value;
-            return data;
+    Field_1 = tslib_1.__importDefault(Field_1);
+    Core = tslib_1.__importStar(Core);
+    class Value extends Field_1.default {
+        _getData() {
+            return {
+                [this._fieldId]: this._field.value,
+            };
         }
-    });
-    return FormBuilderFieldValue;
+    }
+    Core.enableLegacyInheritance(Value);
+    return Value;
 });
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Value.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Value.js
deleted file mode 100644 (file)
index a404ee4..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Data handler for a form builder field in an Ajax form that stores its value in an input's value
- * attribute.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module     WoltLabSuite/Core/Form/Builder/Field/Value
- * @since      5.2
- */
-define(['Core', './Field'], function(Core, FormBuilderField) {
-       "use strict";
-       
-       /**
-        * @constructor
-        */
-       function FormBuilderFieldValue(fieldId) {
-               this.init(fieldId);
-       };
-       Core.inherit(FormBuilderFieldValue, FormBuilderField, {
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-                */
-               _getData: function() {
-                       var data = {};
-                       
-                       data[this._fieldId] = this._field.value;
-                       
-                       return data;
-               }
-       });
-       
-       return FormBuilderFieldValue;
-});
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Value.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Value.ts
new file mode 100644 (file)
index 0000000..89fb2ed
--- /dev/null
@@ -0,0 +1,26 @@
+/**
+ * Data handler for a form builder field in an Ajax form that stores its value in an input's value
+ * attribute.
+ *
+ * @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.2
+ */
+
+import Field from "./Field";
+import { FormBuilderData } from "../Data";
+import * as Core from "../../../Core";
+
+class Value extends Field {
+  protected _getData(): FormBuilderData {
+    return {
+      [this._fieldId]: (this._field as HTMLInputElement).value,
+    };
+  }
+}
+
+Core.enableLegacyInheritance(Value);
+
+export = Value;