From f8ce303bfbbc42baed3751ff102a24d93ecd1ab0 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 9 Dec 2020 17:33:50 +0100 Subject: [PATCH] Convert `Form/Builder/Field/Date` to TypeScript --- .../Core/Form/Builder/Field/Date.js | 39 ++++++------------- .../Core/Form/Builder/Field/Date.js | 33 ---------------- .../Core/Form/Builder/Field/Date.ts | 25 ++++++++++++ 3 files changed, 37 insertions(+), 60 deletions(-) delete mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.js create mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.ts diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Date.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Date.js index 9b567dfe76..2fab9dedcf 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Date.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Date.js @@ -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 - * @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 index 770d742a6c..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.js +++ /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 - * @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 index 0000000000..7ceb95ddf8 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Date.ts @@ -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 + * @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; -- 2.20.1