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

index 9b567dfe760cfcb35064c97439a4051948ff280b..2fab9dedcf38c152669dae7981412073fa05df26 100644 (file)
@@ -1,30 +1,15 @@
-/**
- * Data handler for a date form builder field in an Ajax form.
- *
- * @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/Date
- * @since      5.2
- */
-define(['Core', 'WoltLabSuite/Core/Date/Picker', './Field'], function (Core, DatePicker, FormBuilderField) {
+define(["require", "exports", "tslib", "./Field", "../../../Date/Picker", "../../../Core"], function (require, exports, tslib_1, Field_1, Picker_1, Core) {
     "use strict";
-    /**
-     * @constructor
-     */
-    function FormBuilderFieldDate(fieldId) {
-        this.init(fieldId);
-    }
-    ;
-    Core.inherit(FormBuilderFieldDate, FormBuilderField, {
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-         */
-        _getData: function () {
-            var data = {};
-            data[this._fieldId] = DatePicker.getValue(this._field);
-            return data;
+    Field_1 = tslib_1.__importDefault(Field_1);
+    Picker_1 = tslib_1.__importDefault(Picker_1);
+    Core = tslib_1.__importStar(Core);
+    class Date extends Field_1.default {
+        _getData() {
+            return {
+                [this._fieldId]: Picker_1.default.getValue(this._field),
+            };
         }
-    });
-    return FormBuilderFieldDate;
+    }
+    Core.enableLegacyInheritance(Date);
+    return Date;
 });
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.js
deleted file mode 100644 (file)
index 770d742..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Data handler for a date form builder field in an Ajax form.
- * 
- * @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/Date
- * @since      5.2
- */
-define(['Core', 'WoltLabSuite/Core/Date/Picker', './Field'], function(Core, DatePicker, FormBuilderField) {
-       "use strict";
-       
-       /**
-        * @constructor
-        */
-       function FormBuilderFieldDate(fieldId) {
-               this.init(fieldId);
-       };
-       Core.inherit(FormBuilderFieldDate, FormBuilderField, {
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#_getData
-                */
-               _getData: function() {
-                       var data = {};
-                       
-                       data[this._fieldId] = DatePicker.getValue(this._field);
-                       
-                       return data;
-               }
-       });
-       
-       return FormBuilderFieldDate;
-});
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.ts
new file mode 100644 (file)
index 0000000..7ceb95d
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * Data handler for a date 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/Date
+ * @since 5.2
+ */
+import Field from "./Field";
+import { FormBuilderData } from "../Data";
+import DatePicker from "../../../Date/Picker";
+import * as Core from "../../../Core";
+
+class Date extends Field {
+  protected _getData(): FormBuilderData {
+    return {
+      [this._fieldId]: DatePicker.getValue(this._field as HTMLInputElement),
+    };
+  }
+}
+
+Core.enableLegacyInheritance(Date);
+
+export = Date;