From: Matthias Schmidt Date: Wed, 9 Dec 2020 16:35:10 +0000 (+0100) Subject: Convert `Form/Builder/Field/Value` to TypeScript X-Git-Tag: 5.4.0_Alpha_1~526^2~24 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=68367aa6a6ddcc6e23fb07b2712ae123aace4523;p=GitHub%2FWoltLab%2FWCF.git Convert `Form/Builder/Field/Value` to TypeScript --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Value.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Value.js index e5e03d172a..0c668e0c81 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Value.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Value.js @@ -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 - * @module WoltLabSuite/Core/Form/Builder/Field/Value - * @since 5.2 + * @author Matthias Schmidt + * @copyright 2001-2020 WoltLab GmbH + * @license GNU Lesser General Public License + * @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 index a404ee4a60..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Value.js +++ /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 - * @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 index 0000000000..89fb2ed545 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Value.ts @@ -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 + * @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;